@coinbase/agentkit 0.0.0-nightly-20250425210424 → 0.0.0-nightly-20250429210433

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.
Files changed (31) hide show
  1. package/README.md +142 -0
  2. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +37 -0
  3. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +91 -0
  4. package/dist/action-providers/cdp-v2/index.d.ts +2 -0
  5. package/dist/action-providers/cdp-v2/index.js +18 -0
  6. package/dist/action-providers/cdp-v2/schemas.d.ts +11 -0
  7. package/dist/action-providers/cdp-v2/schemas.js +13 -0
  8. package/dist/action-providers/compound/schemas.d.ts +8 -8
  9. package/dist/action-providers/flaunch/utils.js +1 -1
  10. package/dist/action-providers/index.d.ts +1 -0
  11. package/dist/action-providers/index.js +1 -0
  12. package/dist/action-providers/twitter/twitterActionProvider.d.ts +8 -1
  13. package/dist/action-providers/twitter/twitterActionProvider.js +36 -18
  14. package/dist/action-providers/twitter/twitterActionProvider.test.js +45 -0
  15. package/dist/network/svm.d.ts +1 -0
  16. package/dist/network/svm.js +6 -1
  17. package/dist/wallet-providers/cdpV2EvmWalletProvider.d.ts +105 -0
  18. package/dist/wallet-providers/cdpV2EvmWalletProvider.js +212 -0
  19. package/dist/wallet-providers/cdpV2EvmWalletProvider.test.d.ts +1 -0
  20. package/dist/wallet-providers/cdpV2EvmWalletProvider.test.js +343 -0
  21. package/dist/wallet-providers/cdpV2Shared.d.ts +41 -0
  22. package/dist/wallet-providers/cdpV2Shared.js +2 -0
  23. package/dist/wallet-providers/cdpV2SolanaWalletProvider.d.ts +111 -0
  24. package/dist/wallet-providers/cdpV2SolanaWalletProvider.js +247 -0
  25. package/dist/wallet-providers/cdpV2SolanaWalletProvider.test.d.ts +1 -0
  26. package/dist/wallet-providers/cdpV2SolanaWalletProvider.test.js +307 -0
  27. package/dist/wallet-providers/cdpV2WalletProvider.d.ts +35 -0
  28. package/dist/wallet-providers/cdpV2WalletProvider.js +42 -0
  29. package/dist/wallet-providers/index.d.ts +4 -0
  30. package/dist/wallet-providers/index.js +4 -0
  31. package/package.json +2 -1
