@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.cjs
CHANGED
|
@@ -63,7 +63,6 @@ __export(index_exports, {
|
|
|
63
63
|
VoiceClient: () => VoiceClient,
|
|
64
64
|
WALLET_DIR_PATH: () => WALLET_DIR_PATH,
|
|
65
65
|
WALLET_FILE_PATH: () => WALLET_FILE_PATH,
|
|
66
|
-
XClient: () => XClient,
|
|
67
66
|
clearCache: () => clearCache,
|
|
68
67
|
createPaymentPayload: () => createPaymentPayload,
|
|
69
68
|
createSolanaPaymentPayload: () => createSolanaPaymentPayload,
|
|
@@ -1620,205 +1619,6 @@ var LLMClient = class _LLMClient {
|
|
|
1620
1619
|
}
|
|
1621
1620
|
throw lastError || new Error("All RPCs failed");
|
|
1622
1621
|
}
|
|
1623
|
-
// ============================================================
|
|
1624
|
-
// X/Twitter endpoints (powered by AttentionVC)
|
|
1625
|
-
// ============================================================
|
|
1626
|
-
/**
|
|
1627
|
-
* Look up X/Twitter user profiles by username.
|
|
1628
|
-
*
|
|
1629
|
-
* Powered by AttentionVC. $0.002 per user (min $0.02, max $0.20).
|
|
1630
|
-
*
|
|
1631
|
-
* @param usernames - Single username or array of usernames (without @)
|
|
1632
|
-
*/
|
|
1633
|
-
async xUserLookup(usernames) {
|
|
1634
|
-
const names = Array.isArray(usernames) ? usernames : [usernames];
|
|
1635
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/lookup", { usernames: names });
|
|
1636
|
-
return data;
|
|
1637
|
-
}
|
|
1638
|
-
/**
|
|
1639
|
-
* Get followers of an X/Twitter user.
|
|
1640
|
-
*
|
|
1641
|
-
* Powered by AttentionVC. $0.05 per page (~200 accounts).
|
|
1642
|
-
*
|
|
1643
|
-
* @param username - X/Twitter username (without @)
|
|
1644
|
-
* @param cursor - Pagination cursor from previous response
|
|
1645
|
-
*/
|
|
1646
|
-
async xFollowers(username, cursor) {
|
|
1647
|
-
const body = { username };
|
|
1648
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1649
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/followers", body);
|
|
1650
|
-
return data;
|
|
1651
|
-
}
|
|
1652
|
-
/**
|
|
1653
|
-
* Get accounts an X/Twitter user is following.
|
|
1654
|
-
*
|
|
1655
|
-
* Powered by AttentionVC. $0.05 per page (~200 accounts).
|
|
1656
|
-
*
|
|
1657
|
-
* @param username - X/Twitter username (without @)
|
|
1658
|
-
* @param cursor - Pagination cursor from previous response
|
|
1659
|
-
*/
|
|
1660
|
-
async xFollowings(username, cursor) {
|
|
1661
|
-
const body = { username };
|
|
1662
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1663
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/followings", body);
|
|
1664
|
-
return data;
|
|
1665
|
-
}
|
|
1666
|
-
/**
|
|
1667
|
-
* Get detailed profile info for a single X/Twitter user.
|
|
1668
|
-
*
|
|
1669
|
-
* Powered by AttentionVC. $0.002 per request.
|
|
1670
|
-
*
|
|
1671
|
-
* @param username - X/Twitter username (without @)
|
|
1672
|
-
*/
|
|
1673
|
-
async xUserInfo(username) {
|
|
1674
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/info", { username });
|
|
1675
|
-
return data;
|
|
1676
|
-
}
|
|
1677
|
-
/**
|
|
1678
|
-
* Get verified (blue-check) followers of an X/Twitter user.
|
|
1679
|
-
*
|
|
1680
|
-
* Powered by AttentionVC. $0.048 per page.
|
|
1681
|
-
*
|
|
1682
|
-
* @param userId - X/Twitter user ID (not username)
|
|
1683
|
-
* @param cursor - Pagination cursor from previous response
|
|
1684
|
-
*/
|
|
1685
|
-
async xVerifiedFollowers(userId, cursor) {
|
|
1686
|
-
const body = { userId };
|
|
1687
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1688
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/verified-followers", body);
|
|
1689
|
-
return data;
|
|
1690
|
-
}
|
|
1691
|
-
/**
|
|
1692
|
-
* Get tweets posted by an X/Twitter user.
|
|
1693
|
-
*
|
|
1694
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1695
|
-
*
|
|
1696
|
-
* @param username - X/Twitter username (without @)
|
|
1697
|
-
* @param includeReplies - Include reply tweets (default: false)
|
|
1698
|
-
* @param cursor - Pagination cursor from previous response
|
|
1699
|
-
*/
|
|
1700
|
-
async xUserTweets(username, includeReplies = false, cursor) {
|
|
1701
|
-
const body = { username, includeReplies };
|
|
1702
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1703
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/tweets", body);
|
|
1704
|
-
return data;
|
|
1705
|
-
}
|
|
1706
|
-
/**
|
|
1707
|
-
* Get tweets that mention an X/Twitter user.
|
|
1708
|
-
*
|
|
1709
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1710
|
-
*
|
|
1711
|
-
* @param username - X/Twitter username (without @)
|
|
1712
|
-
* @param sinceTime - Start time filter (ISO8601 or Unix timestamp)
|
|
1713
|
-
* @param untilTime - End time filter (ISO8601 or Unix timestamp)
|
|
1714
|
-
* @param cursor - Pagination cursor from previous response
|
|
1715
|
-
*/
|
|
1716
|
-
async xUserMentions(username, sinceTime, untilTime, cursor) {
|
|
1717
|
-
const body = { username };
|
|
1718
|
-
if (sinceTime !== void 0) body.sinceTime = sinceTime;
|
|
1719
|
-
if (untilTime !== void 0) body.untilTime = untilTime;
|
|
1720
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1721
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/mentions", body);
|
|
1722
|
-
return data;
|
|
1723
|
-
}
|
|
1724
|
-
/**
|
|
1725
|
-
* Fetch full tweet data for up to 200 tweet IDs.
|
|
1726
|
-
*
|
|
1727
|
-
* Powered by AttentionVC. $0.16 per batch.
|
|
1728
|
-
*
|
|
1729
|
-
* @param tweetIds - Single tweet ID or array of tweet IDs (max 200)
|
|
1730
|
-
*/
|
|
1731
|
-
async xTweetLookup(tweetIds) {
|
|
1732
|
-
const ids = Array.isArray(tweetIds) ? tweetIds : [tweetIds];
|
|
1733
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/lookup", { tweet_ids: ids });
|
|
1734
|
-
return data;
|
|
1735
|
-
}
|
|
1736
|
-
/**
|
|
1737
|
-
* Get replies to a specific tweet.
|
|
1738
|
-
*
|
|
1739
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1740
|
-
*
|
|
1741
|
-
* @param tweetId - The tweet ID to get replies for
|
|
1742
|
-
* @param queryType - Sort order: 'Latest' or 'Default'
|
|
1743
|
-
* @param cursor - Pagination cursor from previous response
|
|
1744
|
-
*/
|
|
1745
|
-
async xTweetReplies(tweetId, queryType = "Latest", cursor) {
|
|
1746
|
-
const body = { tweetId, queryType };
|
|
1747
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1748
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/replies", body);
|
|
1749
|
-
return data;
|
|
1750
|
-
}
|
|
1751
|
-
/**
|
|
1752
|
-
* Get the full thread context for a tweet.
|
|
1753
|
-
*
|
|
1754
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1755
|
-
*
|
|
1756
|
-
* @param tweetId - The tweet ID to get thread for
|
|
1757
|
-
* @param cursor - Pagination cursor from previous response
|
|
1758
|
-
*/
|
|
1759
|
-
async xTweetThread(tweetId, cursor) {
|
|
1760
|
-
const body = { tweetId };
|
|
1761
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1762
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/thread", body);
|
|
1763
|
-
return data;
|
|
1764
|
-
}
|
|
1765
|
-
/**
|
|
1766
|
-
* Search X/Twitter with advanced query operators.
|
|
1767
|
-
*
|
|
1768
|
-
* Powered by AttentionVC. $0.032 per page.
|
|
1769
|
-
*
|
|
1770
|
-
* @param query - Search query (supports Twitter search operators)
|
|
1771
|
-
* @param queryType - Sort order: 'Latest', 'Top', or 'Default'
|
|
1772
|
-
* @param cursor - Pagination cursor from previous response
|
|
1773
|
-
*/
|
|
1774
|
-
async xSearch(query, queryType = "Latest", cursor) {
|
|
1775
|
-
const body = { query, queryType };
|
|
1776
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
1777
|
-
const data = await this.requestWithPaymentRaw("/v1/x/search", body);
|
|
1778
|
-
return data;
|
|
1779
|
-
}
|
|
1780
|
-
/**
|
|
1781
|
-
* Get current trending topics on X/Twitter.
|
|
1782
|
-
*
|
|
1783
|
-
* Powered by AttentionVC. $0.002 per request.
|
|
1784
|
-
*/
|
|
1785
|
-
async xTrending() {
|
|
1786
|
-
const data = await this.requestWithPaymentRaw("/v1/x/trending", {});
|
|
1787
|
-
return data;
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* Get rising/viral articles from X/Twitter.
|
|
1791
|
-
*
|
|
1792
|
-
* Powered by AttentionVC intelligence layer. $0.05 per request.
|
|
1793
|
-
*/
|
|
1794
|
-
async xArticlesRising() {
|
|
1795
|
-
const data = await this.requestWithPaymentRaw("/v1/x/articles/rising", {});
|
|
1796
|
-
return data;
|
|
1797
|
-
}
|
|
1798
|
-
/**
|
|
1799
|
-
* Get author analytics and intelligence metrics for an X/Twitter user.
|
|
1800
|
-
*
|
|
1801
|
-
* Powered by AttentionVC intelligence layer. $0.02 per request.
|
|
1802
|
-
*
|
|
1803
|
-
* @param handle - X/Twitter handle (without @)
|
|
1804
|
-
*/
|
|
1805
|
-
async xAuthorAnalytics(handle) {
|
|
1806
|
-
const data = await this.requestWithPaymentRaw("/v1/x/authors", { handle });
|
|
1807
|
-
return data;
|
|
1808
|
-
}
|
|
1809
|
-
/**
|
|
1810
|
-
* Compare two X/Twitter authors side-by-side with intelligence metrics.
|
|
1811
|
-
*
|
|
1812
|
-
* Powered by AttentionVC intelligence layer. $0.05 per request.
|
|
1813
|
-
*
|
|
1814
|
-
* @param handle1 - First X/Twitter handle (without @)
|
|
1815
|
-
* @param handle2 - Second X/Twitter handle (without @)
|
|
1816
|
-
*/
|
|
1817
|
-
async xCompareAuthors(handle1, handle2) {
|
|
1818
|
-
const data = await this.requestWithPaymentRaw("/v1/x/compare", { handle1, handle2 });
|
|
1819
|
-
return data;
|
|
1820
|
-
}
|
|
1821
|
-
// ── Prediction Markets (Powered by Predexon) ────────────────────────────
|
|
1822
1622
|
/**
|
|
1823
1623
|
* Query Predexon prediction market data (GET endpoints).
|
|
1824
1624
|
*
|
|
@@ -3544,217 +3344,10 @@ var SearchClient = class {
|
|
|
3544
3344
|
}
|
|
3545
3345
|
};
|
|
3546
3346
|
|
|
3547
|
-
// src/
|
|
3347
|
+
// src/price.ts
|
|
3548
3348
|
var import_accounts11 = require("viem/accounts");
|
|
3549
3349
|
var DEFAULT_API_URL10 = "https://blockrun.ai/api";
|
|
3550
|
-
var DEFAULT_TIMEOUT10 =
|
|
3551
|
-
var XClient = class _XClient {
|
|
3552
|
-
account;
|
|
3553
|
-
privateKey;
|
|
3554
|
-
apiUrl;
|
|
3555
|
-
timeout;
|
|
3556
|
-
static deprecationWarned = false;
|
|
3557
|
-
constructor(options = {}) {
|
|
3558
|
-
if (!_XClient.deprecationWarned) {
|
|
3559
|
-
console.warn(
|
|
3560
|
-
"[@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."
|
|
3561
|
-
);
|
|
3562
|
-
_XClient.deprecationWarned = true;
|
|
3563
|
-
}
|
|
3564
|
-
const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
|
|
3565
|
-
const privateKey = options.privateKey || envKey;
|
|
3566
|
-
if (!privateKey) {
|
|
3567
|
-
throw new Error(
|
|
3568
|
-
"Private key required. Pass privateKey in options or set BLOCKRUN_WALLET_KEY environment variable."
|
|
3569
|
-
);
|
|
3570
|
-
}
|
|
3571
|
-
validatePrivateKey(privateKey);
|
|
3572
|
-
this.privateKey = privateKey;
|
|
3573
|
-
this.account = (0, import_accounts11.privateKeyToAccount)(privateKey);
|
|
3574
|
-
const apiUrl = options.apiUrl || DEFAULT_API_URL10;
|
|
3575
|
-
validateApiUrl(apiUrl);
|
|
3576
|
-
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
3577
|
-
this.timeout = options.timeout || DEFAULT_TIMEOUT10;
|
|
3578
|
-
}
|
|
3579
|
-
// ───────── User endpoints ─────────
|
|
3580
|
-
userLookup(usernames) {
|
|
3581
|
-
return this.post("/v1/x/users/lookup", { usernames });
|
|
3582
|
-
}
|
|
3583
|
-
userInfo(username) {
|
|
3584
|
-
return this.post("/v1/x/users/info", { username });
|
|
3585
|
-
}
|
|
3586
|
-
followers(username, cursor) {
|
|
3587
|
-
const body = { username };
|
|
3588
|
-
if (cursor) body.cursor = cursor;
|
|
3589
|
-
return this.post("/v1/x/users/followers", body);
|
|
3590
|
-
}
|
|
3591
|
-
/** `/v1/x/users/following` (singular path variant). */
|
|
3592
|
-
following(username, cursor) {
|
|
3593
|
-
const body = { username };
|
|
3594
|
-
if (cursor) body.cursor = cursor;
|
|
3595
|
-
return this.post("/v1/x/users/following", body);
|
|
3596
|
-
}
|
|
3597
|
-
/** `/v1/x/users/followings` (plural path variant). */
|
|
3598
|
-
followings(username, cursor) {
|
|
3599
|
-
const body = { username };
|
|
3600
|
-
if (cursor) body.cursor = cursor;
|
|
3601
|
-
return this.post("/v1/x/users/followings", body);
|
|
3602
|
-
}
|
|
3603
|
-
verifiedFollowers(userId, cursor) {
|
|
3604
|
-
const body = { userId };
|
|
3605
|
-
if (cursor) body.cursor = cursor;
|
|
3606
|
-
return this.post(
|
|
3607
|
-
"/v1/x/users/verified-followers",
|
|
3608
|
-
body
|
|
3609
|
-
);
|
|
3610
|
-
}
|
|
3611
|
-
userTweets(options) {
|
|
3612
|
-
if (!options.username && !options.userId) {
|
|
3613
|
-
throw new Error("Either username or userId is required");
|
|
3614
|
-
}
|
|
3615
|
-
const body = {};
|
|
3616
|
-
if (options.username) body.username = options.username;
|
|
3617
|
-
if (options.userId) body.userId = options.userId;
|
|
3618
|
-
if (options.cursor) body.cursor = options.cursor;
|
|
3619
|
-
if (options.includeReplies !== void 0) body.includeReplies = options.includeReplies;
|
|
3620
|
-
return this.post("/v1/x/users/tweets", body);
|
|
3621
|
-
}
|
|
3622
|
-
mentions(username, options) {
|
|
3623
|
-
const body = { username };
|
|
3624
|
-
if (options?.sinceTime) body.sinceTime = options.sinceTime;
|
|
3625
|
-
if (options?.untilTime) body.untilTime = options.untilTime;
|
|
3626
|
-
if (options?.cursor) body.cursor = options.cursor;
|
|
3627
|
-
return this.post("/v1/x/users/mentions", body);
|
|
3628
|
-
}
|
|
3629
|
-
// ───────── Tweet endpoints ─────────
|
|
3630
|
-
tweetLookup(tweetIds) {
|
|
3631
|
-
return this.post("/v1/x/tweets/lookup", {
|
|
3632
|
-
tweet_ids: tweetIds
|
|
3633
|
-
});
|
|
3634
|
-
}
|
|
3635
|
-
tweetReplies(tweetId, options) {
|
|
3636
|
-
const body = { tweetId };
|
|
3637
|
-
if (options?.cursor) body.cursor = options.cursor;
|
|
3638
|
-
if (options?.queryType) body.queryType = options.queryType;
|
|
3639
|
-
return this.post("/v1/x/tweets/replies", body);
|
|
3640
|
-
}
|
|
3641
|
-
tweetThread(tweetId, cursor) {
|
|
3642
|
-
const body = { tweetId };
|
|
3643
|
-
if (cursor) body.cursor = cursor;
|
|
3644
|
-
return this.post("/v1/x/tweets/thread", body);
|
|
3645
|
-
}
|
|
3646
|
-
// ───────── Search & discovery ─────────
|
|
3647
|
-
search(query, options) {
|
|
3648
|
-
const body = { query };
|
|
3649
|
-
if (options?.queryType) body.queryType = options.queryType;
|
|
3650
|
-
if (options?.cursor) body.cursor = options.cursor;
|
|
3651
|
-
return this.post("/v1/x/search", body);
|
|
3652
|
-
}
|
|
3653
|
-
trending() {
|
|
3654
|
-
return this.post("/v1/x/trending", {});
|
|
3655
|
-
}
|
|
3656
|
-
articlesRising() {
|
|
3657
|
-
return this.post("/v1/x/articles/rising", {});
|
|
3658
|
-
}
|
|
3659
|
-
// ───────── Internals ─────────
|
|
3660
|
-
async post(endpoint, body) {
|
|
3661
|
-
const url = `${this.apiUrl}${endpoint}`;
|
|
3662
|
-
const response = await this.fetchWithTimeout(url, {
|
|
3663
|
-
method: "POST",
|
|
3664
|
-
headers: { "Content-Type": "application/json" },
|
|
3665
|
-
body: JSON.stringify(body)
|
|
3666
|
-
});
|
|
3667
|
-
if (response.status === 402) {
|
|
3668
|
-
return this.payAndRetry(url, body, response);
|
|
3669
|
-
}
|
|
3670
|
-
if (!response.ok) {
|
|
3671
|
-
let errorBody;
|
|
3672
|
-
try {
|
|
3673
|
-
errorBody = await response.json();
|
|
3674
|
-
} catch {
|
|
3675
|
-
errorBody = { error: "Request failed" };
|
|
3676
|
-
}
|
|
3677
|
-
throw new APIError(
|
|
3678
|
-
`API error: ${response.status}`,
|
|
3679
|
-
response.status,
|
|
3680
|
-
sanitizeErrorResponse(errorBody)
|
|
3681
|
-
);
|
|
3682
|
-
}
|
|
3683
|
-
return response.json();
|
|
3684
|
-
}
|
|
3685
|
-
async payAndRetry(url, body, response) {
|
|
3686
|
-
let paymentHeader = response.headers.get("payment-required");
|
|
3687
|
-
if (!paymentHeader) {
|
|
3688
|
-
try {
|
|
3689
|
-
const respBody = await response.json();
|
|
3690
|
-
if (respBody.x402 || respBody.accepts) {
|
|
3691
|
-
paymentHeader = btoa(JSON.stringify(respBody));
|
|
3692
|
-
}
|
|
3693
|
-
} catch {
|
|
3694
|
-
}
|
|
3695
|
-
}
|
|
3696
|
-
if (!paymentHeader) {
|
|
3697
|
-
throw new PaymentError("402 response but no payment requirements found");
|
|
3698
|
-
}
|
|
3699
|
-
const paymentRequired = parsePaymentRequired(paymentHeader);
|
|
3700
|
-
const details = extractPaymentDetails(paymentRequired);
|
|
3701
|
-
const paymentPayload = await createPaymentPayload(
|
|
3702
|
-
this.privateKey,
|
|
3703
|
-
this.account.address,
|
|
3704
|
-
details.recipient,
|
|
3705
|
-
details.amount,
|
|
3706
|
-
details.network || "eip155:8453",
|
|
3707
|
-
{
|
|
3708
|
-
resourceUrl: details.resource?.url || url,
|
|
3709
|
-
resourceDescription: details.resource?.description || "BlockRun X API",
|
|
3710
|
-
maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
|
|
3711
|
-
extra: details.extra
|
|
3712
|
-
}
|
|
3713
|
-
);
|
|
3714
|
-
const retry = await this.fetchWithTimeout(url, {
|
|
3715
|
-
method: "POST",
|
|
3716
|
-
headers: {
|
|
3717
|
-
"Content-Type": "application/json",
|
|
3718
|
-
"PAYMENT-SIGNATURE": paymentPayload
|
|
3719
|
-
},
|
|
3720
|
-
body: JSON.stringify(body)
|
|
3721
|
-
});
|
|
3722
|
-
if (retry.status === 402) {
|
|
3723
|
-
throw new PaymentError("Payment was rejected. Check your wallet balance.");
|
|
3724
|
-
}
|
|
3725
|
-
if (!retry.ok) {
|
|
3726
|
-
let errorBody;
|
|
3727
|
-
try {
|
|
3728
|
-
errorBody = await retry.json();
|
|
3729
|
-
} catch {
|
|
3730
|
-
errorBody = { error: "Request failed" };
|
|
3731
|
-
}
|
|
3732
|
-
throw new APIError(
|
|
3733
|
-
`API error after payment: ${retry.status}`,
|
|
3734
|
-
retry.status,
|
|
3735
|
-
sanitizeErrorResponse(errorBody)
|
|
3736
|
-
);
|
|
3737
|
-
}
|
|
3738
|
-
return retry.json();
|
|
3739
|
-
}
|
|
3740
|
-
async fetchWithTimeout(url, init) {
|
|
3741
|
-
const controller = new AbortController();
|
|
3742
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
3743
|
-
try {
|
|
3744
|
-
return await fetch(url, { ...init, signal: controller.signal });
|
|
3745
|
-
} finally {
|
|
3746
|
-
clearTimeout(timeoutId);
|
|
3747
|
-
}
|
|
3748
|
-
}
|
|
3749
|
-
getWalletAddress() {
|
|
3750
|
-
return this.account.address;
|
|
3751
|
-
}
|
|
3752
|
-
};
|
|
3753
|
-
|
|
3754
|
-
// src/price.ts
|
|
3755
|
-
var import_accounts12 = require("viem/accounts");
|
|
3756
|
-
var DEFAULT_API_URL11 = "https://blockrun.ai/api";
|
|
3757
|
-
var DEFAULT_TIMEOUT11 = 3e4;
|
|
3350
|
+
var DEFAULT_TIMEOUT10 = 3e4;
|
|
3758
3351
|
var PriceClient = class {
|
|
3759
3352
|
account = null;
|
|
3760
3353
|
privateKey = null;
|
|
@@ -3772,12 +3365,12 @@ var PriceClient = class {
|
|
|
3772
3365
|
if (privateKey) {
|
|
3773
3366
|
validatePrivateKey(privateKey);
|
|
3774
3367
|
this.privateKey = privateKey;
|
|
3775
|
-
this.account = (0,
|
|
3368
|
+
this.account = (0, import_accounts11.privateKeyToAccount)(privateKey);
|
|
3776
3369
|
}
|
|
3777
|
-
const apiUrl = options.apiUrl ||
|
|
3370
|
+
const apiUrl = options.apiUrl || DEFAULT_API_URL10;
|
|
3778
3371
|
validateApiUrl(apiUrl);
|
|
3779
3372
|
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
3780
|
-
this.timeout = options.timeout ||
|
|
3373
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT10;
|
|
3781
3374
|
}
|
|
3782
3375
|
async price(category, symbol, options) {
|
|
3783
3376
|
if (!symbol) throw new Error("symbol is required");
|
|
@@ -3956,9 +3549,9 @@ function buildUrl(base, query) {
|
|
|
3956
3549
|
}
|
|
3957
3550
|
|
|
3958
3551
|
// src/surf.ts
|
|
3959
|
-
var
|
|
3960
|
-
var
|
|
3961
|
-
var
|
|
3552
|
+
var import_accounts12 = require("viem/accounts");
|
|
3553
|
+
var DEFAULT_API_URL11 = "https://blockrun.ai/api";
|
|
3554
|
+
var DEFAULT_TIMEOUT11 = 6e4;
|
|
3962
3555
|
var SURF_PREFIX = "/v1/surf";
|
|
3963
3556
|
var SurfClient = class {
|
|
3964
3557
|
account;
|
|
@@ -3975,11 +3568,11 @@ var SurfClient = class {
|
|
|
3975
3568
|
}
|
|
3976
3569
|
validatePrivateKey(privateKey);
|
|
3977
3570
|
this.privateKey = privateKey;
|
|
3978
|
-
this.account = (0,
|
|
3979
|
-
const apiUrl = options.apiUrl ||
|
|
3571
|
+
this.account = (0, import_accounts12.privateKeyToAccount)(privateKey);
|
|
3572
|
+
const apiUrl = options.apiUrl || DEFAULT_API_URL11;
|
|
3980
3573
|
validateApiUrl(apiUrl);
|
|
3981
3574
|
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
3982
|
-
this.timeout = options.timeout ||
|
|
3575
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT11;
|
|
3983
3576
|
}
|
|
3984
3577
|
/**
|
|
3985
3578
|
* GET a Surf endpoint. `path` is everything after `/v1/surf` (a leading
|
|
@@ -4111,9 +3704,9 @@ var SurfClient = class {
|
|
|
4111
3704
|
};
|
|
4112
3705
|
|
|
4113
3706
|
// src/rpc.ts
|
|
4114
|
-
var
|
|
4115
|
-
var
|
|
4116
|
-
var
|
|
3707
|
+
var import_accounts13 = require("viem/accounts");
|
|
3708
|
+
var DEFAULT_API_URL12 = "https://blockrun.ai/api";
|
|
3709
|
+
var DEFAULT_TIMEOUT12 = 6e4;
|
|
4117
3710
|
var RPC_PRICE_USD = 2e-3;
|
|
4118
3711
|
var SUPPORTED_NETWORKS = [
|
|
4119
3712
|
// EVM
|
|
@@ -4205,11 +3798,11 @@ var RpcClient = class {
|
|
|
4205
3798
|
}
|
|
4206
3799
|
validatePrivateKey(privateKey);
|
|
4207
3800
|
this.privateKey = privateKey;
|
|
4208
|
-
this.account = (0,
|
|
4209
|
-
const apiUrl = options.apiUrl ||
|
|
3801
|
+
this.account = (0, import_accounts13.privateKeyToAccount)(privateKey);
|
|
3802
|
+
const apiUrl = options.apiUrl || DEFAULT_API_URL12;
|
|
4210
3803
|
validateApiUrl(apiUrl);
|
|
4211
3804
|
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
4212
|
-
this.timeout = options.timeout ||
|
|
3805
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT12;
|
|
4213
3806
|
}
|
|
4214
3807
|
/**
|
|
4215
3808
|
* Make a single JSON-RPC 2.0 call. Flat $0.002.
|
|
@@ -4364,9 +3957,9 @@ var RpcClient = class {
|
|
|
4364
3957
|
};
|
|
4365
3958
|
|
|
4366
3959
|
// src/blockrun.ts
|
|
4367
|
-
var
|
|
4368
|
-
var
|
|
4369
|
-
var
|
|
3960
|
+
var import_accounts14 = require("viem/accounts");
|
|
3961
|
+
var DEFAULT_API_URL13 = "https://blockrun.ai/api";
|
|
3962
|
+
var DEFAULT_TIMEOUT13 = 6e4;
|
|
4370
3963
|
var DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
4371
3964
|
var DEFAULT_POLL_BUDGET_MS = 3e5;
|
|
4372
3965
|
var MAX_SIGNED_AUTH_SECONDS = 600;
|
|
@@ -4387,11 +3980,11 @@ var BlockrunClient = class {
|
|
|
4387
3980
|
}
|
|
4388
3981
|
validatePrivateKey(privateKey);
|
|
4389
3982
|
this.privateKey = privateKey;
|
|
4390
|
-
this.account = (0,
|
|
4391
|
-
const apiUrl = options.apiUrl ||
|
|
3983
|
+
this.account = (0, import_accounts14.privateKeyToAccount)(privateKey);
|
|
3984
|
+
const apiUrl = options.apiUrl || DEFAULT_API_URL13;
|
|
4392
3985
|
validateApiUrl(apiUrl);
|
|
4393
3986
|
this.apiUrl = apiUrl.replace(/\/$/, "");
|
|
4394
|
-
this.timeout = options.timeout ||
|
|
3987
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT13;
|
|
4395
3988
|
}
|
|
4396
3989
|
/**
|
|
4397
3990
|
* GET a BlockRun endpoint. `path` is everything after `/api` (a leading
|
|
@@ -4742,7 +4335,7 @@ function sleep(ms) {
|
|
|
4742
4335
|
}
|
|
4743
4336
|
|
|
4744
4337
|
// src/wallet.ts
|
|
4745
|
-
var
|
|
4338
|
+
var import_accounts15 = require("viem/accounts");
|
|
4746
4339
|
var fs2 = __toESM(require("fs"), 1);
|
|
4747
4340
|
var path2 = __toESM(require("path"), 1);
|
|
4748
4341
|
var os2 = __toESM(require("os"), 1);
|
|
@@ -4751,8 +4344,8 @@ var BASE_CHAIN_ID2 = "8453";
|
|
|
4751
4344
|
var WALLET_DIR = path2.join(os2.homedir(), ".blockrun");
|
|
4752
4345
|
var WALLET_FILE = path2.join(WALLET_DIR, ".session");
|
|
4753
4346
|
function createWallet() {
|
|
4754
|
-
const privateKey = (0,
|
|
4755
|
-
const account = (0,
|
|
4347
|
+
const privateKey = (0, import_accounts15.generatePrivateKey)();
|
|
4348
|
+
const account = (0, import_accounts15.privateKeyToAccount)(privateKey);
|
|
4756
4349
|
return {
|
|
4757
4350
|
address: account.address,
|
|
4758
4351
|
privateKey
|
|
@@ -4808,12 +4401,12 @@ function loadWallet() {
|
|
|
4808
4401
|
function getOrCreateWallet() {
|
|
4809
4402
|
const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
|
|
4810
4403
|
if (envKey) {
|
|
4811
|
-
const account = (0,
|
|
4404
|
+
const account = (0, import_accounts15.privateKeyToAccount)(envKey);
|
|
4812
4405
|
return { address: account.address, privateKey: envKey, isNew: false };
|
|
4813
4406
|
}
|
|
4814
4407
|
const fileKey = loadWallet();
|
|
4815
4408
|
if (fileKey) {
|
|
4816
|
-
const account = (0,
|
|
4409
|
+
const account = (0, import_accounts15.privateKeyToAccount)(fileKey);
|
|
4817
4410
|
return { address: account.address, privateKey: fileKey, isNew: false };
|
|
4818
4411
|
}
|
|
4819
4412
|
const { address, privateKey } = createWallet();
|
|
@@ -4823,11 +4416,11 @@ function getOrCreateWallet() {
|
|
|
4823
4416
|
function getWalletAddress() {
|
|
4824
4417
|
const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
|
|
4825
4418
|
if (envKey) {
|
|
4826
|
-
return (0,
|
|
4419
|
+
return (0, import_accounts15.privateKeyToAccount)(envKey).address;
|
|
4827
4420
|
}
|
|
4828
4421
|
const fileKey = loadWallet();
|
|
4829
4422
|
if (fileKey) {
|
|
4830
|
-
return (0,
|
|
4423
|
+
return (0, import_accounts15.privateKeyToAccount)(fileKey).address;
|
|
4831
4424
|
}
|
|
4832
4425
|
return null;
|
|
4833
4426
|
}
|
|
@@ -5007,7 +4600,7 @@ async function getOrCreateSolanaWallet() {
|
|
|
5007
4600
|
// src/solana-client.ts
|
|
5008
4601
|
var SOLANA_API_URL = "https://sol.blockrun.ai/api";
|
|
5009
4602
|
var DEFAULT_MAX_TOKENS2 = 1024;
|
|
5010
|
-
var
|
|
4603
|
+
var DEFAULT_TIMEOUT14 = 6e4;
|
|
5011
4604
|
var SDK_VERSION2 = "0.3.0";
|
|
5012
4605
|
var USER_AGENT2 = `blockrun-ts/${SDK_VERSION2}`;
|
|
5013
4606
|
var DEFAULT_SOLANA_RPC_URL = "https://sol.blockrun.ai/api/v1/solana/rpc";
|
|
@@ -5057,7 +4650,7 @@ var SolanaLLMClient = class {
|
|
|
5057
4650
|
const rpc = resolveRpcConfig(options.rpcUrl, options.rpcHeaders);
|
|
5058
4651
|
this.rpcUrl = rpc.url;
|
|
5059
4652
|
this.rpcHeaders = rpc.headers;
|
|
5060
|
-
this.timeout = options.timeout ||
|
|
4653
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT14;
|
|
5061
4654
|
}
|
|
5062
4655
|
/** Get Solana wallet address (public key in base58). */
|
|
5063
4656
|
async getWalletAddress() {
|
|
@@ -5157,89 +4750,6 @@ var SolanaLLMClient = class {
|
|
|
5157
4750
|
const data = await this.requestWithPaymentRaw("/v1/search", body);
|
|
5158
4751
|
return data;
|
|
5159
4752
|
}
|
|
5160
|
-
// ============================================================
|
|
5161
|
-
// X/Twitter endpoints (powered by AttentionVC)
|
|
5162
|
-
// ============================================================
|
|
5163
|
-
async xUserLookup(usernames) {
|
|
5164
|
-
const names = Array.isArray(usernames) ? usernames : [usernames];
|
|
5165
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/lookup", { usernames: names });
|
|
5166
|
-
return data;
|
|
5167
|
-
}
|
|
5168
|
-
async xFollowers(username, cursor) {
|
|
5169
|
-
const body = { username };
|
|
5170
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5171
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/followers", body);
|
|
5172
|
-
return data;
|
|
5173
|
-
}
|
|
5174
|
-
async xFollowings(username, cursor) {
|
|
5175
|
-
const body = { username };
|
|
5176
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5177
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/followings", body);
|
|
5178
|
-
return data;
|
|
5179
|
-
}
|
|
5180
|
-
async xUserInfo(username) {
|
|
5181
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/info", { username });
|
|
5182
|
-
return data;
|
|
5183
|
-
}
|
|
5184
|
-
async xVerifiedFollowers(userId, cursor) {
|
|
5185
|
-
const body = { userId };
|
|
5186
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5187
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/verified-followers", body);
|
|
5188
|
-
return data;
|
|
5189
|
-
}
|
|
5190
|
-
async xUserTweets(username, includeReplies = false, cursor) {
|
|
5191
|
-
const body = { username, includeReplies };
|
|
5192
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5193
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/tweets", body);
|
|
5194
|
-
return data;
|
|
5195
|
-
}
|
|
5196
|
-
async xUserMentions(username, sinceTime, untilTime, cursor) {
|
|
5197
|
-
const body = { username };
|
|
5198
|
-
if (sinceTime !== void 0) body.sinceTime = sinceTime;
|
|
5199
|
-
if (untilTime !== void 0) body.untilTime = untilTime;
|
|
5200
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5201
|
-
const data = await this.requestWithPaymentRaw("/v1/x/users/mentions", body);
|
|
5202
|
-
return data;
|
|
5203
|
-
}
|
|
5204
|
-
async xTweetLookup(tweetIds) {
|
|
5205
|
-
const ids = Array.isArray(tweetIds) ? tweetIds : [tweetIds];
|
|
5206
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/lookup", { tweet_ids: ids });
|
|
5207
|
-
return data;
|
|
5208
|
-
}
|
|
5209
|
-
async xTweetReplies(tweetId, queryType = "Latest", cursor) {
|
|
5210
|
-
const body = { tweetId, queryType };
|
|
5211
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5212
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/replies", body);
|
|
5213
|
-
return data;
|
|
5214
|
-
}
|
|
5215
|
-
async xTweetThread(tweetId, cursor) {
|
|
5216
|
-
const body = { tweetId };
|
|
5217
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5218
|
-
const data = await this.requestWithPaymentRaw("/v1/x/tweets/thread", body);
|
|
5219
|
-
return data;
|
|
5220
|
-
}
|
|
5221
|
-
async xSearch(query, queryType = "Latest", cursor) {
|
|
5222
|
-
const body = { query, queryType };
|
|
5223
|
-
if (cursor !== void 0) body.cursor = cursor;
|
|
5224
|
-
const data = await this.requestWithPaymentRaw("/v1/x/search", body);
|
|
5225
|
-
return data;
|
|
5226
|
-
}
|
|
5227
|
-
async xTrending() {
|
|
5228
|
-
const data = await this.requestWithPaymentRaw("/v1/x/trending", {});
|
|
5229
|
-
return data;
|
|
5230
|
-
}
|
|
5231
|
-
async xArticlesRising() {
|
|
5232
|
-
const data = await this.requestWithPaymentRaw("/v1/x/articles/rising", {});
|
|
5233
|
-
return data;
|
|
5234
|
-
}
|
|
5235
|
-
async xAuthorAnalytics(handle) {
|
|
5236
|
-
const data = await this.requestWithPaymentRaw("/v1/x/authors", { handle });
|
|
5237
|
-
return data;
|
|
5238
|
-
}
|
|
5239
|
-
async xCompareAuthors(handle1, handle2) {
|
|
5240
|
-
const data = await this.requestWithPaymentRaw("/v1/x/compare", { handle1, handle2 });
|
|
5241
|
-
return data;
|
|
5242
|
-
}
|
|
5243
4753
|
// ── Prediction Markets (Powered by Predexon) ────────────────────────────
|
|
5244
4754
|
async pm(path5, params) {
|
|
5245
4755
|
return this.getWithPaymentRaw(`/v1/pm/${path5}`, params);
|
|
@@ -5603,7 +5113,6 @@ var CACHE_DIR = path4.join(os4.homedir(), ".blockrun", "cache");
|
|
|
5603
5113
|
var DATA_DIR = path4.join(os4.homedir(), ".blockrun", "data");
|
|
5604
5114
|
var COST_LOG_FILE2 = path4.join(os4.homedir(), ".blockrun", "cost_log.jsonl");
|
|
5605
5115
|
var DEFAULT_TTL = {
|
|
5606
|
-
"/v1/x/": 3600 * 1e3,
|
|
5607
5116
|
"/v1/partner/": 3600 * 1e3,
|
|
5608
5117
|
"/v1/pm/": 1800 * 1e3,
|
|
5609
5118
|
"/v1/chat/": 0,
|
|
@@ -5672,8 +5181,6 @@ function readableFilename(endpoint, body) {
|
|
|
5672
5181
|
let ep = endpoint.replace(/\/+$/, "").split("/").pop() || "";
|
|
5673
5182
|
if (endpoint.includes("/v1/chat/")) {
|
|
5674
5183
|
ep = "chat";
|
|
5675
|
-
} else if (endpoint.includes("/v1/x/")) {
|
|
5676
|
-
ep = "x_" + ep;
|
|
5677
5184
|
} else if (endpoint.includes("/v1/search")) {
|
|
5678
5185
|
ep = "search";
|
|
5679
5186
|
} else if (endpoint.includes("/v1/image")) {
|
|
@@ -5971,7 +5478,7 @@ var OpenAI = class {
|
|
|
5971
5478
|
};
|
|
5972
5479
|
|
|
5973
5480
|
// src/anthropic-compat.ts
|
|
5974
|
-
var
|
|
5481
|
+
var import_accounts16 = require("viem/accounts");
|
|
5975
5482
|
var AnthropicClient = class {
|
|
5976
5483
|
_client = null;
|
|
5977
5484
|
_clientPromise = null;
|
|
@@ -5984,7 +5491,7 @@ var AnthropicClient = class {
|
|
|
5984
5491
|
const key = options.privateKey ?? wallet.privateKey;
|
|
5985
5492
|
validatePrivateKey(key);
|
|
5986
5493
|
this._privateKey = key;
|
|
5987
|
-
this._account = (0,
|
|
5494
|
+
this._account = (0, import_accounts16.privateKeyToAccount)(this._privateKey);
|
|
5988
5495
|
const apiUrl = options.apiUrl ?? "https://blockrun.ai/api";
|
|
5989
5496
|
validateApiUrl(apiUrl);
|
|
5990
5497
|
this._apiUrl = apiUrl.replace(/\/$/, "");
|
|
@@ -6113,7 +5620,6 @@ var AnthropicClient = class {
|
|
|
6113
5620
|
VoiceClient,
|
|
6114
5621
|
WALLET_DIR_PATH,
|
|
6115
5622
|
WALLET_FILE_PATH,
|
|
6116
|
-
XClient,
|
|
6117
5623
|
clearCache,
|
|
6118
5624
|
createPaymentPayload,
|
|
6119
5625
|
createSolanaPaymentPayload,
|