diff --git a/.env.example b/.env.example index 5fdc5f578c0..c65fe897752 100644 --- a/.env.example +++ b/.env.example @@ -28,8 +28,8 @@ XAI_MODEL= # For asking Claude stuff ANTHROPIC_API_KEY= -WALLET_SECRET_KEY=2eETRBeJFNfxAmPzTxfRynebRjTYK9WBLeAE5JhfxdzAxjJG8ZCbmHX1WadTRdcEpE7HRELVp6cbCfZFY6Qw9BgR -WALLET_PUBLIC_KEY=DM1fSD9KfdJ2jaSmR9NGpPPVcDzBwsYg1STttYc5Bvay +WALLET_SECRET_KEY=EXAMPLE_WALLET_SECRET_KEY +WALLET_PUBLIC_KEY=EXAMPLE_WALLET_PUBLIC_KEY BIRDEYE_API_KEY= diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..73dae121c2f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,75 @@ +# Contributing to Eliza + +First off, thank you for considering contributing to Eliza! It's people like you that make Eliza such a great tool. We welcome contributions from everyone, regardless of their experience level. + +## Code of Conduct + +By participating in this project, you are expected to uphold our Code of Conduct. Please report unacceptable behavior. + +## How Can I Contribute? + +### Reporting Bugs + +1. Ensure the bug was not already reported by searching on GitHub under [Issues](https://github.com/ai16z/eliza/issues). +2. If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/ai16z/eliza/issues/new). Be sure to include + +- a title and clear description, +- as much relevant information as possible, and +- a code sample or an executable test case demonstrating the expected behavior that is not occurring. + +### Suggesting Enhancements + +1. Open a new issue with a clear title and detailed description of the suggested enhancement. +2. Include any relevant examples or mock-ups if applicable. + +### Pull Requests + +1. Fork the repo and create your branch from `main`. + 1. The name of the branch should start with the issue number and be descriptive of the changes you are making. + 1. eg. 40--add-test-for-bug-123 +2. If you've added code that should be tested, add tests. +3. Ensure the test suite passes. +4. Make sure your code lints. +5. Issue that pull request! + +## Styleguides + +### Git Commit Messages + +- Use the present tense ("Add feature" not "Added feature") +- Use the imperative mood ("Move cursor to..." not "Moves cursor to...") +- Limit the first line to 72 characters or less +- Reference issues and pull requests liberally after the first line + +### JavaScript Styleguide + +- All JavaScript must adhere to [JavaScript Standard Style](https://standardjs.com/). + +### TypeScript Styleguide + +- All TypeScript must adhere to [TypeScript Standard Style](https://github.com/standard/ts-standard). + +### Documentation Styleguide + +- Use [Markdown](https://daringfireball.net/projects/markdown/) for documentation. + +## Additional Notes + +### Issue and Pull Request Labels + +This section lists the labels we use to help us track and manage issues and pull requests. + +- `bug` - Issues that are bugs. +- `enhancement` - Issues that are feature requests. +- `documentation` - Issues or pull requests related to documentation. +- `good first issue` - Good for newcomers. + +## Recognition + +We value every contribution. Contributors will be recognized in our README.md file. Significant contributions may be acknowledged with special roles or responsibilities within the project. + +## Questions? + +If you have any questions, please feel free to contact the project maintainers with an issue or in discord. + +Thank you for your interest in contributing to Eliza! \ No newline at end of file diff --git a/README.md b/README.md index 46240f57e72..2a003a71a8b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ https://docs.npmjs.com/downloading-and-installing-node-js-and-npm ## Edit the character file - Check out the file `src/core/defaultCharacter.ts` - you can modify this -- You can also load characters with the `--charaters=` and run multiple bots at the same time. +- You can also load characters with the `node --loader ts-node/esm src/index.ts --characters="path/to/your/character.json"` and run multiple bots at the same time. ### Linux Installation You might need these @@ -75,7 +75,7 @@ TWITTER_COOKIES= # Account cookies If you have an NVIDIA GPU, you can install CUDA to speed up local inference dramatically. ``` npm install -npx --no node-llama-cpp download --gpu cuda +npx --no node-llama-cpp source download --gpu cuda ``` Make sure that you've installed the CUDA Toolkit, including cuDNN and cuBLAS. diff --git a/package-lock.json b/package-lock.json index 1bee6efaca2..9f49b599810 100644 --- a/package-lock.json +++ b/package-lock.json @@ -74,6 +74,7 @@ "playwright": "^1.46.1", "pm2": "^5.4.2", "prism-media": "^1.3.5", + "pumpdotfun-sdk": "^1.3.2", "puppeteer-extra": "^3.3.6", "puppeteer-extra-plugin-capsolver": "^2.0.1", "sql.js": "^1.10.2", @@ -900,6 +901,96 @@ "node": ">=16.7.0" } }, + "node_modules/@coral-xyz/anchor": { + "version": "0.30.1", + "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.30.1.tgz", + "integrity": "sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ==", + "license": "(MIT OR Apache-2.0)", + "dependencies": { + "@coral-xyz/anchor-errors": "^0.30.1", + "@coral-xyz/borsh": "^0.30.1", + "@noble/hashes": "^1.3.1", + "@solana/web3.js": "^1.68.0", + "bn.js": "^5.1.2", + "bs58": "^4.0.1", + "buffer-layout": "^1.2.2", + "camelcase": "^6.3.0", + "cross-fetch": "^3.1.5", + "crypto-hash": "^1.3.0", + "eventemitter3": "^4.0.7", + "pako": "^2.0.3", + "snake-case": "^3.0.4", + "superstruct": "^0.15.4", + "toml": "^3.0.0" + }, + "engines": { + "node": ">=11" + } + }, + "node_modules/@coral-xyz/anchor-errors": { + "version": "0.30.1", + "resolved": "https://registry.npmjs.org/@coral-xyz/anchor-errors/-/anchor-errors-0.30.1.tgz", + "integrity": "sha512-9Mkradf5yS5xiLWrl9WrpjqOrAV+/W2RQHDlbnAZBivoGpOs1ECjoDCkVk4aRG8ZdiFiB8zQEVlxf+8fKkmSfQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=10" + } + }, + "node_modules/@coral-xyz/anchor/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@coral-xyz/anchor/node_modules/cross-fetch": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", + "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.12" + } + }, + "node_modules/@coral-xyz/anchor/node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", + "license": "MIT" + }, + "node_modules/@coral-xyz/anchor/node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", + "license": "(MIT AND Zlib)" + }, + "node_modules/@coral-xyz/anchor/node_modules/superstruct": { + "version": "0.15.5", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz", + "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==", + "license": "MIT" + }, + "node_modules/@coral-xyz/borsh": { + "version": "0.30.1", + "resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.30.1.tgz", + "integrity": "sha512-aaxswpPrCFKl8vZTbxLssA2RvwX2zmKLlRCIktJOwW+VpVwYtXRtlWiIP+c2pPRKneiTiWCN2GEMSH9j1zTlWQ==", + "license": "Apache-2.0", + "dependencies": { + "bn.js": "^5.1.2", + "buffer-layout": "^1.2.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@solana/web3.js": "^1.68.0" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -3456,7 +3547,6 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", - "dev": true, "license": "MIT", "dependencies": { "@rollup/pluginutils": "^5.1.0" @@ -3552,7 +3642,6 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", - "dev": true, "license": "MIT", "dependencies": { "@types/estree": "^1.0.0", @@ -3881,6 +3970,42 @@ "ieee754": "^1.2.1" } }, + "node_modules/@solana/spl-type-length-value": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@solana/spl-type-length-value/-/spl-type-length-value-0.1.0.tgz", + "integrity": "sha512-JBMGB0oR4lPttOZ5XiUGyvylwLQjt1CPJa6qQ5oM+MBCndfjz2TKKkw0eATlLLcYmq1jBVsNlJ2cD6ns2GR7lA==", + "license": "Apache-2.0", + "dependencies": { + "buffer": "^6.0.3" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@solana/spl-type-length-value/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/@solana/web3.js": { "version": "1.95.4", "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.4.tgz", @@ -4183,7 +4308,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true, "license": "MIT" }, "node_modules/@types/express": { @@ -5784,6 +5908,15 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "license": "MIT" }, + "node_modules/buffer-layout": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.2.tgz", + "integrity": "sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==", + "license": "MIT", + "engines": { + "node": ">=4.5" + } + }, "node_modules/bufferutil": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz", @@ -6735,6 +6868,18 @@ "node": ">= 8" } }, + "node_modules/crypto-hash": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/crypto-hash/-/crypto-hash-1.3.0.tgz", + "integrity": "sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/csv-writer": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/csv-writer/-/csv-writer-1.6.0.tgz", @@ -7255,6 +7400,16 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "license": "MIT", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -7957,7 +8112,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true, "license": "MIT" }, "node_modules/esutils": { @@ -12637,6 +12791,15 @@ "url": "https://github.com/sponsors/typicode" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.3" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -13279,6 +13442,16 @@ "dev": true, "license": "MIT" }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "license": "MIT", + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, "node_modules/node-abi": { "version": "3.67.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.67.0.tgz", @@ -15376,6 +15549,169 @@ "once": "^1.3.1" } }, + "node_modules/pumpdotfun-sdk": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/pumpdotfun-sdk/-/pumpdotfun-sdk-1.3.2.tgz", + "integrity": "sha512-TkYY+ZztxyPzv1f38evgdam92Po3YATI8s6BzmvxH8FypBpPs3pBKS301z7k3KXc1WWfjGWG79K/BANWaAcvkQ==", + "license": "ISC", + "dependencies": { + "@coral-xyz/anchor": "^0.30.1", + "@rollup/plugin-json": "^6.1.0", + "@solana/spl-token": "0.4.6", + "@solana/web3.js": "^1.92.1" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs/-/codecs-2.0.0-preview.2.tgz", + "integrity": "sha512-4HHzCD5+pOSmSB71X6w9ptweV48Zj1Vqhe732+pcAQ2cMNnN0gMPMdDq7j3YwaZDZ7yrILVV/3+HTnfT77t2yA==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-data-structures": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/codecs-strings": "2.0.0-preview.2", + "@solana/options": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs-core": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-core/-/codecs-core-2.0.0-preview.2.tgz", + "integrity": "sha512-gLhCJXieSCrAU7acUJjbXl+IbGnqovvxQLlimztPoGgfLQ1wFYu+XJswrEVQqknZYK1pgxpxH3rZ+OKFs0ndQg==", + "license": "MIT", + "dependencies": { + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs-data-structures": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-preview.2.tgz", + "integrity": "sha512-Xf5vIfromOZo94Q8HbR04TbgTwzigqrKII0GjYr21K7rb3nba4hUW2ir8kguY7HWFBcjHGlU5x3MevKBOLp3Zg==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs-numbers": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-numbers/-/codecs-numbers-2.0.0-preview.2.tgz", + "integrity": "sha512-aLZnDTf43z4qOnpTcDsUVy1Ci9im1Md8thWipSWbE+WM9ojZAx528oAql+Cv8M8N+6ALKwgVRhPZkto6E59ARw==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs-strings": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-strings/-/codecs-strings-2.0.0-preview.2.tgz", + "integrity": "sha512-EgBwY+lIaHHgMJIqVOGHfIfpdmmUDNoNO/GAUGeFPf+q0dF+DtwhJPEMShhzh64X2MeCZcmSO6Kinx0Bvmmz2g==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + }, + "peerDependencies": { + "fastestsmallesttextencoderdecoder": "^1.0.22" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/errors": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/errors/-/errors-2.0.0-preview.2.tgz", + "integrity": "sha512-H2DZ1l3iYF5Rp5pPbJpmmtCauWeQXRJapkDg8epQ8BJ7cA2Ut/QEtC3CMmw/iMTcuS6uemFNLcWvlOfoQhvQuA==", + "license": "MIT", + "dependencies": { + "chalk": "^5.3.0", + "commander": "^12.0.0" + }, + "bin": { + "errors": "bin/cli.js" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/options": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/options/-/options-2.0.0-preview.2.tgz", + "integrity": "sha512-FAHqEeH0cVsUOTzjl5OfUBw2cyT8d5Oekx4xcn5hn+NyPAfQJgM3CEThzgRD6Q/4mM5pVUnND3oK/Mt1RzSE/w==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/spl-token": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.4.6.tgz", + "integrity": "sha512-1nCnUqfHVtdguFciVWaY/RKcQz1IF4b31jnKgAmjU9QVN1q7dRUkTEWJZgTYIEtsULjVnC9jRqlhgGN39WbKKA==", + "license": "Apache-2.0", + "dependencies": { + "@solana/buffer-layout": "^4.0.0", + "@solana/buffer-layout-utils": "^0.2.0", + "@solana/spl-token-group": "^0.0.4", + "@solana/spl-token-metadata": "^0.1.4", + "buffer": "^6.0.3" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.91.6" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/spl-token-group": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@solana/spl-token-group/-/spl-token-group-0.0.4.tgz", + "integrity": "sha512-7+80nrEMdUKlK37V6kOe024+T7J4nNss0F8LQ9OOPYdWCCfJmsGUzVx2W3oeizZR4IHM6N4yC9v1Xqwc3BTPWw==", + "license": "Apache-2.0", + "dependencies": { + "@solana/codecs": "2.0.0-preview.2", + "@solana/spl-type-length-value": "0.1.0" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.91.6" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -16103,7 +16439,7 @@ "version": "2.79.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", - "dev": true, + "devOptional": true, "license": "MIT", "bin": { "rollup": "dist/bin/rollup" @@ -16940,6 +17276,16 @@ "npm": ">= 3.0.0" } }, + "node_modules/snake-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", + "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", + "license": "MIT", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/socks": { "version": "2.8.3", "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", @@ -17980,6 +18326,12 @@ "node": ">=0.6" } }, + "node_modules/toml": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", + "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==", + "license": "MIT" + }, "node_modules/touch": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", diff --git a/package.json b/package.json index ca8cc2a4024..edc15120c5f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "start:service:degen": "pm2 start npm --name=\"degen\" --restart-delay=3000 --max-restarts=10 -- run start:degen", "stop:service:degen": "pm2 stop degen", "start:degen": "node --loader ts-node/esm src/index.ts --characters=\"characters/degenspartan.json\"", - "start:service:all": "pm2 start npm --name=\"degen\" --restart-delay=3000 --max-restarts=10 -- run start:degen", + "start:service:all": "pm2 start npm --name=\"all\" --restart-delay=3000 --max-restarts=10 -- run start:degen", "stop:service:all": "pm2 stop all", "start:all": "node --loader ts-node/esm src/index.ts --characters=\"characters/degenspartan.json\",\"characters/ruby.character.json\"", "start:trump": "node --loader ts-node/esm src/index.ts --characters=\"characters/trump.character.json\"", @@ -130,6 +130,7 @@ "playwright": "^1.46.1", "pm2": "^5.4.2", "prism-media": "^1.3.5", + "pumpdotfun-sdk": "^1.3.2", "puppeteer-extra": "^3.3.6", "puppeteer-extra-plugin-capsolver": "^2.0.1", "sql.js": "^1.10.2", diff --git a/src/actions/pumpfun.ts b/src/actions/pumpfun.ts new file mode 100644 index 00000000000..aec84b39514 --- /dev/null +++ b/src/actions/pumpfun.ts @@ -0,0 +1,299 @@ +import { + Connection, + Keypair, + PublicKey, + LAMPORTS_PER_SOL, +} from "@solana/web3.js"; +import { + DEFAULT_DECIMALS, + PumpFunSDK, + CreateTokenMetadata, + PriorityFee, +} from "pumpdotfun-sdk"; +import { AnchorProvider } from "@coral-xyz/anchor"; +import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet"; + +import settings from "../core/settings"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; + +import { + ActionExample, + IAgentRuntime, + Memory, + Content, + type Action, +} from "../core/types.ts"; + +export interface CreateAndBuyContent extends Content { + deployerPrivateKey: string; + tokenMetadata: CreateTokenMetadata; + buyAmountSol: string | number; + priorityFee: { + unitLimit: number; + unitPrice: number; + }; + allowOffCurve: boolean; +} + +export function isCreateAndBuyContent( + content: any +): content is CreateAndBuyContent { + return ( + typeof content.deployerPrivateKey === "string" && + typeof content.tokenMetadata === "object" && + content.tokenMetadata !== null && + (typeof content.buyAmountSol === "string" || + typeof content.buyAmountSol === "number") && + typeof content.priorityFee === "object" && + content.priorityFee !== null && + typeof content.priorityFee.unitLimit === "number" && + typeof content.priorityFee.unitPrice === "number" && + typeof content.allowOffCurve === "boolean" + ); +} + +const privateKey = settings.WALLET_PRIVATE_KEY!; +const wallet = new NodeWallet( + Keypair.fromSecretKey(new Uint8Array(JSON.parse(privateKey))) +); +const connection = new Connection(settings.RPC_URL!); +const provider = new AnchorProvider(connection, wallet, { + commitment: "finalized", +}); +const sdk = new PumpFunSDK(provider); +const slippage = settings.SLIPPAGE!; + +export const createAndBuyToken = async ({ + deployer, + mint, + tokenMetadata, + buyAmountSol, + priorityFee, + allowOffCurve, + commitment = "finalized", +}: { + deployer: Keypair; + mint: Keypair; + tokenMetadata: CreateTokenMetadata; + buyAmountSol: bigint; + priorityFee: PriorityFee; + allowOffCurve: boolean; + commitment?: + | "processed" + | "confirmed" + | "finalized" + | "recent" + | "single" + | "singleGossip" + | "root" + | "max"; +}) => { + const createResults = await sdk.createAndBuy( + deployer, + mint, + tokenMetadata, + buyAmountSol, + BigInt(slippage), + priorityFee, + commitment + ); + if (createResults.success) { + console.log("Success:", `https://pump.fun/${mint.publicKey.toBase58()}`); + let ata = getAssociatedTokenAddressSync( + mint.publicKey, + deployer.publicKey, + allowOffCurve + ); + const balance = await connection.getTokenAccountBalance(ata, "processed"); + const amount = balance.value.uiAmount; + if (amount === null) { + console.log(`${deployer.publicKey.toBase58()}:`, "No Account Found"); + } else { + console.log(`${deployer.publicKey.toBase58()}:`, amount); + } + } else { + console.log("Create and Buy failed"); + } +}; + +export const buyToken = async ({ + sdk, + buyer, + mint, + amount, + priorityFee, + allowOffCurve, +}: { + sdk: PumpFunSDK; + buyer: Keypair; + mint: PublicKey; + amount: bigint; + priorityFee: PriorityFee; + allowOffCurve: boolean; +}) => { + const buyResults = await sdk.buy( + buyer, + mint, + amount, + BigInt(slippage), + priorityFee + ); + if (buyResults.success) { + console.log("Success:", `https://pump.fun/${mint.toBase58()}`); + let ata = getAssociatedTokenAddressSync( + mint, + buyer.publicKey, + allowOffCurve + ); + const balance = await connection.getTokenAccountBalance(ata, "processed"); + const amount = balance.value.uiAmount; + if (amount === null) { + console.log(`${buyer.publicKey.toBase58()}:`, "No Account Found"); + } else { + console.log(`${buyer.publicKey.toBase58()}:`, amount); + } + } else { + console.log("Buy failed"); + } +}; + +export const sellToken = async ({ + sdk, + seller, + mint, + amount, + priorityFee, + allowOffCurve, +}: { + sdk: PumpFunSDK; + seller: Keypair; + mint: PublicKey; + amount: bigint; + priorityFee: PriorityFee; + allowOffCurve: boolean; +}) => { + const sellResults = await sdk.sell( + seller, + mint, + amount, + BigInt(slippage), + priorityFee + ); + if (sellResults.success) { + console.log("Success:", `https://pump.fun/${mint.toBase58()}`); + let ata = getAssociatedTokenAddressSync( + mint, + seller.publicKey, + allowOffCurve + ); + const balance = await connection.getTokenAccountBalance(ata, "processed"); + const amount = balance.value.uiAmount; + if (amount === null) { + console.log(`${seller.publicKey.toBase58()}:`, "No Account Found"); + } else { + console.log(`${seller.publicKey.toBase58()}:`, amount); + } + } else { + console.log("Sell failed"); + } +}; + +const promptConfirmation = async (): Promise => { + if (typeof window !== "undefined" && typeof window.confirm === "function") { + return window.confirm("Confirm the creation and purchase of the token?"); + } + return true; +}; + +export default { + name: "CREATE_AND_BUY_TOKEN", + similes: ["CREATE_AND_PURCHASE_TOKEN", "DEPLOY_AND_BUY_TOKEN"], + validate: async (runtime: IAgentRuntime, message: Memory) => { + return isCreateAndBuyContent(message.content); + }, + description: + "Create a new token and buy a specified amount using SOL. Requires deployer private key, token metadata, buy amount in SOL, priority fee, and allowOffCurve flag.", + handler: async ( + runtime: IAgentRuntime, + message: Memory + ): Promise => { + const content = message.content; + if (!isCreateAndBuyContent(content)) { + console.error("Invalid content for CREATE_AND_BUY_TOKEN action."); + return false; + } + const { + deployerPrivateKey, + tokenMetadata, + buyAmountSol, + priorityFee, + allowOffCurve, + } = content; + + try { + const deployerKeypair = Keypair.fromSecretKey( + Uint8Array.from(Buffer.from(deployerPrivateKey, "base64")) + ); + + const mintKeypair = Keypair.generate(); + + const createAndBuyConfirmation = await promptConfirmation(); + if (!createAndBuyConfirmation) { + console.log("Create and buy token canceled by user"); + return false; + } + + // Execute Create and Buy + await createAndBuyToken({ + deployer: deployerKeypair, + mint: mintKeypair, + tokenMetadata: tokenMetadata as CreateTokenMetadata, + buyAmountSol: BigInt(buyAmountSol), + priorityFee: priorityFee as PriorityFee, + allowOffCurve: allowOffCurve as boolean, + }); + + console.log( + `Token created and purchased successfully! View at: https://pump.fun/${mintKeypair.publicKey.toBase58()}` + ); + return true; + } catch (error) { + console.error("Error during create and buy token:", error); + return false; + } + }, + + examples: [ + [ + { + user: "{{user1}}", + content: { + deployerPrivateKey: "Base64EncodedPrivateKey", + tokenMetadata: { + name: "MyToken", + symbol: "MTK", + description: "My first token", + file: "Base64EncodedFile", // blob file of the image + decimals: DEFAULT_DECIMALS, + }, + buyAmountSol: "1000000000", // 1 SOL in lamports + priorityFee: 1000, + allowOffCurve: false, + }, + }, + { + user: "{{user2}}", + content: { + text: "Creating and buying 1 SOL worth of MyToken...", + action: "CREATE_AND_BUY_TOKEN", + }, + }, + { + user: "{{user2}}", + content: { + text: "Token created and purchased successfully! View at: https://pump.fun/MintPublicKey", + }, + }, + ], + ] as ActionExample[][], +} as Action; diff --git a/src/clients/twitter/generate.ts b/src/clients/twitter/generate.ts index 773562e107e..428de5f4345 100644 --- a/src/clients/twitter/generate.ts +++ b/src/clients/twitter/generate.ts @@ -35,9 +35,9 @@ export class TwitterGenerationClient extends ClientBase { (Math.floor(Math.random() * (45 - 15 + 1)) + 15) * 60 * 1000, ); // Random interval between 4-8 hours }; - setTimeout(() => { + // setTimeout(() => { generateNewTweetLoop(); - }, 5 * 60 * 1000); // Wait 5 minutes before starting the loop + // }, 5 * 60 * 1000); // Wait 5 minutes before starting the loop } constructor(runtime: IAgentRuntime) { diff --git a/src/core/defaultCharacter.ts b/src/core/defaultCharacter.ts index 16623b47bd8..fd2b0a6e8a7 100644 --- a/src/core/defaultCharacter.ts +++ b/src/core/defaultCharacter.ts @@ -10,16 +10,7 @@ const defaultCharacter: Character = { model: "gpt-4o-mini", embeddingModel: "text-embedding-3-small", secrets: { - DISCORD_APPLICATION_ID: null, - DISCORD_API_TOKEN: null, TWITTER_USERNAME: "eliza__v1", - TWITTER_PASSWORD: null, - TWITTER_EMAIL: null, - PROXY_URL: null, - OPENAI_API_KEY: null, - ELEVENLABS_XI_API_KEY: null, - ANTHROPIC_API_KEY: null, - ELEVENLABS_VOICE_ID: null, ELEVENLABS_VOICE_STABILITY: "0.5", ELEVENLABS_VOICE_SIMILARITY_BOOST: "0.9", ELEVENLABS_VOICE_STYLE: "0.66", diff --git a/src/core/runtime.ts b/src/core/runtime.ts index 263b599b7b8..4a37b60a685 100644 --- a/src/core/runtime.ts +++ b/src/core/runtime.ts @@ -1186,7 +1186,7 @@ Text: ${attachment.text} const shuffledLore = [...this.character.lore].sort( () => Math.random() - 0.5, ); - const selectedLore = shuffledLore.slice(0, 3); + const selectedLore = shuffledLore.slice(0, 10); lore = selectedLore.join("\n"); } diff --git a/src/index.ts b/src/index.ts index d696fa59e7f..f5fc52ff5ce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,6 @@ import unfollow_room from "./actions/unfollow_room.ts"; import unmute_room from "./actions/unmute_room.ts"; import { SqliteDatabaseAdapter } from "./adapters/sqlite.ts"; import { DiscordClient } from "./clients/discord/index.ts"; -//import { TwitterSearchClient } from "./clients/twitter/search.ts"; import DirectClient from "./clients/direct/index.ts"; import { TelegramClient } from "./clients/telegram/src/index.ts"; // Added Telegram import import { defaultActions } from "./core/actions.ts"; @@ -18,10 +17,10 @@ import settings from "./core/settings.ts"; import { Character, IAgentRuntime } from "./core/types.ts"; // Added IAgentRuntime import boredomProvider from "./providers/boredom.ts"; import timeProvider from "./providers/time.ts"; -// import walletProvider from "./providers/wallet.ts"; -//import { TwitterInteractionClient } from "./clients/twitter/interactions.ts"; -//import { TwitterGenerationClient } from "./clients/twitter/generate.ts"; -//import { wait } from "./clients/twitter/utils.ts"; +import { wait } from "./clients/twitter/utils.ts"; +import { TwitterSearchClient } from "./clients/twitter/search.ts"; +import { TwitterInteractionClient } from "./clients/twitter/interactions.ts"; +import { TwitterGenerationClient } from "./clients/twitter/generate.ts"; interface Arguments { character?: string; @@ -86,12 +85,15 @@ if (characterPaths?.length > 0) { async function startAgent(character: Character) { console.log("Starting agent for character " + character.name); + const token = character.settings?.secrets?.OPENAI_API_KEY || + (settings.OPENAI_API_KEY as string) + + console.log("token", token); const db = new SqliteDatabaseAdapter(new Database("./db.sqlite")) const runtime = new AgentRuntime({ databaseAdapter: db, token: - character.settings?.secrets?.OPENAI_API_KEY ?? - (settings.OPENAI_API_KEY as string), + token, serverUrl: "https://api.openai.com/v1", model: "gpt-4o", evaluators: [], @@ -158,22 +160,22 @@ async function startAgent(character: Character) { } } - //async function startTwitter(runtime) { - // console.log("Starting search client"); - // const twitterSearchClient = new TwitterSearchClient(runtime); - // await wait(); - // console.log("Starting interaction client"); - // const twitterInteractionClient = new TwitterInteractionClient(runtime); - // await wait(); - // console.log("Starting generation client"); - // const twitterGenerationClient = new TwitterGenerationClient(runtime); - // - // return { - // twitterInteractionClient, - // twitterSearchClient, - // twitterGenerationClient, - // }; - //} + async function startTwitter(runtime) { + console.log("Starting search client"); + const twitterSearchClient = new TwitterSearchClient(runtime); + await wait(); + console.log("Starting interaction client"); + const twitterInteractionClient = new TwitterInteractionClient(runtime); + await wait(); + console.log("Starting generation client"); + const twitterGenerationClient = new TwitterGenerationClient(runtime); + + return { + twitterInteractionClient, + twitterSearchClient, + twitterGenerationClient, + }; + } if (!character.clients) { return console.error("No clients found for character " + character.name); @@ -200,16 +202,16 @@ async function startAgent(character: Character) { } } - //if (character.clients.map((str) => str.toLowerCase()).includes("twitter")) { - // const { - // twitterInteractionClient, - // twitterSearchClient, - // twitterGenerationClient, - // } = await startTwitter(runtime); - // clients.push( - // twitterInteractionClient, twitterSearchClient, twitterGenerationClient, - // ); - //} + if (character.clients.map((str) => str.toLowerCase()).includes("twitter")) { + const { + twitterInteractionClient, + twitterSearchClient, + twitterGenerationClient, + } = await startTwitter(runtime); + clients.push( + twitterInteractionClient, twitterSearchClient, twitterGenerationClient, + ); + } directClient.registerAgent(directRuntime); @@ -228,10 +230,38 @@ const startAgents = async () => { startAgents(); -// way for user input to quit -const stdin = process.stdin; +import readline from 'readline'; -stdin.resume(); -stdin.setEncoding("utf8"); +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +function chat() { + rl.question('You: ', async (input) => { + if (input.toLowerCase() === 'exit') { + rl.close(); + return; + } + + const agentId = characters[0].name.toLowerCase(); // Assuming we're using the first character + const response = await fetch(`http://localhost:3000/${agentId}/message`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + text: input, + userId: 'user', + userName: 'User', + }), + }); + + const data = await response.json(); + console.log(`${characters[0].name}: ${data.text}`); + chat(); + }); +} -console.log("Press Ctrl+C to quit"); \ No newline at end of file +console.log("Chat started. Type 'exit' to quit."); +chat();