package/README.md CHANGED
@@ -18,6 +18,7 @@ AgentKit is a framework for easily enabling AI agents to take actions onchain. I
18
18
  - [Adding Actions to your Action Provider that use a Wallet Provider](#adding-actions-to-your-action-provider-that-use-a-wallet-provider)
19
19
  - [Adding an Action Provider to your AgentKit instance](#adding-an-action-provider-to-your-agentkit-instance)
20
20
  - [EVM Wallet Providers](#evm-wallet-providers)
21
+ - [CdpV2EvmWalletProvider](#cdpv2evmwalletprovider)
21
22
  - [CdpWalletProvider](#cdpwalletprovider)
22
23
  - [Network Configuration](#network-configuration)
23
24
  - [Configuring from an existing CDP API Wallet](#configuring-from-an-existing-cdp-api-wallet)
@@ -36,6 +37,7 @@ AgentKit is a framework for easily enabling AI agents to take actions onchain. I
36
37
  - [Configuring from PrivyWalletProvider](#configuring-from-privywalletprovider)
37
38
  - [Configuring from ViemWalletProvider](#configuring-from-viemwalletprovider)
38
39
  - [SVM Wallet Providers](#svm-wallet-providers)
40
+ - [CdpV2SolanaWalletProvider](#cdpv2solanawalletprovider)
39
41
  - [SolanaKeypairWalletProvider](#solanakeypairwalletprovider)
40
42
  - [Network Configuration](#solana-network-configuration)
41
43
  - [RPC URL Configuration](#rpc-url-configuration)
@@ -537,11 +539,76 @@ const agentKit = new AgentKit({
537
539
  Wallet providers give an agent access to a wallet. AgentKit currently supports the following wallet providers:
538
540
 
539
541
  EVM:
542
+ - [CdpV2EvmWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/cdpV2EvmWalletProvider.ts)
540
543
  - [CdpWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/cdpWalletProvider.ts)
541
544
  - [ViemWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/viemWalletProvider.ts)
542
545
  - [PrivyWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/privyWalletProvider.ts)
543
546
  - [ZeroDevWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/zeroDevWalletProvider.ts)
544
547
 
548
+ ### CdpV2EvmWalletProvider
549
+
550
+ The `CdpV2EvmWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) V2 API. It provides a more modern and streamlined interface for interacting with CDP wallets.
551
+
552
+ #### Basic Configuration
553
+
554
+ ```typescript
555
+ import { CdpV2EvmWalletProvider } from "@coinbase/agentkit";
556
+
557
+ const walletProvider = await CdpV2EvmWalletProvider.configureWithWallet({
558
+ apiKeyId: "CDP_API_KEY_ID",
559
+ apiKeySecret: "CDP_API_KEY_SECRET",
560
+ walletSecret: "CDP_WALLET_SECRET",
561
+ networkId: "base-sepolia", // Optional, defaults to "base-sepolia"
562
+ });
563
+ ```
564
+
565
+ #### Using an Existing Wallet
566
+
567
+ You can configure the provider with an existing wallet by providing the wallet's address:
568
+
569
+ ```typescript
570
+ import { CdpV2EvmWalletProvider } from "@coinbase/agentkit";
571
+
572
+ const walletProvider = await CdpV2EvmWalletProvider.configureWithWallet({
573
+ apiKeyId: "CDP_API_KEY_ID",
574
+ apiKeySecret: "CDP_API_KEY_SECRET",
575
+ walletSecret: "CDP_WALLET_SECRET",
576
+ address: "0x...", // The address of an existing wallet
577
+ networkId: "base-sepolia",
578
+ });
579
+ ```
580
+
581
+ #### Creating a New Wallet
582
+
583
+ To create a new wallet, you can provide an idempotency key. The same idempotency key will always generate the same wallet address, and these keys are valid for 24 hours:
584
+
585
+ ```typescript
586
+ import { CdpV2EvmWalletProvider } from "@coinbase/agentkit";
587
+
588
+ const walletProvider = await CdpV2EvmWalletProvider.configureWithWallet({
589
+ apiKeyId: "CDP_API_KEY_ID",
590
+ apiKeySecret: "CDP_API_KEY_SECRET",
591
+ walletSecret: "CDP_WALLET_SECRET",
592
+ idempotencyKey: "unique-key-123", // Optional, if not provided a new wallet will be created
593
+ networkId: "base-sepolia",
594
+ });
595
+ ```
596
+
597
+ #### Environment Variables
598
+
599
+ The provider can also be configured using environment variables:
600
+
601
+ ```typescript
602
+ // Environment variables:
603
+ // CDP_API_KEY_ID=your_api_key_id
604
+ // CDP_API_KEY_SECRET=your_api_key_secret
605
+ // CDP_WALLET_SECRET=your_wallet_secret
606
+ // NETWORK_ID=base-sepolia (optional)
607
+ // IDEMPOTENCY_KEY=unique-key-123 (optional)
608
+
609
+ const walletProvider = await CdpV2EvmWalletProvider.configureWithWallet();
610
+ ```
611
+
545
612
  ### CdpWalletProvider
546
613
 
547
614
  The `CdpWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) [API Wallet](https://docs.cdp.coinbase.com/wallet-api/docs/welcome).
@@ -877,10 +944,84 @@ const walletProvider = await ZeroDevWalletProvider.configureWithWallet({
877
944
 
878
945
  ## SVM Wallet Providers
879
946
 
947
+ Wallet providers give an agent access to a wallet. AgentKit currently supports the following wallet providers:
948
+
880
949
  SVM:
950
+ - [CdpV2SolanaWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/cdpV2SolanaWalletProvider.ts)
881
951
  - [SolanaKeypairWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/solanaKeypairWalletProvider.ts)
882
952
  - [PrivyWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/privySvmWalletProvider.ts)
883
953
 
954
+ ### CdpV2SolanaWalletProvider
955
+
956
+ The `CdpV2SolanaWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) V2 API for Solana. It provides a more modern and streamlined interface for interacting with CDP wallets on the Solana network.
957
+
958
+ #### Basic Configuration
959
+
960
+ ```typescript
961
+ import { CdpV2SolanaWalletProvider } from "@coinbase/agentkit";
962
+
963
+ const walletProvider = await CdpV2SolanaWalletProvider.configureWithWallet({
964
+ apiKeyId: "CDP_API_KEY_ID",
965
+ apiKeySecret: "CDP_API_KEY_SECRET",
966
+ walletSecret: "CDP_WALLET_SECRET",
967
+ networkId: "solana-devnet", // Optional, defaults to "solana-devnet"
968
+ });
969
+ ```
970
+
971
+ #### Using an Existing Wallet
972
+
973
+ You can configure the provider with an existing wallet by providing the wallet's address:
974
+
975
+ ```typescript
976
+ import { CdpV2SolanaWalletProvider } from "@coinbase/agentkit";
977
+
978
+ const walletProvider = await CdpV2SolanaWalletProvider.configureWithWallet({
979
+ apiKeyId: "CDP_API_KEY_ID",
980
+ apiKeySecret: "CDP_API_KEY_SECRET",
981
+ walletSecret: "CDP_WALLET_SECRET",
982
+ address: "your-solana-address", // The address of an existing wallet
983
+ networkId: "solana-devnet",
984
+ });
985
+ ```
986
+
987
+ #### Creating a New Wallet
988
+
989
+ To create a new wallet, you can provide an idempotency key. The same idempotency key will always generate the same wallet address, and these keys are valid for 24 hours:
990
+
991
+ ```typescript
992
+ import { CdpV2SolanaWalletProvider } from "@coinbase/agentkit";
993
+
994
+ const walletProvider = await CdpV2SolanaWalletProvider.configureWithWallet({
995
+ apiKeyId: "CDP_API_KEY_ID",
996
+ apiKeySecret: "CDP_API_KEY_SECRET",
997
+ walletSecret: "CDP_WALLET_SECRET",
998
+ idempotencyKey: "unique-key-123", // Optional, if not provided a new wallet will be created
999
+ networkId: "solana-devnet",
1000
+ });
1001
+ ```
1002
+
1003
+ #### Environment Variables
1004
+
1005
+ The provider can also be configured using environment variables:
1006
+
1007
+ ```typescript
1008
+ // Environment variables:
1009
+ // CDP_API_KEY_ID=your_api_key_id
1010
+ // CDP_API_KEY_SECRET=your_api_key_secret
1011
+ // CDP_WALLET_SECRET=your_wallet_secret
1012
+ // NETWORK_ID=solana-devnet (optional)
1013
+ // IDEMPOTENCY_KEY=unique-key-123 (optional)
1014
+
1015
+ const walletProvider = await CdpV2SolanaWalletProvider.configureWithWallet();
1016
+ ```
1017
+
1018
+ #### Supported Networks
1019
+
1020
+ The `CdpV2SolanaWalletProvider` supports the following Solana networks:
1021
+ - `solana-mainnet`
1022
+ - `solana-devnet`
1023
+ - `solana-testnet`
1024
+
884
1025
  ### SolanaKeypairWalletProvider
885
1026
 
886
1027
  The `SolanaKeypairWalletProvider` is a wallet provider that uses the API [Solana web3.js](https://solana-labs.github.io/solana-web3.js/).
@@ -931,6 +1072,7 @@ import { PrivyWalletProvider, PrivyWalletConfig } from "@coinbase/agentkit";
931
1072
  const config: PrivyWalletConfig = {
932
1073
  appId: "PRIVY_APP_ID",
933
1074
  appSecret: "PRIVY_APP_SECRET",
1075
+ connection,
934
1076
  chainType: "solana", // optional, defaults to "evm". Make sure to set this to "solana" if you want to use Solana!
935
1077
  networkId: "solana-devnet", // optional, defaults to "solana-devnet"
936
1078
  walletId: "PRIVY_WALLET_ID", // optional, otherwise a new wallet will be created
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ import { Network } from "../../network";
3
+ import { WalletProvider } from "../../wallet-providers";
4
+ import { WalletProviderWithClient } from "../../wallet-providers/cdpV2Shared";
5
+ import { ActionProvider } from "../actionProvider";
6
+ import { RequestFaucetFundsV2Schema } from "./schemas";
7
+ type CdpV2WalletProviderWithClient = WalletProvider & WalletProviderWithClient;
8
+ /**
9
+ * CdpApiActionProvider is an action provider for CDP API.
10
+ *
11
+ * This provider is used for any action that uses the CDP API, but does not require a CDP Wallet.
12
+ */
13
+ export declare class CdpApiV2ActionProvider extends ActionProvider<CdpV2WalletProviderWithClient> {
14
+ /**
15
+ * Constructor for the CdpApiActionProvider class.
16
+ */
17
+ constructor();
18
+ /**
19
+ * Requests test tokens from the faucet for the default address in the wallet.
20
+ *
21
+ * @param walletProvider - The wallet provider to request funds from.
22
+ * @param args - The input arguments for the action.
23
+ * @returns A confirmation message with transaction details.
24
+ */
25
+ faucet(walletProvider: CdpV2WalletProviderWithClient, args: z.infer<typeof RequestFaucetFundsV2Schema>): Promise<string>;
26
+ /**
27
+ * Checks if the Cdp action provider supports the given network.
28
+ *
29
+ * NOTE: Network scoping is done at the action implementation level
30
+ *
31
+ * @param _ - The network to check.
32
+ * @returns True if the Cdp action provider supports the network, false otherwise.
33
+ */
34
+ supportsNetwork: (_: Network) => boolean;
35
+ }
36
+ export declare const cdpApiV2ActionProvider: () => CdpApiV2ActionProvider;
37
+ export {};
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.cdpApiV2ActionProvider = exports.CdpApiV2ActionProvider = void 0;
13
+ const zod_1 = require("zod");
14
+ const actionDecorator_1 = require("../actionDecorator");
15
+ const actionProvider_1 = require("../actionProvider");
16
+ const schemas_1 = require("./schemas");
17
+ /**
18
+ * CdpApiActionProvider is an action provider for CDP API.
19
+ *
20
+ * This provider is used for any action that uses the CDP API, but does not require a CDP Wallet.
21
+ */
22
+ class CdpApiV2ActionProvider extends actionProvider_1.ActionProvider {
23
+ /**
24
+ * Constructor for the CdpApiActionProvider class.
25
+ */
26
+ constructor() {
27
+ super("cdp_api_v2", []);
28
+ /**
29
+ * Checks if the Cdp action provider supports the given network.
30
+ *
31
+ * NOTE: Network scoping is done at the action implementation level
32
+ *
33
+ * @param _ - The network to check.
34
+ * @returns True if the Cdp action provider supports the network, false otherwise.
35
+ */
36
+ this.supportsNetwork = (_) => true;
37
+ }
38
+ /**
39
+ * Requests test tokens from the faucet for the default address in the wallet.
40
+ *
41
+ * @param walletProvider - The wallet provider to request funds from.
42
+ * @param args - The input arguments for the action.
43
+ * @returns A confirmation message with transaction details.
44
+ */
45
+ async faucet(walletProvider, args) {
46
+ const network = walletProvider.getNetwork();
47
+ const networkId = network.networkId;
48
+ if (network.protocolFamily === "evm") {
49
+ if (networkId !== "base-sepolia" && networkId !== "ethereum-sepolia") {
50
+ throw new Error("Faucet is only supported on 'base-sepolia' or 'ethereum-sepolia' evm networks.");
51
+ }
52
+ const faucetTx = await walletProvider.getClient().evm.requestFaucet({
53
+ address: walletProvider.getAddress(),
54
+ token: (args.assetId || "eth"),
55
+ network: networkId,
56
+ });
57
+ return `Received ${args.assetId || "ETH"} from the faucet. Transaction hash: ${faucetTx.transactionHash}`;
58
+ }
59
+ else if (network.protocolFamily === "svm") {
60
+ if (networkId !== "solana-devnet") {
61
+ throw new Error("Faucet is only supported on 'solana-devnet' solana networks.");
62
+ }
63
+ const faucetTx = await walletProvider.getClient().solana.requestFaucet({
64
+ address: walletProvider.getAddress(),
65
+ token: (args.assetId || "sol"),
66
+ });
67
+ return `Received ${args.assetId || "SOL"} from the faucet. Transaction signature hash: ${faucetTx.signature}`;
68
+ }
69
+ else {
70
+ throw new Error("Faucet is only supported on Ethereum and Solana protocol families.");
71
+ }
72
+ }
73
+ }
74
+ exports.CdpApiV2ActionProvider = CdpApiV2ActionProvider;
75
+ __decorate([
76
+ (0, actionDecorator_1.CreateAction)({
77
+ name: "request_faucet_funds",
78
+ description: `This tool will request test tokens from the faucet for the default address in the wallet. It takes the wallet and asset ID as input.
79
+ Faucet is only allowed on 'base-sepolia' or 'solana-devnet'.
80
+ If fauceting on 'base-sepolia', user can only provide asset ID 'eth', 'usdc', 'eurc' or 'cbbtc', if no asset ID is provided, the faucet will default to 'eth'.
81
+ If fauceting on 'solana-devnet', user can only provide asset ID 'sol' or 'usdc', if no asset ID is provided, the faucet will default to 'sol'.
82
+ You are not allowed to faucet with any other network or asset ID. If you are on another network, suggest that the user sends you some ETH
83
+ from another wallet and provide the user with your wallet details.`,
84
+ schema: schemas_1.RequestFaucetFundsV2Schema,
85
+ }),
86
+ __metadata("design:type", Function),
87
+ __metadata("design:paramtypes", [Object, void 0]),
88
+ __metadata("design:returntype", Promise)
89
+ ], CdpApiV2ActionProvider.prototype, "faucet", null);
90
+ const cdpApiV2ActionProvider = () => new CdpApiV2ActionProvider();
91
+ exports.cdpApiV2ActionProvider = cdpApiV2ActionProvider;
@@ -0,0 +1,2 @@
1
+ export * from "./schemas";
2
+ export * from "./cdpApiV2ActionProvider";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./schemas"), exports);
18
+ __exportStar(require("./cdpApiV2ActionProvider"), exports);
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Input schema for request faucet funds action.
4
+ */
5
+ export declare const RequestFaucetFundsV2Schema: z.ZodObject<{
6
+ assetId: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ assetId?: string | undefined;
9
+ }, {
10
+ assetId?: string | undefined;
11
+ }>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestFaucetFundsV2Schema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Input schema for request faucet funds action.
7
+ */
8
+ exports.RequestFaucetFundsV2Schema = zod_1.z
9
+ .object({
10
+ assetId: zod_1.z.string().optional().describe("The optional asset ID to request from faucet"),
11
+ })
12
+ .strip()
13
+ .describe("Instructions for requesting faucet funds");
@@ -7,10 +7,10 @@ export declare const CompoundSupplySchema: z.ZodObject<{
7
7
  amount: z.ZodString;
8
8
  }, "strip", z.ZodTypeAny, {
9
9
  amount: string;
10
- assetId: "weth" | "cbeth" | "cbbtc" | "wsteth" | "usdc";
10
+ assetId: "usdc" | "cbbtc" | "weth" | "cbeth" | "wsteth";
11
11
  }, {
12
12
  amount: string;
13
- assetId: "weth" | "cbeth" | "cbbtc" | "wsteth" | "usdc";
13
+ assetId: "usdc" | "cbbtc" | "weth" | "cbeth" | "wsteth";
14
14
  }>;
15
15
  /**
16
16
  * Input schema for Compound withdraw action.
@@ -20,10 +20,10 @@ export declare const CompoundWithdrawSchema: z.ZodObject<{
20
20
  amount: z.ZodString;
21
21
  }, "strip", z.ZodTypeAny, {
22
22
  amount: string;
23
- assetId: "weth" | "cbeth" | "cbbtc" | "wsteth" | "usdc";
23
+ assetId: "usdc" | "cbbtc" | "weth" | "cbeth" | "wsteth";
24
24
  }, {
25
25
  amount: string;
26
- assetId: "weth" | "cbeth" | "cbbtc" | "wsteth" | "usdc";
26
+ assetId: "usdc" | "cbbtc" | "weth" | "cbeth" | "wsteth";
27
27
  }>;
28
28
  /**
29
29
  * Input schema for Compound borrow action.
@@ -33,10 +33,10 @@ export declare const CompoundBorrowSchema: z.ZodObject<{
33
33
  amount: z.ZodString;
34
34
  }, "strip", z.ZodTypeAny, {
35
35
  amount: string;
36
- assetId: "weth" | "usdc";
36
+ assetId: "usdc" | "weth";
37
37
  }, {
38
38
  amount: string;
39
- assetId: "weth" | "usdc";
39
+ assetId: "usdc" | "weth";
40
40
  }>;
41
41
  /**
42
42
  * Input schema for Compound repay action.
@@ -46,10 +46,10 @@ export declare const CompoundRepaySchema: z.ZodObject<{
46
46
  amount: z.ZodString;
47
47
  }, "strip", z.ZodTypeAny, {
48
48
  amount: string;
49
- assetId: "weth" | "usdc";
49
+ assetId: "usdc" | "weth";
50
50
  }, {
51
51
  amount: string;
52
- assetId: "weth" | "usdc";
52
+ assetId: "usdc" | "weth";
53
53
  }>;
54
54
  /**
55
55
  * Input schema for Compound get portfolio action.
@@ -313,7 +313,7 @@ const ethToMemecoin = (params) => {
313
313
  };
314
314
  };
315
315
  exports.ethToMemecoin = ethToMemecoin;
316
- // @notice Beofre calling the UniversalRouter the user must have:
316
+ // @notice Before calling the UniversalRouter the user must have:
317
317
  // 1. Given the Permit2 contract allowance to spend the memecoin
318
318
  const memecoinToEthWithPermit2 = (params) => {
319
319
  const flETH = constants_1.FLETHAddress[params.chainId];
@@ -5,6 +5,7 @@ export * from "./across";
5
5
  export * from "./alchemy";
6
6
  export * from "./basename";
7
7
  export * from "./cdp";
8
+ export * from "./cdp-v2";
8
9
  export * from "./compound";
9
10
  export * from "./defillama";
10
11
  export * from "./erc20";
@@ -21,6 +21,7 @@ __exportStar(require("./across"), exports);
21
21
  __exportStar(require("./alchemy"), exports);
22
22
  __exportStar(require("./basename"), exports);
23
23
  __exportStar(require("./cdp"), exports);
24
+ __exportStar(require("./cdp-v2"), exports);
24
25
  __exportStar(require("./compound"), exports);
25
26
  __exportStar(require("./defillama"), exports);
26
27
  __exportStar(require("./erc20"), exports);
@@ -29,7 +29,8 @@ export interface TwitterActionProviderConfig {
29
29
  * @augments ActionProvider
30
30
  */
31
31
  export declare class TwitterActionProvider extends ActionProvider {
32
- private readonly client;
32
+ private client;
33
+ private config;
33
34
  /**
34
35
  * Constructor for the TwitterActionProvider class.
35
36
  *
@@ -72,6 +73,12 @@ export declare class TwitterActionProvider extends ActionProvider {
72
73
  * @returns Always returns true as Twitter actions are network-independent
73
74
  */
74
75
  supportsNetwork(_: Network): boolean;
76
+ /**
77
+ * Get the Twitter API client, initializing it if needed
78
+ *
79
+ * @returns The Twitter API client
80
+ */
81
+ private getClient;
75
82
  }
76
83
  /**
77
84
  * Factory function to create a new TwitterActionProvider instance.
@@ -27,29 +27,29 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
27
27
  * @param config - The configuration options for the TwitterActionProvider
28
28
  */
29
29
  constructor(config = {}) {
30
+ var _a, _b, _c, _d;
30
31
  super("twitter", []);
31
- config.apiKey || (config.apiKey = process.env.TWITTER_API_KEY);
32
- config.apiSecret || (config.apiSecret = process.env.TWITTER_API_SECRET);
33
- config.accessToken || (config.accessToken = process.env.TWITTER_ACCESS_TOKEN);
34
- config.accessTokenSecret || (config.accessTokenSecret = process.env.TWITTER_ACCESS_TOKEN_SECRET);
35
- if (!config.apiKey) {
32
+ this.client = null;
33
+ // Store config for later use but don't initialize the client yet
34
+ this.config = { ...config };
35
+ // Set defaults from environment variables
36
+ (_a = this.config).apiKey || (_a.apiKey = process.env.TWITTER_API_KEY);
37
+ (_b = this.config).apiSecret || (_b.apiSecret = process.env.TWITTER_API_SECRET);
38
+ (_c = this.config).accessToken || (_c.accessToken = process.env.TWITTER_ACCESS_TOKEN);
39
+ (_d = this.config).accessTokenSecret || (_d.accessTokenSecret = process.env.TWITTER_ACCESS_TOKEN_SECRET);
40
+ // Validate config
41
+ if (!this.config.apiKey) {
36
42
  throw new Error("TWITTER_API_KEY is not configured.");
37
43
  }
38
- if (!config.apiSecret) {
44
+ if (!this.config.apiSecret) {
39
45
  throw new Error("TWITTER_API_SECRET is not configured.");
40
46
  }
41
- if (!config.accessToken) {
47
+ if (!this.config.accessToken) {
42
48
  throw new Error("TWITTER_ACCESS_TOKEN is not configured.");
43
49
  }
44
- if (!config.accessTokenSecret) {
50
+ if (!this.config.accessTokenSecret) {
45
51
  throw new Error("TWITTER_ACCESS_TOKEN_SECRET is not configured.");
46
52
  }
47
- this.client = new twitter_api_v2_1.TwitterApi({
48
- appKey: config.apiKey,
49
- appSecret: config.apiSecret,
50
- accessToken: config.accessToken,
51
- accessSecret: config.accessTokenSecret,
52
- });
53
53
  }
54
54
  /**
55
55
  * Get account details for the currently authenticated Twitter (X) user.
@@ -59,7 +59,7 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
59
59
  */
60
60
  async accountDetails(_) {
61
61
  try {
62
- const response = await this.client.v2.me();
62
+ const response = await this.getClient().v2.me();
63
63
  response.data.url = `https://x.com/${response.data.username}`;
64
64
  return `Successfully retrieved authenticated user account details:\n${JSON.stringify(response)}`;
65
65
  }
@@ -75,7 +75,7 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
75
75
  */
76
76
  async accountMentions(args) {
77
77
  try {
78
- const response = await this.client.v2.userMentionTimeline(args.userId);
78
+ const response = await this.getClient().v2.userMentionTimeline(args.userId);
79
79
  return `Successfully retrieved account mentions:\n${JSON.stringify(response)}`;
80
80
  }
81
81
  catch (error) {
@@ -90,7 +90,7 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
90
90
  */
91
91
  async postTweet(args) {
92
92
  try {
93
- const response = await this.client.v2.tweet(args.tweet);
93
+ const response = await this.getClient().v2.tweet(args.tweet);
94
94
  return `Successfully posted to Twitter:\n${JSON.stringify(response)}`;
95
95
  }
96
96
  catch (error) {
@@ -105,7 +105,7 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
105
105
  */
106
106
  async postTweetReply(args) {
107
107
  try {
108
- const response = await this.client.v2.tweet(args.tweetReply, {
108
+ const response = await this.getClient().v2.tweet(args.tweetReply, {
109
109
  reply: { in_reply_to_tweet_id: args.tweetId },
110
110
  });
111
111
  return `Successfully posted reply to Twitter:\n${JSON.stringify(response)}`;
@@ -124,6 +124,24 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
124
124
  supportsNetwork(_) {
125
125
  return true;
126
126
  }
127
+ /**
128
+ * Get the Twitter API client, initializing it if needed
129
+ *
130
+ * @returns The Twitter API client
131
+ */
132
+ getClient() {
133
+ if (!this.client) {
134
+ // Initialize client only when needed
135
+ const tokens = {
136
+ appKey: this.config.apiKey,
137
+ appSecret: this.config.apiSecret,
138
+ accessToken: this.config.accessToken,
139
+ accessSecret: this.config.accessTokenSecret,
140
+ };
141
+ this.client = new twitter_api_v2_1.TwitterApi(tokens);
142
+ }
143
+ return this.client;
144
+ }
127
145
  }
128
146
  exports.TwitterActionProvider = TwitterActionProvider;
129
147
  __decorate([
@@ -44,6 +44,24 @@ describe("TwitterActionProvider", () => {
44
44
  delete process.env.TWITTER_ACCESS_TOKEN_SECRET;
45
45
  expect(() => new twitterActionProvider_1.TwitterActionProvider()).toThrow("TWITTER_API_KEY is not configured.");
46
46
  });
47
+ it("should implement lazy initialization", async () => {
48
+ // We'll check lazy initialization by observing that we can create an instance
49
+ // without error, and then use it to call methods successfully
50
+ const provider = new twitterActionProvider_1.TwitterActionProvider(MOCK_CONFIG);
51
+ // Mock a response for accountDetails
52
+ mockClient.me.mockResolvedValue({
53
+ data: {
54
+ id: MOCK_ID,
55
+ name: MOCK_NAME,
56
+ username: MOCK_USERNAME,
57
+ },
58
+ });
59
+ // Call a method that should trigger initialization
60
+ const response = await provider.accountDetails({});
61
+ // Verify the method worked, which means initialization succeeded
62
+ expect(response).toContain("Successfully retrieved authenticated user account details");
63
+ expect(mockClient.me).toHaveBeenCalled();
64
+ });
47
65
  });
48
66
  describe("Account Details Action", () => {
49
67
  const mockResponse = {
@@ -182,4 +200,31 @@ describe("TwitterActionProvider", () => {
182
200
  expect(provider.supportsNetwork({ protocolFamily: "solana", networkId: "2" })).toBe(true);
183
201
  });
184
202
  });
203
+ describe("Next.js Integration", () => {
204
+ it("should work in a simulated Next.js environment", async () => {
205
+ // Create a clean instance of the provider
206
+ const provider = new twitterActionProvider_1.TwitterActionProvider(MOCK_CONFIG);
207
+ // Mock v2.me to test functionality
208
+ const mockResponse = {
209
+ data: {
210
+ id: MOCK_ID,
211
+ name: MOCK_NAME,
212
+ username: MOCK_USERNAME,
213
+ },
214
+ };
215
+ const mockTwitterApi = {
216
+ v2: {
217
+ me: jest.fn().mockResolvedValue(mockResponse),
218
+ },
219
+ };
220
+ // Override the getClient method to return our mocked API
221
+ jest
222
+ .spyOn(provider, "getClient")
223
+ .mockReturnValue(mockTwitterApi);
224
+ // Simulate a Next.js API route calling the provider
225
+ const result = await provider.accountDetails({});
226
+ expect(result).toContain("Successfully retrieved authenticated user account details");
227
+ expect(mockTwitterApi.v2.me).toHaveBeenCalled();
228
+ });
229
+ });
185
230
  });
@@ -3,6 +3,7 @@ export declare const SOLANA_MAINNET_NETWORK_ID = "solana-mainnet";
3
3
  export declare const SOLANA_TESTNET_NETWORK_ID = "solana-testnet";
4
4
  export declare const SOLANA_DEVNET_NETWORK_ID = "solana-devnet";
5
5
  export type SOLANA_NETWORK_ID = typeof SOLANA_MAINNET_NETWORK_ID | typeof SOLANA_TESTNET_NETWORK_ID | typeof SOLANA_DEVNET_NETWORK_ID;
6
+ export declare const SOLANA_NETWORK_IDS: SOLANA_NETWORK_ID[];
6
7
  export declare const SOLANA_PROTOCOL_FAMILY = "svm";
7
8
  export declare const SOLANA_MAINNET_GENESIS_BLOCK_HASH = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
8
9
  export declare const SOLANA_TESTNET_GENESIS_BLOCK_HASH = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY";
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SOLANA_CLUSTER_ID_BY_NETWORK_ID = exports.SOLANA_NETWORKS = exports.SOLANA_DEVNET_NETWORK = exports.SOLANA_TESTNET_NETWORK = exports.SOLANA_MAINNET_NETWORK = exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH = exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH = exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH = exports.SOLANA_PROTOCOL_FAMILY = exports.SOLANA_DEVNET_NETWORK_ID = exports.SOLANA_TESTNET_NETWORK_ID = exports.SOLANA_MAINNET_NETWORK_ID = void 0;
3
+ exports.SOLANA_CLUSTER_ID_BY_NETWORK_ID = exports.SOLANA_NETWORKS = exports.SOLANA_DEVNET_NETWORK = exports.SOLANA_TESTNET_NETWORK = exports.SOLANA_MAINNET_NETWORK = exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH = exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH = exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH = exports.SOLANA_PROTOCOL_FAMILY = exports.SOLANA_NETWORK_IDS = exports.SOLANA_DEVNET_NETWORK_ID = exports.SOLANA_TESTNET_NETWORK_ID = exports.SOLANA_MAINNET_NETWORK_ID = void 0;
4
4
  // CDP Network IDs
5
5
  exports.SOLANA_MAINNET_NETWORK_ID = "solana-mainnet";
6
6
  exports.SOLANA_TESTNET_NETWORK_ID = "solana-testnet";
7
7
  exports.SOLANA_DEVNET_NETWORK_ID = "solana-devnet";
8
+ exports.SOLANA_NETWORK_IDS = [
9
+ exports.SOLANA_MAINNET_NETWORK_ID,
10
+ exports.SOLANA_TESTNET_NETWORK_ID,
11
+ exports.SOLANA_DEVNET_NETWORK_ID,
12
+ ];
8
13
  // AgentKit Protocol Family
9
14
  exports.SOLANA_PROTOCOL_FAMILY = "svm";
10
15
  // Chain IDs - Genesis Block Hashes