@blockrun/llm 2.13.0 → 3.0.0
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 +1 -49
- package/dist/index.cjs +34 -528
- package/dist/index.d.cts +1 -347
- package/dist/index.d.ts +1 -347
- package/dist/index.js +33 -526
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1512,205 +1512,6 @@ var LLMClient = class _LLMClient {
|
|
|
1512
1512
|
}
|
|
1513
1513
|
throw lastError || new Error("All RPCs failed");
|
|
1514
1514
|
}
|
|
1515
|
-
// ============================================================
|
|
1516
|
-
// X/Twitter endpoints (powered by AttentionVC)
|
|
1517
|
-
// ============================================================
|
|
1518
|
-
/**
|
|
1519
|
-
* Look up X/Twitter user profiles by username.
|
|
1520
|
-
*
|
|
1521
|
-
* Powered by AttentionVC. $0.002 per user (min $0.02, max $0.20).
|
|
1522
|
-
*
|
|
1523
|
-
* @param usernames - Single username or array of usernames (without @)
|
|
1524
|
-
*/
|
|
1525
|
-
async xUserLookup(usernames) {
|
|
1526
|
-
const names = Array.isArray(usernames) ? usernames : [usernames];
|
|
1527
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/lookup", { usernames: names });
|
|
1528
|
-
return data;
|
|
1529
|
-
}
|
|
1530
|
-
/**
|
|
1531
|
-
* Get followers of an X/Twitter user.
|
|
1532
|
-
*
|
|
1533
|
-
* Powered by AttentionVC. $0.05 per page (~200 accounts).
|
|
1534
|
-
*
|
|
1535
|
-
* @param username - X/Twitter username (without @)
|
|
1536
|
-
* @param cursor - Pagination cursor from previous response
|
|
1537
|
-
*/
|
|
1538
|
-
async xFollowers(username, cursor) {
|
|
1539
|
-
const body = { username };
|
|
1540
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1541
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/followers", body);
|
|
1542
|
-
return data;
|
|
1543
|
-
}
|
|
1544
|
-
/**
|
|
1545
|
-
* Get accounts an X/Twitter user is following.
|
|
1546
|
-
*
|
|
1547
|
-
* Powered by AttentionVC. $0.05 per page (~200 accounts).
|
|
1548
|
-
*
|
|
1549
|
-
* @param username - X/Twitter username (without @)
|
|
1550
|
-
* @param cursor - Pagination cursor from previous response
|
|
1551
|
-
*/
|
|
1552
|
-
async xFollowings(username, cursor) {
|
|
1553
|
-
const body = { username };
|
|
1554
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1555
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/followings", body);
|
|
1556
|
-
return data;
|
|
1557
|
-
}
|
|
1558
|
-
/**
|
|
1559
|
-
* Get detailed profile info for a single X/Twitter user.
|
|
1560
|
-
*
|
|
1561
|
-
* Powered by AttentionVC. $0.002 per request.
|
|
1562
|
-
*
|
|
1563
|
-
* @param username - X/Twitter username (without @)
|
|
1564
|
-
*/
|
|
1565
|
-
async xUserInfo(username) {
|
|
1566
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/info", { username });
|
|
1567
|
-
return data;
|
|
1568
|
-
}
|
|
1569
|
-
/**
|
|
1570
|
-
* Get verified (blue-check) followers of an X/Twitter user.
|
|
1571
|
-
*
|
|
1572
|
-
* Powered by AttentionVC. $0.048 per page.
|
|
1573
|
-
*
|
|
1574
|
-
* @param userId - X/Twitter user ID (not username)
|
|
1575
|
-
* @param cursor - Pagination cursor from previous response
|
|
1576
|
-
*/
|
|
1577
|
-
async xVerifiedFollowers(userId, cursor) {
|
|
1578
|
-
const body = { userId };
|
|
1579
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1580
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/verified-followers", body);
|
|
1581
|
-
return data;
|
|
1582
|
-
}
|
|
1583
|
-
/**
|
|
1584
|
-
* Get tweets posted by an X/Twitter user.
|
|
1585
|
-
*
|
|
1586
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1587
|
-
*
|
|
1588
|
-
* @param username - X/Twitter username (without @)
|
|
1589
|
-
* @param includeReplies - Include reply tweets (default: false)
|
|
1590
|
-
* @param cursor - Pagination cursor from previous response
|
|
1591
|
-
*/
|
|
1592
|
-
async xUserTweets(username, includeReplies = false, cursor) {
|
|
1593
|
-
const body = { username, includeReplies };
|
|
1594
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1595
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/tweets", body);
|
|
1596
|
-
return data;
|
|
1597
|
-
}
|
|
1598
|
-
/**
|
|
1599
|
-
* Get tweets that mention an X/Twitter user.
|
|
1600
|
-
*
|
|
1601
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1602
|
-
*
|
|
1603
|
-
* @param username - X/Twitter username (without @)
|
|
1604
|
-
* @param sinceTime - Start time filter (ISO8601 or Unix timestamp)
|
|
1605
|
-
* @param untilTime - End time filter (ISO8601 or Unix timestamp)
|
|
1606
|
-
* @param cursor - Pagination cursor from previous response
|
|
1607
|
-
*/
|
|
1608
|
-
async xUserMentions(username, sinceTime, untilTime, cursor) {
|
|
1609
|
-
const body = { username };
|
|
1610
|
-
if (sinceTime !== void 0) body.sinceTime = sinceTime;
|
|
1611
|
-
if (untilTime !== void 0) body.untilTime = untilTime;
|
|
1612
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1613
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/mentions", body);
|
|
1614
|
-
return data;
|
|
1615
|
-
}
|
|
1616
|
-
/**
|
|
1617
|
-
* Fetch full tweet data for up to 200 tweet IDs.
|
|
1618
|
-
*
|
|
1619
|
-
* Powered by AttentionVC. $0.16 per batch.
|
|
1620
|
-
*
|
|
1621
|
-
* @param tweetIds - Single tweet ID or array of tweet IDs (max 200)
|
|
1622
|
-
*/
|
|
1623
|
-
async xTweetLookup(tweetIds) {
|
|
1624
|
-
const ids = Array.isArray(tweetIds) ? tweetIds : [tweetIds];
|
|
1625
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/lookup", { tweet_ids: ids });
|
|
1626
|
-
return data;
|
|
1627
|
-
}
|
|
1628
|
-
/**
|
|
1629
|
-
* Get replies to a specific tweet.
|
|
1630
|
-
*
|
|
1631
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1632
|
-
*
|
|
1633
|
-
* @param tweetId - The tweet ID to get replies for
|
|
1634
|
-
* @param queryType - Sort order: 'Latest' or 'Default'
|
|
1635
|
-
* @param cursor - Pagination cursor from previous response
|
|
1636
|
-
*/
|
|
1637
|
-
async xTweetReplies(tweetId, queryType = "Latest", cursor) {
|
|
1638
|
-
const body = { tweetId, queryType };
|
|
1639
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1640
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/replies", body);
|
|
1641
|
-
return data;
|
|
1642
|
-
}
|
|
1643
|
-
/**
|
|
1644
|
-
* Get the full thread context for a tweet.
|
|
1645
|
-
*
|
|
1646
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1647
|
-
*
|
|
1648
|
-
* @param tweetId - The tweet ID to get thread for
|
|
1649
|
-
* @param cursor - Pagination cursor from previous response
|
|
1650
|
-
*/
|
|
1651
|
-
async xTweetThread(tweetId, cursor) {
|
|
1652
|
-
const body = { tweetId };
|
|
1653
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1654
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/thread", body);
|
|
1655
|
-
return data;
|
|
1656
|
-
}
|
|
1657
|
-
/**
|
|
1658
|
-
* Search X/Twitter with advanced query operators.
|
|
1659
|
-
*
|
|
1660
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1661
|
-
*
|
|
1662
|
-
* @param query - Search query (supports Twitter search operators)
|
|
1663
|
-
* @param queryType - Sort order: 'Latest', 'Top', or 'Default'
|
|
1664
|
-
* @param cursor - Pagination cursor from previous response
|
|
1665
|
-
*/
|
|
1666
|
-
async xSearch(query, queryType = "Latest", cursor) {
|
|
1667
|
-
const body = { query, queryType };
|
|
1668
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1669
|
-
const data = await this.requestWithPaymentRaw("/v1/x/search", body);
|
|
1670
|
-
return data;
|
|
1671
|
-
}
|
|
1672
|
-
/**
|
|
1673
|
-
* Get current trending topics on X/Twitter.
|
|
1674
|
-
*
|
|
1675
|
-
* Powered by AttentionVC. $0.002 per request.
|
|
1676
|
-
*/
|
|
1677
|
-
async xTrending() {
|
|
1678
|
-
const data = await this.requestWithPaymentRaw("/v1/x/trending", {});
|
|
1679
|
-
return data;
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* Get rising/viral articles from X/Twitter.
|
|
1683
|
-
*
|
|
1684
|
-
* Powered by AttentionVC intelligence layer. $0.05 per request.
|
|
1685
|
-
*/
|
|
1686
|
-
async xArticlesRising() {
|
|
1687
|
-
const data = await this.requestWithPaymentRaw("/v1/x/articles/rising", {});
|
|
1688
|
-
return data;
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* Get author analytics and intelligence metrics for an X/Twitter user.
|
|
1692
|
-
*
|
|
1693
|
-
* Powered by AttentionVC intelligence layer. $0.02 per request.
|
|
1694
|
-
*
|
|
1695
|
-
* @param handle - X/Twitter handle (without @)
|
|
1696
|
-
*/
|
|
1697
|
-
async xAuthorAnalytics(handle) {
|
|
1698
|
-
const data = await this.requestWithPaymentRaw("/v1/x/authors", { handle });
|
|
1699
|
-
return data;
|
|
1700
|
-
}
|
|
1701
|
-
/**
|
|
1702
|
-
* Compare two X/Twitter authors side-by-side with intelligence metrics.
|
|
1703
|
-
*
|
|
1704
|
-
* Powered by AttentionVC intelligence layer. $0.05 per request.
|
|
1705
|
-
*
|
|
1706
|
-
* @param handle1 - First X/Twitter handle (without @)
|
|
1707
|
-
* @param handle2 - Second X/Twitter handle (without @)
|
|
1708
|
-
*/
|
|
1709
|
-
async xCompareAuthors(handle1, handle2) {
|
|
1710
|
-
const data = await this.requestWithPaymentRaw("/v1/x/compare", { handle1, handle2 });
|
|
1711
|
-
return data;
|
|
1712
|
-
}
|
|
1713
|
-
// ── Prediction Markets (Powered by Predexon) ────────────────────────────
|
|
1714
1515
|
/**
|
|
1715
1516
|
* Query Predexon prediction market data (GET endpoints).
|
|
1716
1517
|
*
|
|
@@ -3436,217 +3237,10 @@ var SearchClient = class {
|
|
|
3436
3237
|
}
|
|
3437
3238
|
};
|
|
3438
3239
|
|
|
3439
|
-
// src/
|
|
3240
|
+
// src/price.ts
|
|
3440
3241
|
import { privateKeyToAccount as privateKeyToAccount10 } from "viem/accounts";
|
|
3441
3242
|
var DEFAULT_API_URL10 = "https://blockrun.ai/api";
|
|
3442
|
-
var DEFAULT_TIMEOUT10 =
|
|
3443
|
-
var XClient = class _XClient {
|
|
3444
|
-
account;
|
|
3445
|
-
privateKey;
|
|
3446
|
-
apiUrl;
|
|
3447
|
-
timeout;
|
|
3448
|
-
static deprecationWarned = false;
|
|
3449
|
-
constructor(options = {}) {
|
|
3450
|
-
if (!_XClient.deprecationWarned) {
|
|
3451
|
-
console.warn(
|
|
3452
|
-
"[@blockrun/llm] XClient: BlockRun's /v1/x/* (AttentionVC) integration was removed 2026-04-30. All calls will return HTTP 404 until a replacement X data upstream is reintroduced."
|
|
3453
|
-
);
|
|
3454
|
-
_XClient.deprecationWarned = true;
|
|
3455
|
-
}
|
|
3456
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
|
|
3457
|
-
const privateKey = options.privateKey || envKey;
|
|
3458
|
-
if (!privateKey) {
|
|
3459
|
-
throw new Error(
|
|
3460
|
-
"Private key required. Pass privateKey in options or set BLOCKRUN_WALLET_KEY environment variable."
|
|
3461
|
-
);
|
|
3462
|
-
}
|
|
3463
|
-
validatePrivateKey(privateKey);
|
|
3464
|
-
this.privateKey = privateKey;
|
|
3465
|
-
this.account = privateKeyToAccount10(privateKey);
|
|
3466
|
-
const apiUrl = options.apiUrl || DEFAULT_API_URL10;
|
|
3467
|
-
validateApiUrl(apiUrl);
|
|
3468
|
-
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
3469
|
-
this.timeout = options.timeout || DEFAULT_TIMEOUT10;
|
|
3470
|
-
}
|
|
3471
|
-
// ───────── User endpoints ─────────
|
|
3472
|
-
userLookup(usernames) {
|
|
3473
|
-
return this.post("/v1/x/users/lookup", { usernames });
|
|
3474
|
-
}
|
|
3475
|
-
userInfo(username) {
|
|
3476
|
-
return this.post("/v1/x/users/info", { username });
|
|
3477
|
-
}
|
|
3478
|
-
followers(username, cursor) {
|
|
3479
|
-
const body = { username };
|
|
3480
|
-
if (cursor) body.cursor = cursor;
|
|
3481
|
-
return this.post("/v1/x/users/followers", body);
|
|
3482
|
-
}
|
|
3483
|
-
/** `/v1/x/users/following` (singular path variant). */
|
|
3484
|
-
following(username, cursor) {
|
|
3485
|
-
const body = { username };
|
|
3486
|
-
if (cursor) body.cursor = cursor;
|
|
3487
|
-
return this.post("/v1/x/users/following", body);
|
|
3488
|
-
}
|
|
3489
|
-
/** `/v1/x/users/followings` (plural path variant). */
|
|
3490
|
-
followings(username, cursor) {
|
|
3491
|
-
const body = { username };
|
|
3492
|
-
if (cursor) body.cursor = cursor;
|
|
3493
|
-
return this.post("/v1/x/users/followings", body);
|
|
3494
|
-
}
|
|
3495
|
-
verifiedFollowers(userId, cursor) {
|
|
3496
|
-
const body = { userId };
|
|
3497
|
-
if (cursor) body.cursor = cursor;
|
|
3498
|
-
return this.post(
|
|
3499
|
-
"/v1/x/users/verified-followers",
|
|
3500
|
-
body
|
|
3501
|
-
);
|
|
3502
|
-
}
|
|
3503
|
-
userTweets(options) {
|
|
3504
|
-
if (!options.username && !options.userId) {
|
|
3505
|
-
throw new Error("Either username or userId is required");
|
|
3506
|
-
}
|
|
3507
|
-
const body = {};
|
|
3508
|
-
if (options.username) body.username = options.username;
|
|
3509
|
-
if (options.userId) body.userId = options.userId;
|
|
3510
|
-
if (options.cursor) body.cursor = options.cursor;
|
|
3511
|
-
if (options.includeReplies !== void 0) body.includeReplies = options.includeReplies;
|
|
3512
|
-
return this.post("/v1/x/users/tweets", body);
|
|
3513
|
-
}
|
|
3514
|
-
mentions(username, options) {
|
|
3515
|
-
const body = { username };
|
|
3516
|
-
if (options?.sinceTime) body.sinceTime = options.sinceTime;
|
|
3517
|
-
if (options?.untilTime) body.untilTime = options.untilTime;
|
|
3518
|
-
if (options?.cursor) body.cursor = options.cursor;
|
|
3519
|
-
return this.post("/v1/x/users/mentions", body);
|
|
3520
|
-
}
|
|
3521
|
-
// ───────── Tweet endpoints ─────────
|
|
3522
|
-
tweetLookup(tweetIds) {
|
|
3523
|
-
return this.post("/v1/x/tweets/lookup", {
|
|
3524
|
-
tweet_ids: tweetIds
|
|
3525
|
-
});
|
|
3526
|
-
}
|
|
3527
|
-
tweetReplies(tweetId, options) {
|
|
3528
|
-
const body = { tweetId };
|
|
3529
|
-
if (options?.cursor) body.cursor = options.cursor;
|
|
3530
|
-
if (options?.queryType) body.queryType = options.queryType;
|
|
3531
|
-
return this.post("/v1/x/tweets/replies", body);
|
|
3532
|
-
}
|
|
3533
|
-
tweetThread(tweetId, cursor) {
|
|
3534
|
-
const body = { tweetId };
|
|
3535
|
-
if (cursor) body.cursor = cursor;
|
|
3536
|
-
return this.post("/v1/x/tweets/thread", body);
|
|
3537
|
-
}
|
|
3538
|
-
// ───────── Search & discovery ─────────
|
|
3539
|
-
search(query, options) {
|
|
3540
|
-
const body = { query };
|
|
3541
|
-
if (options?.queryType) body.queryType = options.queryType;
|
|
3542
|
-
if (options?.cursor) body.cursor = options.cursor;
|
|
3543
|
-
return this.post("/v1/x/search", body);
|
|
3544
|
-
}
|
|
3545
|
-
trending() {
|
|
3546
|
-
return this.post("/v1/x/trending", {});
|
|
3547
|
-
}
|
|
3548
|
-
articlesRising() {
|
|
3549
|
-
return this.post("/v1/x/articles/rising", {});
|
|
3550
|
-
}
|
|
3551
|
-
// ───────── Internals ─────────
|
|
3552
|
-
async post(endpoint, body) {
|
|
3553
|
-
const url = `${this.apiUrl}${endpoint}`;
|
|
3554
|
-
const response = await this.fetchWithTimeout(url, {
|
|
3555
|
-
method: "POST",
|
|
3556
|
-
headers: { "Content-Type": "application/json" },
|
|
3557
|
-
body: JSON.stringify(body)
|
|
3558
|
-
});
|
|
3559
|
-
if (response.status === 402) {
|
|
3560
|
-
return this.payAndRetry(url, body, response);
|
|
3561
|
-
}
|
|
3562
|
-
if (!response.ok) {
|
|
3563
|
-
let errorBody;
|
|
3564
|
-
try {
|
|
3565
|
-
errorBody = await response.json();
|
|
3566
|
-
} catch {
|
|
3567
|
-
errorBody = { error: "Request failed" };
|
|
3568
|
-
}
|
|
3569
|
-
throw new APIError(
|
|
3570
|
-
`API error: ${response.status}`,
|
|
3571
|
-
response.status,
|
|
3572
|
-
sanitizeErrorResponse(errorBody)
|
|
3573
|
-
);
|
|
3574
|
-
}
|
|
3575
|
-
return response.json();
|
|
3576
|
-
}
|
|
3577
|
-
async payAndRetry(url, body, response) {
|
|
3578
|
-
let paymentHeader = response.headers.get("payment-required");
|
|
3579
|
-
if (!paymentHeader) {
|
|
3580
|
-
try {
|
|
3581
|
-
const respBody = await response.json();
|
|
3582
|
-
if (respBody.x402 || respBody.accepts) {
|
|
3583
|
-
paymentHeader = btoa(JSON.stringify(respBody));
|
|
3584
|
-
}
|
|
3585
|
-
} catch {
|
|
3586
|
-
}
|
|
3587
|
-
}
|
|
3588
|
-
if (!paymentHeader) {
|
|
3589
|
-
throw new PaymentError("402 response but no payment requirements found");
|
|
3590
|
-
}
|
|
3591
|
-
const paymentRequired = parsePaymentRequired(paymentHeader);
|
|
3592
|
-
const details = extractPaymentDetails(paymentRequired);
|
|
3593
|
-
const paymentPayload = await createPaymentPayload(
|
|
3594
|
-
this.privateKey,
|
|
3595
|
-
this.account.address,
|
|
3596
|
-
details.recipient,
|
|
3597
|
-
details.amount,
|
|
3598
|
-
details.network || "eip155:8453",
|
|
3599
|
-
{
|
|
3600
|
-
resourceUrl: details.resource?.url || url,
|
|
3601
|
-
resourceDescription: details.resource?.description || "BlockRun X API",
|
|
3602
|
-
maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
|
|
3603
|
-
extra: details.extra
|
|
3604
|
-
}
|
|
3605
|
-
);
|
|
3606
|
-
const retry = await this.fetchWithTimeout(url, {
|
|
3607
|
-
method: "POST",
|
|
3608
|
-
headers: {
|
|
3609
|
-
"Content-Type": "application/json",
|
|
3610
|
-
"PAYMENT-SIGNATURE": paymentPayload
|
|
3611
|
-
},
|
|
3612
|
-
body: JSON.stringify(body)
|
|
3613
|
-
});
|
|
3614
|
-
if (retry.status === 402) {
|
|
3615
|
-
throw new PaymentError("Payment was rejected. Check your wallet balance.");
|
|
3616
|
-
}
|
|
3617
|
-
if (!retry.ok) {
|
|
3618
|
-
let errorBody;
|
|
3619
|
-
try {
|
|
3620
|
-
errorBody = await retry.json();
|
|
3621
|
-
} catch {
|
|
3622
|
-
errorBody = { error: "Request failed" };
|
|
3623
|
-
}
|
|
3624
|
-
throw new APIError(
|
|
3625
|
-
`API error after payment: ${retry.status}`,
|
|
3626
|
-
retry.status,
|
|
3627
|
-
sanitizeErrorResponse(errorBody)
|
|
3628
|
-
);
|
|
3629
|
-
}
|
|
3630
|
-
return retry.json();
|
|
3631
|
-
}
|
|
3632
|
-
async fetchWithTimeout(url, init) {
|
|
3633
|
-
const controller = new AbortController();
|
|
3634
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
3635
|
-
try {
|
|
3636
|
-
return await fetch(url, { ...init, signal: controller.signal });
|
|
3637
|
-
} finally {
|
|
3638
|
-
clearTimeout(timeoutId);
|
|
3639
|
-
}
|
|
3640
|
-
}
|
|
3641
|
-
getWalletAddress() {
|
|
3642
|
-
return this.account.address;
|
|
3643
|
-
}
|
|
3644
|
-
};
|
|
3645
|
-
|
|
3646
|
-
// src/price.ts
|
|
3647
|
-
import { privateKeyToAccount as privateKeyToAccount11 } from "viem/accounts";
|
|
3648
|
-
var DEFAULT_API_URL11 = "https://blockrun.ai/api";
|
|
3649
|
-
var DEFAULT_TIMEOUT11 = 3e4;
|
|
3243
|
+
var DEFAULT_TIMEOUT10 = 3e4;
|
|
3650
3244
|
var PriceClient = class {
|
|
3651
3245
|
account = null;
|
|
3652
3246
|
privateKey = null;
|
|
@@ -3664,12 +3258,12 @@ var PriceClient = class {
|
|
|
3664
3258
|
if (privateKey) {
|
|
3665
3259
|
validatePrivateKey(privateKey);
|
|
3666
3260
|
this.privateKey = privateKey;
|
|
3667
|
-
this.account =
|
|
3261
|
+
this.account = privateKeyToAccount10(privateKey);
|
|
3668
3262
|
}
|
|
3669
|
-
const apiUrl = options.apiUrl ||
|
|
3263
|
+
const apiUrl = options.apiUrl || DEFAULT_API_URL10;
|
|
3670
3264
|
validateApiUrl(apiUrl);
|
|
3671
3265
|
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
3672
|
-
this.timeout = options.timeout ||
|
|
3266
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT10;
|
|
3673
3267
|
}
|
|
3674
3268
|
async price(category, symbol, options) {
|
|
3675
3269
|
if (!symbol) throw new Error("symbol is required");
|
|
@@ -3848,9 +3442,9 @@ function buildUrl(base, query) {
|
|
|
3848
3442
|
}
|
|
3849
3443
|
|
|
3850
3444
|
// src/surf.ts
|
|
3851
|
-
import { privateKeyToAccount as
|
|
3852
|
-
var
|
|
3853
|
-
var
|
|
3445
|
+
import { privateKeyToAccount as privateKeyToAccount11 } from "viem/accounts";
|
|
3446
|
+
var DEFAULT_API_URL11 = "https://blockrun.ai/api";
|
|
3447
|
+
var DEFAULT_TIMEOUT11 = 6e4;
|
|
3854
3448
|
var SURF_PREFIX = "/v1/surf";
|
|
3855
3449
|
var SurfClient = class {
|
|
3856
3450
|
account;
|
|
@@ -3867,11 +3461,11 @@ var SurfClient = class {
|
|
|
3867
3461
|
}
|
|
3868
3462
|
validatePrivateKey(privateKey);
|
|
3869
3463
|
this.privateKey = privateKey;
|
|
3870
|
-
this.account =
|
|
3871
|
-
const apiUrl = options.apiUrl ||
|
|
3464
|
+
this.account = privateKeyToAccount11(privateKey);
|
|
3465
|
+
const apiUrl = options.apiUrl || DEFAULT_API_URL11;
|
|
3872
3466
|
validateApiUrl(apiUrl);
|
|
3873
3467
|
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
3874
|
-
this.timeout = options.timeout ||
|
|
3468
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT11;
|
|
3875
3469
|
}
|
|
3876
3470
|
/**
|
|
3877
3471
|
* GET a Surf endpoint. `path` is everything after `/v1/surf` (a leading
|
|
@@ -4003,9 +3597,9 @@ var SurfClient = class {
|
|
|
4003
3597
|
};
|
|
4004
3598
|
|
|
4005
3599
|
// src/rpc.ts
|
|
4006
|
-
import { privateKeyToAccount as
|
|
4007
|
-
var
|
|
4008
|
-
var
|
|
3600
|
+
import { privateKeyToAccount as privateKeyToAccount12 } from "viem/accounts";
|
|
3601
|
+
var DEFAULT_API_URL12 = "https://blockrun.ai/api";
|
|
3602
|
+
var DEFAULT_TIMEOUT12 = 6e4;
|
|
4009
3603
|
var RPC_PRICE_USD = 2e-3;
|
|
4010
3604
|
var SUPPORTED_NETWORKS = [
|
|
4011
3605
|
// EVM
|
|
@@ -4097,11 +3691,11 @@ var RpcClient = class {
|
|
|
4097
3691
|
}
|
|
4098
3692
|
validatePrivateKey(privateKey);
|
|
4099
3693
|
this.privateKey = privateKey;
|
|
4100
|
-
this.account =
|
|
4101
|
-
const apiUrl = options.apiUrl ||
|
|
3694
|
+
this.account = privateKeyToAccount12(privateKey);
|
|
3695
|
+
const apiUrl = options.apiUrl || DEFAULT_API_URL12;
|
|
4102
3696
|
validateApiUrl(apiUrl);
|
|
4103
3697
|
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
4104
|
-
this.timeout = options.timeout ||
|
|
3698
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT12;
|
|
4105
3699
|
}
|
|
4106
3700
|
/**
|
|
4107
3701
|
* Make a single JSON-RPC 2.0 call. Flat $0.002.
|
|
@@ -4256,9 +3850,9 @@ var RpcClient = class {
|
|
|
4256
3850
|
};
|
|
4257
3851
|
|
|
4258
3852
|
// src/blockrun.ts
|
|
4259
|
-
import { privateKeyToAccount as
|
|
4260
|
-
var
|
|
4261
|
-
var
|
|
3853
|
+
import { privateKeyToAccount as privateKeyToAccount13 } from "viem/accounts";
|
|
3854
|
+
var DEFAULT_API_URL13 = "https://blockrun.ai/api";
|
|
3855
|
+
var DEFAULT_TIMEOUT13 = 6e4;
|
|
4262
3856
|
var DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
4263
3857
|
var DEFAULT_POLL_BUDGET_MS = 3e5;
|
|
4264
3858
|
var MAX_SIGNED_AUTH_SECONDS = 600;
|
|
@@ -4279,11 +3873,11 @@ var BlockrunClient = class {
|
|
|
4279
3873
|
}
|
|
4280
3874
|
validatePrivateKey(privateKey);
|
|
4281
3875
|
this.privateKey = privateKey;
|
|
4282
|
-
this.account =
|
|
4283
|
-
const apiUrl = options.apiUrl ||
|
|
3876
|
+
this.account = privateKeyToAccount13(privateKey);
|
|
3877
|
+
const apiUrl = options.apiUrl || DEFAULT_API_URL13;
|
|
4284
3878
|
validateApiUrl(apiUrl);
|
|
4285
3879
|
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
4286
|
-
this.timeout = options.timeout ||
|
|
3880
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT13;
|
|
4287
3881
|
}
|
|
4288
3882
|
/**
|
|
4289
3883
|
* GET a BlockRun endpoint. `path` is everything after `/api` (a leading
|
|
@@ -4634,7 +4228,7 @@ function sleep(ms) {
|
|
|
4634
4228
|
}
|
|
4635
4229
|
|
|
4636
4230
|
// src/wallet.ts
|
|
4637
|
-
import { privateKeyToAccount as
|
|
4231
|
+
import { privateKeyToAccount as privateKeyToAccount14, generatePrivateKey } from "viem/accounts";
|
|
4638
4232
|
import * as fs2 from "fs";
|
|
4639
4233
|
import * as path2 from "path";
|
|
4640
4234
|
import * as os2 from "os";
|
|
@@ -4644,7 +4238,7 @@ var WALLET_DIR = path2.join(os2.homedir(), ".blockrun");
|
|
|
4644
4238
|
var WALLET_FILE = path2.join(WALLET_DIR, ".session");
|
|
4645
4239
|
function createWallet() {
|
|
4646
4240
|
const privateKey = generatePrivateKey();
|
|
4647
|
-
const account =
|
|
4241
|
+
const account = privateKeyToAccount14(privateKey);
|
|
4648
4242
|
return {
|
|
4649
4243
|
address: account.address,
|
|
4650
4244
|
privateKey
|
|
@@ -4700,12 +4294,12 @@ function loadWallet() {
|
|
|
4700
4294
|
function getOrCreateWallet() {
|
|
4701
4295
|
const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
|
|
4702
4296
|
if (envKey) {
|
|
4703
|
-
const account =
|
|
4297
|
+
const account = privateKeyToAccount14(envKey);
|
|
4704
4298
|
return { address: account.address, privateKey: envKey, isNew: false };
|
|
4705
4299
|
}
|
|
4706
4300
|
const fileKey = loadWallet();
|
|
4707
4301
|
if (fileKey) {
|
|
4708
|
-
const account =
|
|
4302
|
+
const account = privateKeyToAccount14(fileKey);
|
|
4709
4303
|
return { address: account.address, privateKey: fileKey, isNew: false };
|
|
4710
4304
|
}
|
|
4711
4305
|
const { address, privateKey } = createWallet();
|
|
@@ -4715,11 +4309,11 @@ function getOrCreateWallet() {
|
|
|
4715
4309
|
function getWalletAddress() {
|
|
4716
4310
|
const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
|
|
4717
4311
|
if (envKey) {
|
|
4718
|
-
return
|
|
4312
|
+
return privateKeyToAccount14(envKey).address;
|
|
4719
4313
|
}
|
|
4720
4314
|
const fileKey = loadWallet();
|
|
4721
4315
|
if (fileKey) {
|
|
4722
|
-
return
|
|
4316
|
+
return privateKeyToAccount14(fileKey).address;
|
|
4723
4317
|
}
|
|
4724
4318
|
return null;
|
|
4725
4319
|
}
|
|
@@ -4899,7 +4493,7 @@ async function getOrCreateSolanaWallet() {
|
|
|
4899
4493
|
// src/solana-client.ts
|
|
4900
4494
|
var SOLANA_API_URL = "https://sol.blockrun.ai/api";
|
|
4901
4495
|
var DEFAULT_MAX_TOKENS2 = 1024;
|
|
4902
|
-
var
|
|
4496
|
+
var DEFAULT_TIMEOUT14 = 6e4;
|
|
4903
4497
|
var SDK_VERSION2 = "0.3.0";
|
|
4904
4498
|
var USER_AGENT2 = `blockrun-ts/${SDK_VERSION2}`;
|
|
4905
4499
|
var DEFAULT_SOLANA_RPC_URL = "https://sol.blockrun.ai/api/v1/solana/rpc";
|
|
@@ -4949,7 +4543,7 @@ var SolanaLLMClient = class {
|
|
|
4949
4543
|
const rpc = resolveRpcConfig(options.rpcUrl, options.rpcHeaders);
|
|
4950
4544
|
this.rpcUrl = rpc.url;
|
|
4951
4545
|
this.rpcHeaders = rpc.headers;
|
|
4952
|
-
this.timeout = options.timeout ||
|
|
4546
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT14;
|
|
4953
4547
|
}
|
|
4954
4548
|
/** Get Solana wallet address (public key in base58). */
|
|
4955
4549
|
async getWalletAddress() {
|
|
@@ -5049,89 +4643,6 @@ var SolanaLLMClient = class {
|
|
|
5049
4643
|
const data = await this.requestWithPaymentRaw("/v1/search", body);
|
|
5050
4644
|
return data;
|
|
5051
4645
|
}
|
|
5052
|
-
// ============================================================
|
|
5053
|
-
// X/Twitter endpoints (powered by AttentionVC)
|
|
5054
|
-
// ============================================================
|
|
5055
|
-
async xUserLookup(usernames) {
|
|
5056
|
-
const names = Array.isArray(usernames) ? usernames : [usernames];
|
|
5057
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/lookup", { usernames: names });
|
|
5058
|
-
return data;
|
|
5059
|
-
}
|
|
5060
|
-
async xFollowers(username, cursor) {
|
|
5061
|
-
const body = { username };
|
|
5062
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5063
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/followers", body);
|
|
5064
|
-
return data;
|
|
5065
|
-
}
|
|
5066
|
-
async xFollowings(username, cursor) {
|
|
5067
|
-
const body = { username };
|
|
5068
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5069
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/followings", body);
|
|
5070
|
-
return data;
|
|
5071
|
-
}
|
|
5072
|
-
async xUserInfo(username) {
|
|
5073
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/info", { username });
|
|
5074
|
-
return data;
|
|
5075
|
-
}
|
|
5076
|
-
async xVerifiedFollowers(userId, cursor) {
|
|
5077
|
-
const body = { userId };
|
|
5078
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5079
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/verified-followers", body);
|
|
5080
|
-
return data;
|
|
5081
|
-
}
|
|
5082
|
-
async xUserTweets(username, includeReplies = false, cursor) {
|
|
5083
|
-
const body = { username, includeReplies };
|
|
5084
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5085
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/tweets", body);
|
|
5086
|
-
return data;
|
|
5087
|
-
}
|
|
5088
|
-
async xUserMentions(username, sinceTime, untilTime, cursor) {
|
|
5089
|
-
const body = { username };
|
|
5090
|
-
if (sinceTime !== void 0) body.sinceTime = sinceTime;
|
|
5091
|
-
if (untilTime !== void 0) body.untilTime = untilTime;
|
|
5092
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5093
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/mentions", body);
|
|
5094
|
-
return data;
|
|
5095
|
-
}
|
|
5096
|
-
async xTweetLookup(tweetIds) {
|
|
5097
|
-
const ids = Array.isArray(tweetIds) ? tweetIds : [tweetIds];
|
|
5098
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/lookup", { tweet_ids: ids });
|
|
5099
|
-
return data;
|
|
5100
|
-
}
|
|
5101
|
-
async xTweetReplies(tweetId, queryType = "Latest", cursor) {
|
|
5102
|
-
const body = { tweetId, queryType };
|
|
5103
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5104
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/replies", body);
|
|
5105
|
-
return data;
|
|
5106
|
-
}
|
|
5107
|
-
async xTweetThread(tweetId, cursor) {
|
|
5108
|
-
const body = { tweetId };
|
|
5109
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5110
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/thread", body);
|
|
5111
|
-
return data;
|
|
5112
|
-
}
|
|
5113
|
-
async xSearch(query, queryType = "Latest", cursor) {
|
|
5114
|
-
const body = { query, queryType };
|
|
5115
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5116
|
-
const data = await this.requestWithPaymentRaw("/v1/x/search", body);
|
|
5117
|
-
return data;
|
|
5118
|
-
}
|
|
5119
|
-
async xTrending() {
|
|
5120
|
-
const data = await this.requestWithPaymentRaw("/v1/x/trending", {});
|
|
5121
|
-
return data;
|
|
5122
|
-
}
|
|
5123
|
-
async xArticlesRising() {
|
|
5124
|
-
const data = await this.requestWithPaymentRaw("/v1/x/articles/rising", {});
|
|
5125
|
-
return data;
|
|
5126
|
-
}
|
|
5127
|
-
async xAuthorAnalytics(handle) {
|
|
5128
|
-
const data = await this.requestWithPaymentRaw("/v1/x/authors", { handle });
|
|
5129
|
-
return data;
|
|
5130
|
-
}
|
|
5131
|
-
async xCompareAuthors(handle1, handle2) {
|
|
5132
|
-
const data = await this.requestWithPaymentRaw("/v1/x/compare", { handle1, handle2 });
|
|
5133
|
-
return data;
|
|
5134
|
-
}
|
|
5135
4646
|
// ── Prediction Markets (Powered by Predexon) ────────────────────────────
|
|
5136
4647
|
async pm(path5, params) {
|
|
5137
4648
|
return this.getWithPaymentRaw(`/v1/pm/${path5}`, params);
|
|
@@ -5495,7 +5006,6 @@ var CACHE_DIR = path4.join(os4.homedir(), ".blockrun", "cache");
|
|
|
5495
5006
|
var DATA_DIR = path4.join(os4.homedir(), ".blockrun", "data");
|
|
5496
5007
|
var COST_LOG_FILE2 = path4.join(os4.homedir(), ".blockrun", "cost_log.jsonl");
|
|
5497
5008
|
var DEFAULT_TTL = {
|
|
5498
|
-
"/v1/x/": 3600 * 1e3,
|
|
5499
5009
|
"/v1/partner/": 3600 * 1e3,
|
|
5500
5010
|
"/v1/pm/": 1800 * 1e3,
|
|
5501
5011
|
"/v1/chat/": 0,
|
|
@@ -5564,8 +5074,6 @@ function readableFilename(endpoint, body) {
|
|
|
5564
5074
|
let ep = endpoint.replace(/\/+$/, "").split("/").pop() || "";
|
|
5565
5075
|
if (endpoint.includes("/v1/chat/")) {
|
|
5566
5076
|
ep = "chat";
|
|
5567
|
-
} else if (endpoint.includes("/v1/x/")) {
|
|
5568
|
-
ep = "x_" + ep;
|
|
5569
5077
|
} else if (endpoint.includes("/v1/search")) {
|
|
5570
5078
|
ep = "search";
|
|
5571
5079
|
} else if (endpoint.includes("/v1/image")) {
|
|
@@ -5863,7 +5371,7 @@ var OpenAI = class {
|
|
|
5863
5371
|
};
|
|
5864
5372
|
|
|
5865
5373
|
// src/anthropic-compat.ts
|
|
5866
|
-
import { privateKeyToAccount as
|
|
5374
|
+
import { privateKeyToAccount as privateKeyToAccount15 } from "viem/accounts";
|
|
5867
5375
|
var AnthropicClient = class {
|
|
5868
5376
|
_client = null;
|
|
5869
5377
|
_clientPromise = null;
|
|
@@ -5876,7 +5384,7 @@ var AnthropicClient = class {
|
|
|
5876
5384
|
const key = options.privateKey ?? wallet.privateKey;
|
|
5877
5385
|
validatePrivateKey(key);
|
|
5878
5386
|
this._privateKey = key;
|
|
5879
|
-
this._account =
|
|
5387
|
+
this._account = privateKeyToAccount15(this._privateKey);
|
|
5880
5388
|
const apiUrl = options.apiUrl ?? "https://blockrun.ai/api";
|
|
5881
5389
|
validateApiUrl(apiUrl);
|
|
5882
5390
|
this._apiUrl = apiUrl.replace(/\/$/, "");
|
|
@@ -6004,7 +5512,6 @@ export {
|
|
|
6004
5512
|
VoiceClient,
|
|
6005
5513
|
WALLET_DIR_PATH,
|
|
6006
5514
|
WALLET_FILE_PATH,
|
|
6007
|
-
XClient,
|
|
6008
5515
|
clearCache,
|
|
6009
5516
|
createPaymentPayload,
|
|
6010
5517
|
createSolanaPaymentPayload,
|