@bridgenode/llm 0.2.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 +3 -29
- package/dist/index.cjs +50 -58
- package/dist/index.d.cts +15 -25
- package/dist/index.d.ts +15 -25
- package/dist/index.js +50 -55
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @bridgenode/llm (TypeScript SDK)
|
|
2
2
|
|
|
3
|
-
> **@bridgenode/llm** — TypeScript/Node.js SDK for BridgeNode: pay-per-request AI inference via x402 micropayments on
|
|
3
|
+
> **@bridgenode/llm** — TypeScript/Node.js SDK for BridgeNode: pay-per-request AI inference via x402 micropayments on Solana. No API keys required — your wallet signature is your authentication.
|
|
4
4
|
|
|
5
5
|
**Protocol:** x402 v2
|
|
6
|
-
**Payment:** USDC (
|
|
6
|
+
**Payment:** USDC (Solana SPL)
|
|
7
7
|
**Gasless:** Solana fee sponsorship — agent needs 0 SOL
|
|
8
8
|
|
|
9
9
|
---
|
|
@@ -52,9 +52,6 @@ import { BridgeNodeClient } from "@bridgenode/llm";
|
|
|
52
52
|
|
|
53
53
|
const br = new BridgeNodeClient({ privateKey: "0x..." });
|
|
54
54
|
|
|
55
|
-
// GET
|
|
56
|
-
const data = await br.get("/v1/surf/market/price", { symbol: "BTC" });
|
|
57
|
-
|
|
58
55
|
// POST
|
|
59
56
|
const result = await br.post("/v1/chat/completions", {
|
|
60
57
|
model: "deepseek-v4-flash",
|
|
@@ -73,33 +70,10 @@ for await (const chunk of br.stream("/v1/chat/completions", {
|
|
|
73
70
|
|
|
74
71
|
---
|
|
75
72
|
|
|
76
|
-
##
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
// Auto-detect best model per request
|
|
80
|
-
const response = await client.chat("auto", [
|
|
81
|
-
{ role: "user", content: "Hello!" } // → groq-llama-3.3-70b (cheapest)
|
|
82
|
-
]);
|
|
83
|
-
|
|
84
|
-
const code = await client.chat("auto", [
|
|
85
|
-
{ role: "user", content: "Write a complex Rust function" } // → deepseek-v4-flash
|
|
86
|
-
]);
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
| Prompt type | Model assigned |
|
|
90
|
-
|-------------|---------------|
|
|
91
|
-
| Simple chat | `groq-llama-3.3-70b` |
|
|
92
|
-
| Code / reasoning | `deepseek-v4-flash` |
|
|
93
|
-
| Complex analysis | `deepseek-v4-pro` |
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## Supported Chains
|
|
73
|
+
## Supported Chain
|
|
98
74
|
|
|
99
75
|
| Chain | Payment | Status |
|
|
100
76
|
|-------|---------|--------|
|
|
101
|
-
| **Base** (Chain ID: 8453) | USDC native | ✅ Primary |
|
|
102
|
-
| **Base Sepolia** (Chain ID: 84532) | Testnet USDC | ✅ Development |
|
|
103
77
|
| **Solana Mainnet** | USDC (SPL) | ✅ Active |
|
|
104
78
|
|
|
105
79
|
---
|
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,6 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
APIError: () => APIError,
|
|
34
34
|
AnthropicClient: () => AnthropicClient,
|
|
35
|
-
BASE_CHAIN_ID: () => BASE_CHAIN_ID,
|
|
36
35
|
BridgeNodeClient: () => BridgeNodeClient,
|
|
37
36
|
BridgeNodeError: () => BridgeNodeError,
|
|
38
37
|
ImageClient: () => ImageClient,
|
|
@@ -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" }
|
|
@@ -587,14 +582,14 @@ var LLMClient = class _LLMClient {
|
|
|
587
582
|
/**
|
|
588
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,7 +921,7 @@ 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`,
|
|
@@ -1011,7 +1006,7 @@ 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`,
|
|
@@ -1202,7 +1197,7 @@ 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,
|
|
@@ -1349,7 +1344,7 @@ 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,
|
|
@@ -1930,7 +1925,7 @@ var ImageClient = class {
|
|
|
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(
|
|
@@ -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,7 +3407,7 @@ 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
3413
|
resourceDescription: details.resource?.description || "BridgeNode Virtual Portrait",
|
|
@@ -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",
|
|
@@ -4234,7 +4229,7 @@ var BridgeNodeClient = 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(
|
|
@@ -4540,7 +4535,7 @@ var BridgeNodeClient = 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() {
|
|
@@ -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,13 +4761,13 @@ 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
|
}
|
|
@@ -4781,11 +4776,11 @@ function formatWalletCreatedMessage(address) {
|
|
|
4781
4776
|
return `
|
|
4782
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;
|
|
@@ -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,
|
package/dist/index.d.cts
CHANGED
|
@@ -241,7 +241,7 @@ interface PaymentRequired {
|
|
|
241
241
|
resource?: ResourceInfo;
|
|
242
242
|
}
|
|
243
243
|
interface LLMClientOptions {
|
|
244
|
-
/** EVM wallet private key (hex string starting with 0x). Optional if
|
|
244
|
+
/** EVM wallet private key (hex string starting with 0x). Optional if BRIDGENODE_WALLET_KEY env var is set. */
|
|
245
245
|
privateKey?: `0x${string}` | string;
|
|
246
246
|
/** API endpoint URL (default: https://bridgenode.cc/api) */
|
|
247
247
|
apiUrl?: string;
|
|
@@ -962,7 +962,7 @@ declare class APIError extends BridgeNodeError {
|
|
|
962
962
|
* Usage:
|
|
963
963
|
* import { LLMClient } from '@bridgenode/llm';
|
|
964
964
|
*
|
|
965
|
-
* // Option 1: Use
|
|
965
|
+
* // Option 1: Use BRIDGENODE_WALLET_KEY env var
|
|
966
966
|
* const client = new LLMClient();
|
|
967
967
|
*
|
|
968
968
|
* // Option 2: Pass private key directly
|
|
@@ -994,7 +994,7 @@ declare class LLMClient {
|
|
|
994
994
|
/**
|
|
995
995
|
* Initialize the BridgeNode LLM client.
|
|
996
996
|
*
|
|
997
|
-
* @param options - Client configuration options (optional if
|
|
997
|
+
* @param options - Client configuration options (optional if BRIDGENODE_WALLET_KEY env var is set)
|
|
998
998
|
*/
|
|
999
999
|
constructor(options?: LLMClientOptions);
|
|
1000
1000
|
/**
|
|
@@ -1531,7 +1531,7 @@ declare class ImageClient {
|
|
|
1531
1531
|
* BridgeNode Music Generation Client.
|
|
1532
1532
|
*
|
|
1533
1533
|
* Generate full-length ~3 minute music tracks using MiniMax Music 2.5+
|
|
1534
|
-
* with automatic x402 micropayments on
|
|
1534
|
+
* with automatic x402 micropayments on Solana.
|
|
1535
1535
|
*
|
|
1536
1536
|
* Pricing: $0.1575/track
|
|
1537
1537
|
* Note: Generated URLs expire in ~24h — download immediately if needed.
|
|
@@ -1609,7 +1609,7 @@ declare class MusicClient {
|
|
|
1609
1609
|
* BridgeNode Speech Client (BridgeNode Voice).
|
|
1610
1610
|
*
|
|
1611
1611
|
* Text-to-speech and sound-effect generation using ElevenLabs models
|
|
1612
|
-
* with automatic x402 micropayments on
|
|
1612
|
+
* with automatic x402 micropayments on Solana.
|
|
1613
1613
|
*
|
|
1614
1614
|
* TTS pricing scales with input characters; sound effects are flat
|
|
1615
1615
|
* $0.05/generation.
|
|
@@ -1809,7 +1809,7 @@ declare class VideoClient {
|
|
|
1809
1809
|
* BridgeNode Voice Call Client.
|
|
1810
1810
|
*
|
|
1811
1811
|
* Initiates AI-powered outbound phone calls with automatic x402 micropayments
|
|
1812
|
-
* on
|
|
1812
|
+
* on Solana.
|
|
1813
1813
|
*
|
|
1814
1814
|
* Pricing: $0.54 per call (regardless of duration up to max_duration).
|
|
1815
1815
|
* Status polling is free.
|
|
@@ -2089,7 +2089,7 @@ declare class PriceClient {
|
|
|
2089
2089
|
* wallet intelligence, prediction markets, social analytics, and news under
|
|
2090
2090
|
* a single OpenAPI surface mounted at `/api/v1/surf/*`.
|
|
2091
2091
|
*
|
|
2092
|
-
* Pricing tiers (flat per-call, USDC on
|
|
2092
|
+
* Pricing tiers (flat per-call, USDC on Solana):
|
|
2093
2093
|
* Tier 1 — $0.001/call (prices, rankings, lists, news, simple reads)
|
|
2094
2094
|
* Tier 2 — $0.005/call (order books, candles, search, wallet details)
|
|
2095
2095
|
* Tier 3 — $0.020/call (on-chain SQL, schema introspection, chat)
|
|
@@ -2215,7 +2215,7 @@ declare const NETWORK_ALIASES: Record<string, string>;
|
|
|
2215
2215
|
* BridgeNode Multi-chain RPC Client.
|
|
2216
2216
|
*
|
|
2217
2217
|
* Standard JSON-RPC 2.0 access to 40+ chains through BridgeNode's Tatum
|
|
2218
|
-
* gateway with automatic x402 micropayments on
|
|
2218
|
+
* gateway with automatic x402 micropayments on Solana.
|
|
2219
2219
|
*
|
|
2220
2220
|
* Flat $0.002 per call; a JSON-RPC batch charges per element.
|
|
2221
2221
|
*/
|
|
@@ -2398,10 +2398,9 @@ declare class BridgeNodeClient {
|
|
|
2398
2398
|
*
|
|
2399
2399
|
* This module handles creating signed payment payloads for the x402 v2 protocol.
|
|
2400
2400
|
* The private key is used ONLY for local signing and NEVER leaves the client.
|
|
2401
|
+
* Solana only — no Base/EVM chain support.
|
|
2401
2402
|
*/
|
|
2402
2403
|
|
|
2403
|
-
declare const BASE_CHAIN_ID = 8453;
|
|
2404
|
-
declare const USDC_BASE: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
2405
2404
|
declare const SOLANA_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
2406
2405
|
declare const USDC_SOLANA = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
2407
2406
|
interface CreatePaymentOptions {
|
|
@@ -2421,7 +2420,7 @@ interface CreatePaymentOptions {
|
|
|
2421
2420
|
* @param fromAddress - Sender wallet address
|
|
2422
2421
|
* @param recipient - Payment recipient address
|
|
2423
2422
|
* @param amount - Amount in micro USDC (6 decimals)
|
|
2424
|
-
* @param network - Network identifier (default:
|
|
2423
|
+
* @param network - Network identifier (default: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp)
|
|
2425
2424
|
* @param options - Additional options for resource info
|
|
2426
2425
|
* @returns Base64-encoded signed payment payload
|
|
2427
2426
|
*/
|
|
@@ -2470,9 +2469,9 @@ declare function parsePaymentRequired(headerValue: string): PaymentRequired;
|
|
|
2470
2469
|
*
|
|
2471
2470
|
* @param paymentRequired - Parsed payment required object
|
|
2472
2471
|
* @param preferredNetwork - Optional network preference. If specified, will try
|
|
2473
|
-
* to use matching network option. Defaults to first option
|
|
2472
|
+
* to use matching network option. Defaults to first option ).
|
|
2474
2473
|
* Examples:
|
|
2475
|
-
* -
|
|
2474
|
+
* - SOLANA_NETWORK for Base
|
|
2476
2475
|
* - "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" for Solana
|
|
2477
2476
|
*/
|
|
2478
2477
|
declare function extractPaymentDetails(paymentRequired: PaymentRequired, preferredNetwork?: string): {
|
|
@@ -2490,15 +2489,6 @@ declare function extractPaymentDetails(paymentRequired: PaymentRequired, preferr
|
|
|
2490
2489
|
resource?: ResourceInfo;
|
|
2491
2490
|
};
|
|
2492
2491
|
|
|
2493
|
-
/**
|
|
2494
|
-
* BridgeNode Wallet Management - Auto-create and manage wallets.
|
|
2495
|
-
*
|
|
2496
|
-
* Provides frictionless wallet setup for new users:
|
|
2497
|
-
* - Auto-creates wallet if none exists
|
|
2498
|
-
* - Stores key securely at ~/.bridgenode/.session
|
|
2499
|
-
* - Generates EIP-681 URIs for easy MetaMask funding
|
|
2500
|
-
*/
|
|
2501
|
-
declare const USDC_BASE_CONTRACT = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
2502
2492
|
interface WalletInfo {
|
|
2503
2493
|
privateKey: string;
|
|
2504
2494
|
address: string;
|
|
@@ -2618,7 +2608,7 @@ declare function getOrCreateWallet(): WalletInfo;
|
|
|
2618
2608
|
*/
|
|
2619
2609
|
declare function getWalletAddress(): string | null;
|
|
2620
2610
|
/**
|
|
2621
|
-
* Generate EIP-681 URI for USDC transfer
|
|
2611
|
+
* Generate EIP-681 URI for Solana USDC transfer.
|
|
2622
2612
|
*
|
|
2623
2613
|
* @param address - Recipient Ethereum address
|
|
2624
2614
|
* @param amountUsdc - Amount in USDC (default 1.0)
|
|
@@ -2964,7 +2954,7 @@ interface CostEntry {
|
|
|
2964
2954
|
model?: string;
|
|
2965
2955
|
/** Payer wallet address (EVM 0x... or Solana base58). */
|
|
2966
2956
|
wallet?: string;
|
|
2967
|
-
/** Network identifier —
|
|
2957
|
+
/** Network identifier — SOLANA_NETWORK for Solana mainnet, "solana-mainnet", etc. */
|
|
2968
2958
|
network?: string;
|
|
2969
2959
|
/** Caller kind for analytics — "LLMClient", "ImageClient", "AgentClient", ... */
|
|
2970
2960
|
client_kind?: string;
|
|
@@ -3207,4 +3197,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
3207
3197
|
*/
|
|
3208
3198
|
declare function validateTopP(topP?: number): void;
|
|
3209
3199
|
|
|
3210
|
-
export { APIError, AnthropicClient, type AudioModel, type AudioTrack,
|
|
3200
|
+
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, type BarResolution, type BridgeNodeAnthropicOptions, BridgeNodeClient, type BridgeNodeClientOptions, BridgeNodeError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, RPC_PRICE_USD, type ResponseFormat, type RoutingDecision, type RoutingProfile, type RoutingTier, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XSearchSource, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
package/dist/index.d.ts
CHANGED
|
@@ -241,7 +241,7 @@ interface PaymentRequired {
|
|
|
241
241
|
resource?: ResourceInfo;
|
|
242
242
|
}
|
|
243
243
|
interface LLMClientOptions {
|
|
244
|
-
/** EVM wallet private key (hex string starting with 0x). Optional if
|
|
244
|
+
/** EVM wallet private key (hex string starting with 0x). Optional if BRIDGENODE_WALLET_KEY env var is set. */
|
|
245
245
|
privateKey?: `0x${string}` | string;
|
|
246
246
|
/** API endpoint URL (default: https://bridgenode.cc/api) */
|
|
247
247
|
apiUrl?: string;
|
|
@@ -962,7 +962,7 @@ declare class APIError extends BridgeNodeError {
|
|
|
962
962
|
* Usage:
|
|
963
963
|
* import { LLMClient } from '@bridgenode/llm';
|
|
964
964
|
*
|
|
965
|
-
* // Option 1: Use
|
|
965
|
+
* // Option 1: Use BRIDGENODE_WALLET_KEY env var
|
|
966
966
|
* const client = new LLMClient();
|
|
967
967
|
*
|
|
968
968
|
* // Option 2: Pass private key directly
|
|
@@ -994,7 +994,7 @@ declare class LLMClient {
|
|
|
994
994
|
/**
|
|
995
995
|
* Initialize the BridgeNode LLM client.
|
|
996
996
|
*
|
|
997
|
-
* @param options - Client configuration options (optional if
|
|
997
|
+
* @param options - Client configuration options (optional if BRIDGENODE_WALLET_KEY env var is set)
|
|
998
998
|
*/
|
|
999
999
|
constructor(options?: LLMClientOptions);
|
|
1000
1000
|
/**
|
|
@@ -1531,7 +1531,7 @@ declare class ImageClient {
|
|
|
1531
1531
|
* BridgeNode Music Generation Client.
|
|
1532
1532
|
*
|
|
1533
1533
|
* Generate full-length ~3 minute music tracks using MiniMax Music 2.5+
|
|
1534
|
-
* with automatic x402 micropayments on
|
|
1534
|
+
* with automatic x402 micropayments on Solana.
|
|
1535
1535
|
*
|
|
1536
1536
|
* Pricing: $0.1575/track
|
|
1537
1537
|
* Note: Generated URLs expire in ~24h — download immediately if needed.
|
|
@@ -1609,7 +1609,7 @@ declare class MusicClient {
|
|
|
1609
1609
|
* BridgeNode Speech Client (BridgeNode Voice).
|
|
1610
1610
|
*
|
|
1611
1611
|
* Text-to-speech and sound-effect generation using ElevenLabs models
|
|
1612
|
-
* with automatic x402 micropayments on
|
|
1612
|
+
* with automatic x402 micropayments on Solana.
|
|
1613
1613
|
*
|
|
1614
1614
|
* TTS pricing scales with input characters; sound effects are flat
|
|
1615
1615
|
* $0.05/generation.
|
|
@@ -1809,7 +1809,7 @@ declare class VideoClient {
|
|
|
1809
1809
|
* BridgeNode Voice Call Client.
|
|
1810
1810
|
*
|
|
1811
1811
|
* Initiates AI-powered outbound phone calls with automatic x402 micropayments
|
|
1812
|
-
* on
|
|
1812
|
+
* on Solana.
|
|
1813
1813
|
*
|
|
1814
1814
|
* Pricing: $0.54 per call (regardless of duration up to max_duration).
|
|
1815
1815
|
* Status polling is free.
|
|
@@ -2089,7 +2089,7 @@ declare class PriceClient {
|
|
|
2089
2089
|
* wallet intelligence, prediction markets, social analytics, and news under
|
|
2090
2090
|
* a single OpenAPI surface mounted at `/api/v1/surf/*`.
|
|
2091
2091
|
*
|
|
2092
|
-
* Pricing tiers (flat per-call, USDC on
|
|
2092
|
+
* Pricing tiers (flat per-call, USDC on Solana):
|
|
2093
2093
|
* Tier 1 — $0.001/call (prices, rankings, lists, news, simple reads)
|
|
2094
2094
|
* Tier 2 — $0.005/call (order books, candles, search, wallet details)
|
|
2095
2095
|
* Tier 3 — $0.020/call (on-chain SQL, schema introspection, chat)
|
|
@@ -2215,7 +2215,7 @@ declare const NETWORK_ALIASES: Record<string, string>;
|
|
|
2215
2215
|
* BridgeNode Multi-chain RPC Client.
|
|
2216
2216
|
*
|
|
2217
2217
|
* Standard JSON-RPC 2.0 access to 40+ chains through BridgeNode's Tatum
|
|
2218
|
-
* gateway with automatic x402 micropayments on
|
|
2218
|
+
* gateway with automatic x402 micropayments on Solana.
|
|
2219
2219
|
*
|
|
2220
2220
|
* Flat $0.002 per call; a JSON-RPC batch charges per element.
|
|
2221
2221
|
*/
|
|
@@ -2398,10 +2398,9 @@ declare class BridgeNodeClient {
|
|
|
2398
2398
|
*
|
|
2399
2399
|
* This module handles creating signed payment payloads for the x402 v2 protocol.
|
|
2400
2400
|
* The private key is used ONLY for local signing and NEVER leaves the client.
|
|
2401
|
+
* Solana only — no Base/EVM chain support.
|
|
2401
2402
|
*/
|
|
2402
2403
|
|
|
2403
|
-
declare const BASE_CHAIN_ID = 8453;
|
|
2404
|
-
declare const USDC_BASE: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
2405
2404
|
declare const SOLANA_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
2406
2405
|
declare const USDC_SOLANA = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
2407
2406
|
interface CreatePaymentOptions {
|
|
@@ -2421,7 +2420,7 @@ interface CreatePaymentOptions {
|
|
|
2421
2420
|
* @param fromAddress - Sender wallet address
|
|
2422
2421
|
* @param recipient - Payment recipient address
|
|
2423
2422
|
* @param amount - Amount in micro USDC (6 decimals)
|
|
2424
|
-
* @param network - Network identifier (default:
|
|
2423
|
+
* @param network - Network identifier (default: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp)
|
|
2425
2424
|
* @param options - Additional options for resource info
|
|
2426
2425
|
* @returns Base64-encoded signed payment payload
|
|
2427
2426
|
*/
|
|
@@ -2470,9 +2469,9 @@ declare function parsePaymentRequired(headerValue: string): PaymentRequired;
|
|
|
2470
2469
|
*
|
|
2471
2470
|
* @param paymentRequired - Parsed payment required object
|
|
2472
2471
|
* @param preferredNetwork - Optional network preference. If specified, will try
|
|
2473
|
-
* to use matching network option. Defaults to first option
|
|
2472
|
+
* to use matching network option. Defaults to first option ).
|
|
2474
2473
|
* Examples:
|
|
2475
|
-
* -
|
|
2474
|
+
* - SOLANA_NETWORK for Base
|
|
2476
2475
|
* - "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" for Solana
|
|
2477
2476
|
*/
|
|
2478
2477
|
declare function extractPaymentDetails(paymentRequired: PaymentRequired, preferredNetwork?: string): {
|
|
@@ -2490,15 +2489,6 @@ declare function extractPaymentDetails(paymentRequired: PaymentRequired, preferr
|
|
|
2490
2489
|
resource?: ResourceInfo;
|
|
2491
2490
|
};
|
|
2492
2491
|
|
|
2493
|
-
/**
|
|
2494
|
-
* BridgeNode Wallet Management - Auto-create and manage wallets.
|
|
2495
|
-
*
|
|
2496
|
-
* Provides frictionless wallet setup for new users:
|
|
2497
|
-
* - Auto-creates wallet if none exists
|
|
2498
|
-
* - Stores key securely at ~/.bridgenode/.session
|
|
2499
|
-
* - Generates EIP-681 URIs for easy MetaMask funding
|
|
2500
|
-
*/
|
|
2501
|
-
declare const USDC_BASE_CONTRACT = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
2502
2492
|
interface WalletInfo {
|
|
2503
2493
|
privateKey: string;
|
|
2504
2494
|
address: string;
|
|
@@ -2618,7 +2608,7 @@ declare function getOrCreateWallet(): WalletInfo;
|
|
|
2618
2608
|
*/
|
|
2619
2609
|
declare function getWalletAddress(): string | null;
|
|
2620
2610
|
/**
|
|
2621
|
-
* Generate EIP-681 URI for USDC transfer
|
|
2611
|
+
* Generate EIP-681 URI for Solana USDC transfer.
|
|
2622
2612
|
*
|
|
2623
2613
|
* @param address - Recipient Ethereum address
|
|
2624
2614
|
* @param amountUsdc - Amount in USDC (default 1.0)
|
|
@@ -2964,7 +2954,7 @@ interface CostEntry {
|
|
|
2964
2954
|
model?: string;
|
|
2965
2955
|
/** Payer wallet address (EVM 0x... or Solana base58). */
|
|
2966
2956
|
wallet?: string;
|
|
2967
|
-
/** Network identifier —
|
|
2957
|
+
/** Network identifier — SOLANA_NETWORK for Solana mainnet, "solana-mainnet", etc. */
|
|
2968
2958
|
network?: string;
|
|
2969
2959
|
/** Caller kind for analytics — "LLMClient", "ImageClient", "AgentClient", ... */
|
|
2970
2960
|
client_kind?: string;
|
|
@@ -3207,4 +3197,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
3207
3197
|
*/
|
|
3208
3198
|
declare function validateTopP(topP?: number): void;
|
|
3209
3199
|
|
|
3210
|
-
export { APIError, AnthropicClient, type AudioModel, type AudioTrack,
|
|
3200
|
+
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, type BarResolution, type BridgeNodeAnthropicOptions, BridgeNodeClient, type BridgeNodeClientOptions, BridgeNodeError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, RPC_PRICE_USD, type ResponseFormat, type RoutingDecision, type RoutingProfile, type RoutingTier, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XSearchSource, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
package/dist/index.js
CHANGED
|
@@ -27,8 +27,6 @@ var APIError = class extends BridgeNodeError {
|
|
|
27
27
|
|
|
28
28
|
// src/x402.ts
|
|
29
29
|
import { signTypedData } from "viem/accounts";
|
|
30
|
-
var BASE_CHAIN_ID = 8453;
|
|
31
|
-
var USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
32
30
|
var SOLANA_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
33
31
|
var USDC_SOLANA = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
34
32
|
var DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1;
|
|
@@ -36,8 +34,8 @@ var DEFAULT_COMPUTE_UNIT_LIMIT = 8e3;
|
|
|
36
34
|
var USDC_DOMAIN = {
|
|
37
35
|
name: "USD Coin",
|
|
38
36
|
version: "2",
|
|
39
|
-
chainId:
|
|
40
|
-
verifyingContract:
|
|
37
|
+
chainId: 8453,
|
|
38
|
+
verifyingContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
41
39
|
};
|
|
42
40
|
var TRANSFER_TYPES = {
|
|
43
41
|
TransferWithAuthorization: [
|
|
@@ -64,7 +62,7 @@ function withBuilderCodeServiceCode(extensions) {
|
|
|
64
62
|
};
|
|
65
63
|
return merged;
|
|
66
64
|
}
|
|
67
|
-
async function createPaymentPayload(privateKey, fromAddress, recipient, amount, network =
|
|
65
|
+
async function createPaymentPayload(privateKey, fromAddress, recipient, amount, network = SOLANA_NETWORK, options = {}) {
|
|
68
66
|
const now = Math.floor(Date.now() / 1e3);
|
|
69
67
|
const validAfter = now - 600;
|
|
70
68
|
const validBefore = now + (options.maxTimeoutSeconds || 300);
|
|
@@ -95,7 +93,7 @@ async function createPaymentPayload(privateKey, fromAddress, recipient, amount,
|
|
|
95
93
|
scheme: "exact",
|
|
96
94
|
network,
|
|
97
95
|
amount,
|
|
98
|
-
asset:
|
|
96
|
+
asset: USDC_SOLANA,
|
|
99
97
|
payTo: recipient,
|
|
100
98
|
maxTimeoutSeconds: options.maxTimeoutSeconds || 300,
|
|
101
99
|
extra: { name: "USD Coin", version: "2" }
|
|
@@ -474,14 +472,14 @@ var LLMClient = class _LLMClient {
|
|
|
474
472
|
/**
|
|
475
473
|
* Initialize the BridgeNode LLM client.
|
|
476
474
|
*
|
|
477
|
-
* @param options - Client configuration options (optional if
|
|
475
|
+
* @param options - Client configuration options (optional if BRIDGENODE_WALLET_KEY env var is set)
|
|
478
476
|
*/
|
|
479
477
|
constructor(options = {}) {
|
|
480
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.
|
|
478
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
481
479
|
const privateKey = options.privateKey || envKey;
|
|
482
480
|
if (!privateKey) {
|
|
483
481
|
throw new Error(
|
|
484
|
-
"Private key required. Pass privateKey in options or set
|
|
482
|
+
"Private key required. Pass privateKey in options or set BRIDGENODE_WALLET_KEY environment variable."
|
|
485
483
|
);
|
|
486
484
|
}
|
|
487
485
|
validatePrivateKey(privateKey);
|
|
@@ -813,7 +811,7 @@ var LLMClient = class _LLMClient {
|
|
|
813
811
|
this.account.address,
|
|
814
812
|
details.recipient,
|
|
815
813
|
details.amount,
|
|
816
|
-
details.network ||
|
|
814
|
+
details.network || SOLANA_NETWORK,
|
|
817
815
|
{
|
|
818
816
|
resourceUrl: validateResourceUrl(
|
|
819
817
|
details.resource?.url || `${this.apiUrl}/v1/chat/completions`,
|
|
@@ -898,7 +896,7 @@ var LLMClient = class _LLMClient {
|
|
|
898
896
|
this.account.address,
|
|
899
897
|
details.recipient,
|
|
900
898
|
details.amount,
|
|
901
|
-
details.network ||
|
|
899
|
+
details.network || SOLANA_NETWORK,
|
|
902
900
|
{
|
|
903
901
|
resourceUrl: validateResourceUrl(
|
|
904
902
|
details.resource?.url || `${this.apiUrl}/v1/chat/completions`,
|
|
@@ -1089,7 +1087,7 @@ var LLMClient = class _LLMClient {
|
|
|
1089
1087
|
this.account.address,
|
|
1090
1088
|
details.recipient,
|
|
1091
1089
|
details.amount,
|
|
1092
|
-
details.network ||
|
|
1090
|
+
details.network || SOLANA_NETWORK,
|
|
1093
1091
|
{
|
|
1094
1092
|
resourceUrl: validateResourceUrl(
|
|
1095
1093
|
details.resource?.url || url,
|
|
@@ -1236,7 +1234,7 @@ var LLMClient = class _LLMClient {
|
|
|
1236
1234
|
this.account.address,
|
|
1237
1235
|
details.recipient,
|
|
1238
1236
|
details.amount,
|
|
1239
|
-
details.network ||
|
|
1237
|
+
details.network || SOLANA_NETWORK,
|
|
1240
1238
|
{
|
|
1241
1239
|
resourceUrl: validateResourceUrl(
|
|
1242
1240
|
details.resource?.url || url,
|
|
@@ -1817,7 +1815,7 @@ var ImageClient = class {
|
|
|
1817
1815
|
* @param options - Client configuration options
|
|
1818
1816
|
*/
|
|
1819
1817
|
constructor(options = {}) {
|
|
1820
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
1818
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
1821
1819
|
const privateKey = options.privateKey || envKey;
|
|
1822
1820
|
if (!privateKey) {
|
|
1823
1821
|
throw new Error(
|
|
@@ -1981,7 +1979,7 @@ var ImageClient = class {
|
|
|
1981
1979
|
this.account.address,
|
|
1982
1980
|
details.recipient,
|
|
1983
1981
|
details.amount,
|
|
1984
|
-
details.network ||
|
|
1982
|
+
details.network || SOLANA_NETWORK,
|
|
1985
1983
|
{
|
|
1986
1984
|
resourceUrl: validateResourceUrl(
|
|
1987
1985
|
details.resource?.url || `${this.apiUrl}/v1/images/generations`,
|
|
@@ -2130,7 +2128,7 @@ var MusicClient = class {
|
|
|
2130
2128
|
sessionTotalUsd = 0;
|
|
2131
2129
|
sessionCalls = 0;
|
|
2132
2130
|
constructor(options = {}) {
|
|
2133
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
2131
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
2134
2132
|
const privateKey = options.privateKey || envKey;
|
|
2135
2133
|
if (!privateKey) {
|
|
2136
2134
|
throw new Error(
|
|
@@ -2220,7 +2218,7 @@ var MusicClient = class {
|
|
|
2220
2218
|
this.account.address,
|
|
2221
2219
|
details.recipient,
|
|
2222
2220
|
details.amount,
|
|
2223
|
-
details.network ||
|
|
2221
|
+
details.network || SOLANA_NETWORK,
|
|
2224
2222
|
{
|
|
2225
2223
|
resourceUrl: details.resource?.url || `${this.apiUrl}/v1/audio/generations`,
|
|
2226
2224
|
resourceDescription: details.resource?.description || "BridgeNode Music Generation",
|
|
@@ -2286,7 +2284,7 @@ var SpeechClient = class {
|
|
|
2286
2284
|
sessionTotalUsd = 0;
|
|
2287
2285
|
sessionCalls = 0;
|
|
2288
2286
|
constructor(options = {}) {
|
|
2289
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
2287
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
2290
2288
|
const privateKey = options.privateKey || envKey;
|
|
2291
2289
|
if (!privateKey) {
|
|
2292
2290
|
throw new Error(
|
|
@@ -2418,7 +2416,7 @@ var SpeechClient = class {
|
|
|
2418
2416
|
this.account.address,
|
|
2419
2417
|
details.recipient,
|
|
2420
2418
|
details.amount,
|
|
2421
|
-
details.network ||
|
|
2419
|
+
details.network || SOLANA_NETWORK,
|
|
2422
2420
|
{
|
|
2423
2421
|
resourceUrl: details.resource?.url || `${this.apiUrl}${endpoint}`,
|
|
2424
2422
|
resourceDescription: details.resource?.description || "BridgeNode Voice",
|
|
@@ -2488,7 +2486,7 @@ var VideoClient = class {
|
|
|
2488
2486
|
sessionTotalUsd = 0;
|
|
2489
2487
|
sessionCalls = 0;
|
|
2490
2488
|
constructor(options = {}) {
|
|
2491
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
2489
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
2492
2490
|
const privateKey = options.privateKey || envKey;
|
|
2493
2491
|
if (!privateKey) {
|
|
2494
2492
|
throw new Error(
|
|
@@ -2726,7 +2724,7 @@ var VideoClient = class {
|
|
|
2726
2724
|
this.account.address,
|
|
2727
2725
|
details.recipient,
|
|
2728
2726
|
details.amount,
|
|
2729
|
-
details.network ||
|
|
2727
|
+
details.network || SOLANA_NETWORK,
|
|
2730
2728
|
{
|
|
2731
2729
|
resourceUrl: details.resource?.url || fallbackUrl,
|
|
2732
2730
|
resourceDescription: details.resource?.description || "BridgeNode Video Generation",
|
|
@@ -2798,7 +2796,7 @@ var VoiceClient = class {
|
|
|
2798
2796
|
sessionTotalUsd = 0;
|
|
2799
2797
|
sessionCalls = 0;
|
|
2800
2798
|
constructor(options = {}) {
|
|
2801
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
2799
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
2802
2800
|
const privateKey = options.privateKey || envKey;
|
|
2803
2801
|
if (!privateKey) {
|
|
2804
2802
|
throw new Error(
|
|
@@ -2933,7 +2931,7 @@ var VoiceClient = class {
|
|
|
2933
2931
|
this.account.address,
|
|
2934
2932
|
details.recipient,
|
|
2935
2933
|
details.amount,
|
|
2936
|
-
details.network ||
|
|
2934
|
+
details.network || SOLANA_NETWORK,
|
|
2937
2935
|
{
|
|
2938
2936
|
resourceUrl: details.resource?.url || `${this.apiUrl}/v1/voice/call`,
|
|
2939
2937
|
resourceDescription: details.resource?.description || "BridgeNode Voice Call",
|
|
@@ -3017,7 +3015,7 @@ var PhoneClient = class {
|
|
|
3017
3015
|
sessionTotalUsd = 0;
|
|
3018
3016
|
sessionCalls = 0;
|
|
3019
3017
|
constructor(options = {}) {
|
|
3020
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3018
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3021
3019
|
const privateKey = options.privateKey || envKey;
|
|
3022
3020
|
if (!privateKey) {
|
|
3023
3021
|
throw new Error(
|
|
@@ -3147,7 +3145,7 @@ var PhoneClient = class {
|
|
|
3147
3145
|
this.account.address,
|
|
3148
3146
|
details.recipient,
|
|
3149
3147
|
details.amount,
|
|
3150
|
-
details.network ||
|
|
3148
|
+
details.network || SOLANA_NETWORK,
|
|
3151
3149
|
{
|
|
3152
3150
|
resourceUrl: details.resource?.url || url,
|
|
3153
3151
|
resourceDescription: details.resource?.description || "BridgeNode Phone",
|
|
@@ -3217,7 +3215,7 @@ var PortraitClient = class {
|
|
|
3217
3215
|
sessionTotalUsd = 0;
|
|
3218
3216
|
sessionCalls = 0;
|
|
3219
3217
|
constructor(options = {}) {
|
|
3220
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3218
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3221
3219
|
const privateKey = options.privateKey || envKey;
|
|
3222
3220
|
if (!privateKey) {
|
|
3223
3221
|
throw new Error(
|
|
@@ -3299,7 +3297,7 @@ var PortraitClient = class {
|
|
|
3299
3297
|
this.account.address,
|
|
3300
3298
|
details.recipient,
|
|
3301
3299
|
details.amount,
|
|
3302
|
-
details.network ||
|
|
3300
|
+
details.network || SOLANA_NETWORK,
|
|
3303
3301
|
{
|
|
3304
3302
|
resourceUrl: details.resource?.url || url,
|
|
3305
3303
|
resourceDescription: details.resource?.description || "BridgeNode Virtual Portrait",
|
|
@@ -3368,7 +3366,7 @@ var SearchClient = class {
|
|
|
3368
3366
|
apiUrl;
|
|
3369
3367
|
timeout;
|
|
3370
3368
|
constructor(options = {}) {
|
|
3371
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3369
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3372
3370
|
const privateKey = options.privateKey || envKey;
|
|
3373
3371
|
if (!privateKey) {
|
|
3374
3372
|
throw new Error(
|
|
@@ -3446,7 +3444,7 @@ var SearchClient = class {
|
|
|
3446
3444
|
this.account.address,
|
|
3447
3445
|
details.recipient,
|
|
3448
3446
|
details.amount,
|
|
3449
|
-
details.network ||
|
|
3447
|
+
details.network || SOLANA_NETWORK,
|
|
3450
3448
|
{
|
|
3451
3449
|
resourceUrl: details.resource?.url || url,
|
|
3452
3450
|
resourceDescription: details.resource?.description || "BridgeNode Search",
|
|
@@ -3504,7 +3502,7 @@ var PriceClient = class {
|
|
|
3504
3502
|
apiUrl;
|
|
3505
3503
|
timeout;
|
|
3506
3504
|
constructor(options = {}) {
|
|
3507
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3505
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3508
3506
|
const privateKey = options.privateKey || envKey;
|
|
3509
3507
|
const requireWallet = options.requireWallet ?? true;
|
|
3510
3508
|
if (!privateKey && requireWallet) {
|
|
@@ -3636,7 +3634,7 @@ var PriceClient = class {
|
|
|
3636
3634
|
this.account.address,
|
|
3637
3635
|
details.recipient,
|
|
3638
3636
|
details.amount,
|
|
3639
|
-
details.network ||
|
|
3637
|
+
details.network || SOLANA_NETWORK,
|
|
3640
3638
|
{
|
|
3641
3639
|
resourceUrl: details.resource?.url || url,
|
|
3642
3640
|
resourceDescription: details.resource?.description || "BridgeNode Price Data",
|
|
@@ -3709,7 +3707,7 @@ var SurfClient = class {
|
|
|
3709
3707
|
apiUrl;
|
|
3710
3708
|
timeout;
|
|
3711
3709
|
constructor(options = {}) {
|
|
3712
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3710
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3713
3711
|
const privateKey = options.privateKey || envKey;
|
|
3714
3712
|
if (!privateKey) {
|
|
3715
3713
|
throw new Error(
|
|
@@ -3798,7 +3796,7 @@ var SurfClient = class {
|
|
|
3798
3796
|
this.account.address,
|
|
3799
3797
|
details.recipient,
|
|
3800
3798
|
details.amount,
|
|
3801
|
-
details.network ||
|
|
3799
|
+
details.network || SOLANA_NETWORK,
|
|
3802
3800
|
{
|
|
3803
3801
|
resourceUrl: details.resource?.url || url,
|
|
3804
3802
|
resourceDescription: details.resource?.description || "BridgeNode Surf",
|
|
@@ -3939,7 +3937,7 @@ var RpcClient = class {
|
|
|
3939
3937
|
sessionTotalUsd = 0;
|
|
3940
3938
|
sessionCalls = 0;
|
|
3941
3939
|
constructor(options = {}) {
|
|
3942
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
3940
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
3943
3941
|
const privateKey = options.privateKey || envKey;
|
|
3944
3942
|
if (!privateKey) {
|
|
3945
3943
|
throw new Error(
|
|
@@ -4056,7 +4054,7 @@ var RpcClient = class {
|
|
|
4056
4054
|
this.account.address,
|
|
4057
4055
|
details.recipient,
|
|
4058
4056
|
details.amount,
|
|
4059
|
-
details.network ||
|
|
4057
|
+
details.network || SOLANA_NETWORK,
|
|
4060
4058
|
{
|
|
4061
4059
|
resourceUrl: details.resource?.url || `${this.apiUrl}${endpoint}`,
|
|
4062
4060
|
resourceDescription: details.resource?.description || "BridgeNode Multi-chain RPC",
|
|
@@ -4121,7 +4119,7 @@ var BridgeNodeClient = class {
|
|
|
4121
4119
|
sessionTotalUsd = 0;
|
|
4122
4120
|
sessionCalls = 0;
|
|
4123
4121
|
constructor(options = {}) {
|
|
4124
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
4122
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
4125
4123
|
const privateKey = options.privateKey || envKey;
|
|
4126
4124
|
if (!privateKey) {
|
|
4127
4125
|
throw new Error(
|
|
@@ -4427,7 +4425,7 @@ var BridgeNodeClient = class {
|
|
|
4427
4425
|
this.account.address,
|
|
4428
4426
|
details.recipient,
|
|
4429
4427
|
details.amount,
|
|
4430
|
-
details.network ||
|
|
4428
|
+
details.network || SOLANA_NETWORK,
|
|
4431
4429
|
{
|
|
4432
4430
|
resourceUrl: details.resource?.url || url,
|
|
4433
4431
|
resourceDescription: details.resource?.description || opts.description,
|
|
@@ -4490,7 +4488,7 @@ import * as fs2 from "fs";
|
|
|
4490
4488
|
import * as path2 from "path";
|
|
4491
4489
|
import * as os2 from "os";
|
|
4492
4490
|
var USDC_BASE_CONTRACT = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
4493
|
-
var
|
|
4491
|
+
var BASE_CHAIN_ID = "8453";
|
|
4494
4492
|
var WALLET_DIR = path2.join(os2.homedir(), ".bridgenode");
|
|
4495
4493
|
var WALLET_FILE = path2.join(WALLET_DIR, ".session");
|
|
4496
4494
|
function createWallet() {
|
|
@@ -4626,7 +4624,7 @@ BRIDGENODE_WALLET_KEY=<private-key> for a single run without changing anything.
|
|
|
4626
4624
|
`;
|
|
4627
4625
|
}
|
|
4628
4626
|
function getOrCreateWallet() {
|
|
4629
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
4627
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
4630
4628
|
if (envKey) {
|
|
4631
4629
|
const account = privateKeyToAccount14(envKey);
|
|
4632
4630
|
return { address: account.address, privateKey: envKey, isNew: false };
|
|
@@ -4641,7 +4639,7 @@ function getOrCreateWallet() {
|
|
|
4641
4639
|
return { address, privateKey, isNew: true };
|
|
4642
4640
|
}
|
|
4643
4641
|
function getWalletAddress() {
|
|
4644
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.
|
|
4642
|
+
const envKey = typeof process !== "undefined" && process.env ? process.env.BRIDGENODE_WALLET_KEY || process.env.BRIDGENODE_WALLET_KEY : void 0;
|
|
4645
4643
|
if (envKey) {
|
|
4646
4644
|
return privateKeyToAccount14(envKey).address;
|
|
4647
4645
|
}
|
|
@@ -4653,13 +4651,13 @@ function getWalletAddress() {
|
|
|
4653
4651
|
}
|
|
4654
4652
|
function getEip681Uri(address, amountUsdc = 1) {
|
|
4655
4653
|
const amountWei = Math.floor(amountUsdc * 1e6);
|
|
4656
|
-
return `ethereum:${USDC_BASE_CONTRACT}@${
|
|
4654
|
+
return `ethereum:${USDC_BASE_CONTRACT}@${BASE_CHAIN_ID}/transfer?address=${address}&uint256=${amountWei}`;
|
|
4657
4655
|
}
|
|
4658
4656
|
function getPaymentLinks(address) {
|
|
4659
4657
|
return {
|
|
4660
4658
|
basescan: `https://basescan.org/address/${address}`,
|
|
4661
|
-
walletLink: `ethereum:${USDC_BASE_CONTRACT}@${
|
|
4662
|
-
ethereum: `ethereum:${address}@${
|
|
4659
|
+
walletLink: `ethereum:${USDC_BASE_CONTRACT}@${BASE_CHAIN_ID}/transfer?address=${address}`,
|
|
4660
|
+
ethereum: `ethereum:${address}@${BASE_CHAIN_ID}`,
|
|
4663
4661
|
bridgenode: `https://bridgenode.cc/fund?address=${address}`
|
|
4664
4662
|
};
|
|
4665
4663
|
}
|
|
@@ -4668,11 +4666,11 @@ function formatWalletCreatedMessage(address) {
|
|
|
4668
4666
|
return `
|
|
4669
4667
|
I'm your BridgeNode Agent! I can access GPT-4, Grok, image generation, and more.
|
|
4670
4668
|
|
|
4671
|
-
Please send $1-5 USDC
|
|
4669
|
+
Please send $1-5 Solana USDC to start:
|
|
4672
4670
|
|
|
4673
4671
|
${address}
|
|
4674
4672
|
|
|
4675
|
-
What is
|
|
4673
|
+
What is Solana? Solana is a high-performance's blockchain network.
|
|
4676
4674
|
You can buy USDC on Coinbase and send it directly to me.
|
|
4677
4675
|
|
|
4678
4676
|
What $1 USDC gets you:
|
|
@@ -4693,7 +4691,7 @@ Your private key never leaves your machine - only signatures are sent.
|
|
|
4693
4691
|
function formatNeedsFundingMessage(address) {
|
|
4694
4692
|
const links = getPaymentLinks(address);
|
|
4695
4693
|
return `
|
|
4696
|
-
I've run out of funds! Please send more USDC
|
|
4694
|
+
I've run out of funds! Please send more Solana USDC to continue helping you.
|
|
4697
4695
|
|
|
4698
4696
|
Send to my address:
|
|
4699
4697
|
${address}
|
|
@@ -4708,7 +4706,7 @@ Your private key never leaves your machine - only signatures are sent.
|
|
|
4708
4706
|
}
|
|
4709
4707
|
function formatFundingMessageCompact(address) {
|
|
4710
4708
|
const links = getPaymentLinks(address);
|
|
4711
|
-
return `I need a little top-up to keep helping you! Send USDC
|
|
4709
|
+
return `I need a little top-up to keep helping you! Send Solana USDC to: ${address}
|
|
4712
4710
|
Check my balance: ${links.basescan}`;
|
|
4713
4711
|
}
|
|
4714
4712
|
var WALLET_FILE_PATH = WALLET_FILE;
|
|
@@ -5266,7 +5264,7 @@ var SolanaLLMClient = class {
|
|
|
5266
5264
|
const details = extractPaymentDetails(paymentRequired, SOLANA_NETWORK);
|
|
5267
5265
|
if (!details.network?.startsWith("solana:")) {
|
|
5268
5266
|
throw new PaymentError(
|
|
5269
|
-
`Expected Solana payment network, got: ${details.network}. Use LLMClient for
|
|
5267
|
+
`Expected Solana payment network, got: ${details.network}. Use LLMClient for Solana payments.`
|
|
5270
5268
|
);
|
|
5271
5269
|
}
|
|
5272
5270
|
const feePayer = details.extra?.feePayer;
|
|
@@ -5358,7 +5356,7 @@ var SolanaLLMClient = class {
|
|
|
5358
5356
|
const details = extractPaymentDetails(paymentRequired, SOLANA_NETWORK);
|
|
5359
5357
|
if (!details.network?.startsWith("solana:")) {
|
|
5360
5358
|
throw new PaymentError(
|
|
5361
|
-
`Expected Solana payment network, got: ${details.network}. Use LLMClient for
|
|
5359
|
+
`Expected Solana payment network, got: ${details.network}. Use LLMClient for Solana payments.`
|
|
5362
5360
|
);
|
|
5363
5361
|
}
|
|
5364
5362
|
const feePayer = details.extra?.feePayer;
|
|
@@ -5450,7 +5448,7 @@ var SolanaLLMClient = class {
|
|
|
5450
5448
|
const details = extractPaymentDetails(paymentRequired, SOLANA_NETWORK);
|
|
5451
5449
|
if (!details.network?.startsWith("solana:")) {
|
|
5452
5450
|
throw new PaymentError(
|
|
5453
|
-
`Expected Solana payment network, got: ${details.network}. Use LLMClient for
|
|
5451
|
+
`Expected Solana payment network, got: ${details.network}. Use LLMClient for Solana payments.`
|
|
5454
5452
|
);
|
|
5455
5453
|
}
|
|
5456
5454
|
const feePayer = details.extra?.feePayer;
|
|
@@ -5716,7 +5714,7 @@ function setupAgentWallet(options) {
|
|
|
5716
5714
|
`
|
|
5717
5715
|
BridgeNode Agent Wallet Created!
|
|
5718
5716
|
Address: ${address}
|
|
5719
|
-
Send USDC on
|
|
5717
|
+
Send USDC on Solana to get started.
|
|
5720
5718
|
`
|
|
5721
5719
|
);
|
|
5722
5720
|
}
|
|
@@ -5960,7 +5958,7 @@ var AnthropicClient = class {
|
|
|
5960
5958
|
this._account.address,
|
|
5961
5959
|
details.recipient,
|
|
5962
5960
|
details.amount,
|
|
5963
|
-
details.network ||
|
|
5961
|
+
details.network || SOLANA_NETWORK,
|
|
5964
5962
|
{
|
|
5965
5963
|
resourceUrl: validateResourceUrl(
|
|
5966
5964
|
details.resource?.url || `${this._apiUrl}/v1/messages`,
|
|
@@ -6009,7 +6007,6 @@ var AnthropicClient = class {
|
|
|
6009
6007
|
export {
|
|
6010
6008
|
APIError,
|
|
6011
6009
|
AnthropicClient,
|
|
6012
|
-
BASE_CHAIN_ID,
|
|
6013
6010
|
BridgeNodeClient,
|
|
6014
6011
|
BridgeNodeError,
|
|
6015
6012
|
ImageClient,
|
|
@@ -6033,8 +6030,6 @@ export {
|
|
|
6033
6030
|
SolanaLLMClient,
|
|
6034
6031
|
SpeechClient,
|
|
6035
6032
|
SurfClient,
|
|
6036
|
-
USDC_BASE,
|
|
6037
|
-
USDC_BASE_CONTRACT,
|
|
6038
6033
|
USDC_SOLANA,
|
|
6039
6034
|
VideoClient,
|
|
6040
6035
|
VoiceClient,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridgenode/llm",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "BridgeNode SDK - Pay-per-request AI
|
|
5
|
+
"description": "BridgeNode SDK - Pay-per-request AI via x402 on Solana",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
@@ -84,4 +84,4 @@
|
|
|
84
84
|
"optional": true
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
}
|