@pocketagent/paw 1.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.
Files changed (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +307 -0
  3. package/dist/cli/commands/address.d.ts +3 -0
  4. package/dist/cli/commands/address.d.ts.map +1 -0
  5. package/dist/cli/commands/address.js +32 -0
  6. package/dist/cli/commands/address.js.map +1 -0
  7. package/dist/cli/commands/balance.d.ts +3 -0
  8. package/dist/cli/commands/balance.d.ts.map +1 -0
  9. package/dist/cli/commands/balance.js +76 -0
  10. package/dist/cli/commands/balance.js.map +1 -0
  11. package/dist/cli/commands/config.d.ts +3 -0
  12. package/dist/cli/commands/config.d.ts.map +1 -0
  13. package/dist/cli/commands/config.js +90 -0
  14. package/dist/cli/commands/config.js.map +1 -0
  15. package/dist/cli/commands/dashboard.d.ts +3 -0
  16. package/dist/cli/commands/dashboard.d.ts.map +1 -0
  17. package/dist/cli/commands/dashboard.js +224 -0
  18. package/dist/cli/commands/dashboard.js.map +1 -0
  19. package/dist/cli/commands/history.d.ts +3 -0
  20. package/dist/cli/commands/history.d.ts.map +1 -0
  21. package/dist/cli/commands/history.js +103 -0
  22. package/dist/cli/commands/history.js.map +1 -0
  23. package/dist/cli/commands/init.d.ts +3 -0
  24. package/dist/cli/commands/init.d.ts.map +1 -0
  25. package/dist/cli/commands/init.js +62 -0
  26. package/dist/cli/commands/init.js.map +1 -0
  27. package/dist/cli/commands/send.d.ts +3 -0
  28. package/dist/cli/commands/send.d.ts.map +1 -0
  29. package/dist/cli/commands/send.js +65 -0
  30. package/dist/cli/commands/send.js.map +1 -0
  31. package/dist/cli/commands/swap.d.ts +3 -0
  32. package/dist/cli/commands/swap.d.ts.map +1 -0
  33. package/dist/cli/commands/swap.js +123 -0
  34. package/dist/cli/commands/swap.js.map +1 -0
  35. package/dist/cli/commands/tokens.d.ts +3 -0
  36. package/dist/cli/commands/tokens.d.ts.map +1 -0
  37. package/dist/cli/commands/tokens.js +97 -0
  38. package/dist/cli/commands/tokens.js.map +1 -0
  39. package/dist/cli/index.d.ts +3 -0
  40. package/dist/cli/index.d.ts.map +1 -0
  41. package/dist/cli/index.js +31 -0
  42. package/dist/cli/index.js.map +1 -0
  43. package/dist/core/crypto/machine-identity.d.ts +26 -0
  44. package/dist/core/crypto/machine-identity.d.ts.map +1 -0
  45. package/dist/core/crypto/machine-identity.js +87 -0
  46. package/dist/core/crypto/machine-identity.js.map +1 -0
  47. package/dist/core/signer/engine.d.ts +17 -0
  48. package/dist/core/signer/engine.d.ts.map +1 -0
  49. package/dist/core/signer/engine.js +81 -0
  50. package/dist/core/signer/engine.js.map +1 -0
  51. package/dist/core/storage/encryption.d.ts +23 -0
  52. package/dist/core/storage/encryption.d.ts.map +1 -0
  53. package/dist/core/storage/encryption.js +79 -0
  54. package/dist/core/storage/encryption.js.map +1 -0
  55. package/dist/core/storage/filesystem.d.ts +68 -0
  56. package/dist/core/storage/filesystem.d.ts.map +1 -0
  57. package/dist/core/storage/filesystem.js +189 -0
  58. package/dist/core/storage/filesystem.js.map +1 -0
  59. package/dist/core/wallet/manager.d.ts +30 -0
  60. package/dist/core/wallet/manager.d.ts.map +1 -0
  61. package/dist/core/wallet/manager.js +98 -0
  62. package/dist/core/wallet/manager.js.map +1 -0
  63. package/dist/index.d.ts +10 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +19 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/integrations/jupiter/client.d.ts +62 -0
  68. package/dist/integrations/jupiter/client.d.ts.map +1 -0
  69. package/dist/integrations/jupiter/client.js +143 -0
  70. package/dist/integrations/jupiter/client.js.map +1 -0
  71. package/dist/types/transaction.d.ts +23 -0
  72. package/dist/types/transaction.d.ts.map +1 -0
  73. package/dist/types/transaction.js +3 -0
  74. package/dist/types/transaction.js.map +1 -0
  75. package/dist/types/wallet.d.ts +31 -0
  76. package/dist/types/wallet.d.ts.map +1 -0
  77. package/dist/types/wallet.js +3 -0
  78. package/dist/types/wallet.js.map +1 -0
  79. package/dist/utils/price.d.ts +12 -0
  80. package/dist/utils/price.d.ts.map +1 -0
  81. package/dist/utils/price.js +45 -0
  82. package/dist/utils/price.js.map +1 -0
  83. package/dist/utils/solana.d.ts +22 -0
  84. package/dist/utils/solana.d.ts.map +1 -0
  85. package/dist/utils/solana.js +85 -0
  86. package/dist/utils/solana.js.map +1 -0
  87. package/package.json +80 -0
  88. package/skills/SKILLS.md +393 -0
@@ -0,0 +1,68 @@
1
+ import { EncryptedKeypair } from '../../types/wallet';
2
+ export declare class FileSystemStorage {
3
+ private static readonly PAW_DIR;
4
+ private static readonly AGENTS_DIR;
5
+ /**
6
+ * Get the directory path for an agent
7
+ */
8
+ static getAgentDir(agentId: string): string;
9
+ /**
10
+ * Get the keypair file path for an agent
11
+ */
12
+ static getKeypairPath(agentId: string): string;
13
+ /**
14
+ * Get the passphrase file path for an agent
15
+ */
16
+ static getPassphrasePath(agentId: string): string;
17
+ /**
18
+ * Get the config file path for an agent
19
+ */
20
+ static getConfigPath(agentId: string): string;
21
+ /**
22
+ * Check if an agent wallet exists
23
+ */
24
+ static exists(agentId: string): Promise<boolean>;
25
+ /**
26
+ * Create agent directory if it doesn't exist
27
+ */
28
+ static ensureAgentDir(agentId: string): Promise<void>;
29
+ /**
30
+ * Save encrypted keypair to disk
31
+ */
32
+ static saveKeypair(agentId: string, encryptedKeypair: EncryptedKeypair): Promise<void>;
33
+ /**
34
+ * Load encrypted keypair from disk
35
+ */
36
+ static loadKeypair(agentId: string): Promise<EncryptedKeypair>;
37
+ /**
38
+ * Save agent configuration
39
+ */
40
+ static saveConfig(agentId: string, config: any): Promise<void>;
41
+ /**
42
+ * Load agent configuration
43
+ */
44
+ static loadConfig(agentId: string): Promise<any>;
45
+ /**
46
+ * Delete agent wallet
47
+ */
48
+ static deleteAgent(agentId: string): Promise<void>;
49
+ /**
50
+ * List all agent IDs
51
+ */
52
+ static listAgents(): Promise<string[]>;
53
+ /**
54
+ * Save passphrase (encrypted with machine-specific key)
55
+ * Passphrase is NEVER stored in plaintext!
56
+ */
57
+ static savePassphrase(agentId: string, passphrase: string): Promise<void>;
58
+ /**
59
+ * Load passphrase (decrypt with machine-specific key)
60
+ * Only works on the same machine where it was saved
61
+ */
62
+ static loadPassphrase(agentId: string): Promise<string>;
63
+ /**
64
+ * Check if passphrase file exists
65
+ */
66
+ static hasPassphrase(agentId: string): Promise<boolean>;
67
+ }
68
+ //# sourceMappingURL=filesystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../../src/core/storage/filesystem.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAClE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAGhC;IAEF;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI3C;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI9C;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAIjD;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI7C;;OAEG;WACU,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAStD;;OAEG;WACU,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3D;;OAEG;WACU,WAAW,CACtB,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,IAAI,CAAC;IAehB;;OAEG;WACU,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAapE;;OAEG;WACU,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpE;;OAEG;WACU,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAMtD;;OAEG;WACU,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxD;;OAEG;WACU,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAS5C;;;OAGG;WACU,cAAc,CACzB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAWhB;;;OAGG;WACU,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAU7D;;OAEG;WACU,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAQ9D"}
@@ -0,0 +1,189 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.FileSystemStorage = void 0;
40
+ const promises_1 = __importDefault(require("fs/promises"));
41
+ const path_1 = __importDefault(require("path"));
42
+ const os_1 = __importDefault(require("os"));
43
+ class FileSystemStorage {
44
+ /**
45
+ * Get the directory path for an agent
46
+ */
47
+ static getAgentDir(agentId) {
48
+ return path_1.default.join(FileSystemStorage.AGENTS_DIR, agentId);
49
+ }
50
+ /**
51
+ * Get the keypair file path for an agent
52
+ */
53
+ static getKeypairPath(agentId) {
54
+ return path_1.default.join(FileSystemStorage.getAgentDir(agentId), 'keypair.enc');
55
+ }
56
+ /**
57
+ * Get the passphrase file path for an agent
58
+ */
59
+ static getPassphrasePath(agentId) {
60
+ return path_1.default.join(FileSystemStorage.getAgentDir(agentId), '.passphrase');
61
+ }
62
+ /**
63
+ * Get the config file path for an agent
64
+ */
65
+ static getConfigPath(agentId) {
66
+ return path_1.default.join(FileSystemStorage.getAgentDir(agentId), 'config.json');
67
+ }
68
+ /**
69
+ * Check if an agent wallet exists
70
+ */
71
+ static async exists(agentId) {
72
+ try {
73
+ await promises_1.default.access(FileSystemStorage.getKeypairPath(agentId));
74
+ return true;
75
+ }
76
+ catch {
77
+ return false;
78
+ }
79
+ }
80
+ /**
81
+ * Create agent directory if it doesn't exist
82
+ */
83
+ static async ensureAgentDir(agentId) {
84
+ const agentDir = FileSystemStorage.getAgentDir(agentId);
85
+ await promises_1.default.mkdir(agentDir, { recursive: true });
86
+ }
87
+ /**
88
+ * Save encrypted keypair to disk
89
+ */
90
+ static async saveKeypair(agentId, encryptedKeypair) {
91
+ await FileSystemStorage.ensureAgentDir(agentId);
92
+ // Combine all components into single buffer
93
+ const data = Buffer.concat([
94
+ encryptedKeypair.salt,
95
+ encryptedKeypair.iv,
96
+ encryptedKeypair.encrypted,
97
+ encryptedKeypair.authTag,
98
+ ]);
99
+ const keypairPath = FileSystemStorage.getKeypairPath(agentId);
100
+ await promises_1.default.writeFile(keypairPath, data, { mode: 0o600 }); // Read/write for owner only
101
+ }
102
+ /**
103
+ * Load encrypted keypair from disk
104
+ */
105
+ static async loadKeypair(agentId) {
106
+ const keypairPath = FileSystemStorage.getKeypairPath(agentId);
107
+ const data = await promises_1.default.readFile(keypairPath);
108
+ // Extract components
109
+ const salt = data.slice(0, 32);
110
+ const iv = data.slice(32, 48);
111
+ const encrypted = data.slice(48, data.length - 16);
112
+ const authTag = data.slice(data.length - 16);
113
+ return { salt, iv, encrypted, authTag };
114
+ }
115
+ /**
116
+ * Save agent configuration
117
+ */
118
+ static async saveConfig(agentId, config) {
119
+ await FileSystemStorage.ensureAgentDir(agentId);
120
+ const configPath = FileSystemStorage.getConfigPath(agentId);
121
+ await promises_1.default.writeFile(configPath, JSON.stringify(config, null, 2));
122
+ }
123
+ /**
124
+ * Load agent configuration
125
+ */
126
+ static async loadConfig(agentId) {
127
+ const configPath = FileSystemStorage.getConfigPath(agentId);
128
+ const data = await promises_1.default.readFile(configPath, 'utf-8');
129
+ return JSON.parse(data);
130
+ }
131
+ /**
132
+ * Delete agent wallet
133
+ */
134
+ static async deleteAgent(agentId) {
135
+ const agentDir = FileSystemStorage.getAgentDir(agentId);
136
+ await promises_1.default.rm(agentDir, { recursive: true, force: true });
137
+ }
138
+ /**
139
+ * List all agent IDs
140
+ */
141
+ static async listAgents() {
142
+ try {
143
+ const agents = await promises_1.default.readdir(FileSystemStorage.AGENTS_DIR);
144
+ return agents;
145
+ }
146
+ catch {
147
+ return [];
148
+ }
149
+ }
150
+ /**
151
+ * Save passphrase (encrypted with machine-specific key)
152
+ * Passphrase is NEVER stored in plaintext!
153
+ */
154
+ static async savePassphrase(agentId, passphrase) {
155
+ const { MachineIdentity } = await Promise.resolve().then(() => __importStar(require('../crypto/machine-identity')));
156
+ // Encrypt passphrase with machine-specific key
157
+ const encrypted = MachineIdentity.encrypt(passphrase);
158
+ // Save encrypted passphrase
159
+ const passphrasePath = FileSystemStorage.getPassphrasePath(agentId);
160
+ await promises_1.default.writeFile(passphrasePath, encrypted, { mode: 0o600 });
161
+ }
162
+ /**
163
+ * Load passphrase (decrypt with machine-specific key)
164
+ * Only works on the same machine where it was saved
165
+ */
166
+ static async loadPassphrase(agentId) {
167
+ const { MachineIdentity } = await Promise.resolve().then(() => __importStar(require('../crypto/machine-identity')));
168
+ const passphrasePath = FileSystemStorage.getPassphrasePath(agentId);
169
+ const encrypted = await promises_1.default.readFile(passphrasePath, 'utf-8');
170
+ // Decrypt with machine-specific key
171
+ return MachineIdentity.decrypt(encrypted);
172
+ }
173
+ /**
174
+ * Check if passphrase file exists
175
+ */
176
+ static async hasPassphrase(agentId) {
177
+ try {
178
+ await promises_1.default.access(FileSystemStorage.getPassphrasePath(agentId));
179
+ return true;
180
+ }
181
+ catch {
182
+ return false;
183
+ }
184
+ }
185
+ }
186
+ exports.FileSystemStorage = FileSystemStorage;
187
+ FileSystemStorage.PAW_DIR = path_1.default.join(os_1.default.homedir(), '.paw');
188
+ FileSystemStorage.AGENTS_DIR = path_1.default.join(FileSystemStorage.PAW_DIR, 'agents');
189
+ //# sourceMappingURL=filesystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../../../src/core/storage/filesystem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6B;AAC7B,gDAAwB;AACxB,4CAAoB;AAGpB,MAAa,iBAAiB;IAO5B;;OAEG;IACH,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AC,CAAC;QACpE,MAAM,kBAAE,CAAC,SAAS,CAAC,cAAc,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,OAAe;QACzC,MAAM,EAAE,eAAe,EAAE,GAAG,wDAAa,4BAA4B,GAAC,CAAC;QAEvE,MAAM,cAAc,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,SAAS,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAE7D,oCAAoC;QACpC,OAAO,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,OAAe;QACxC,IAAI,CAAC;YACH,MAAM,kBAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;;AA5KH,8CA6KC;AA5KyB,yBAAO,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;AAC1C,4BAAU,GAAG,cAAI,CAAC,IAAI,CAC5C,iBAAiB,CAAC,OAAO,EACzB,QAAQ,CACT,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Keypair } from '@solana/web3.js';
2
+ import { WalletConfig, WalletInfo } from '../../types/wallet';
3
+ export declare class WalletManager {
4
+ /**
5
+ * Create a new wallet for an agent
6
+ */
7
+ static createWallet(config: WalletConfig): Promise<WalletInfo>;
8
+ /**
9
+ * Load wallet info for an agent
10
+ */
11
+ static getWalletInfo(agentId: string): Promise<WalletInfo>;
12
+ /**
13
+ * Load keypair (decrypted in memory)
14
+ */
15
+ static loadKeypair(agentId: string, passphrase: string): Promise<Keypair>;
16
+ /**
17
+ * Load keypair automatically using saved passphrase
18
+ * Passphrase is encrypted with machine-specific key
19
+ */
20
+ static loadKeypairAuto(agentId: string): Promise<Keypair>;
21
+ /**
22
+ * Delete a wallet
23
+ */
24
+ static deleteWallet(agentId: string): Promise<void>;
25
+ /**
26
+ * List all wallets
27
+ */
28
+ static listWallets(): Promise<string[]>;
29
+ }
30
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/core/wallet/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAa,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAI9D,qBAAa,aAAa;IACxB;;OAEG;WACU,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;IAiDpE;;OAEG;WACU,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAehE;;OAEG;WACU,WAAW,CACtB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC;IASnB;;;OAGG;WACU,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAa/D;;OAEG;WACU,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD;;OAEG;WACU,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAG9C"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletManager = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const encryption_1 = require("../storage/encryption");
6
+ const filesystem_1 = require("../storage/filesystem");
7
+ class WalletManager {
8
+ /**
9
+ * Create a new wallet for an agent
10
+ */
11
+ static async createWallet(config) {
12
+ const { agentId, passphrase } = config;
13
+ // Check if wallet already exists
14
+ if (await filesystem_1.FileSystemStorage.exists(agentId)) {
15
+ throw new Error(`Wallet for agent "${agentId}" already exists`);
16
+ }
17
+ // Generate passphrase if not provided
18
+ const finalPassphrase = passphrase || encryption_1.EncryptionService.generatePassphrase();
19
+ // Generate new keypair
20
+ const keypair = web3_js_1.Keypair.generate();
21
+ // Encrypt keypair
22
+ const encryptedKeypair = encryption_1.EncryptionService.encrypt(keypair, finalPassphrase);
23
+ // Save encrypted keypair to disk
24
+ await filesystem_1.FileSystemStorage.saveKeypair(agentId, encryptedKeypair);
25
+ // Save passphrase (encrypted with machine-specific key)
26
+ // This is NOT plaintext! It's encrypted so only this machine can decrypt it
27
+ await filesystem_1.FileSystemStorage.savePassphrase(agentId, finalPassphrase);
28
+ // Save config
29
+ await filesystem_1.FileSystemStorage.saveConfig(agentId, {
30
+ agentId,
31
+ publicKey: keypair.publicKey.toBase58(),
32
+ createdAt: new Date().toISOString(),
33
+ network: config.network || 'mainnet-beta',
34
+ });
35
+ const walletInfo = {
36
+ agentId,
37
+ publicKey: keypair.publicKey,
38
+ address: keypair.publicKey.toBase58(),
39
+ createdAt: new Date(),
40
+ };
41
+ // Clear keypair from memory
42
+ encryption_1.EncryptionService.clearKeypair(keypair);
43
+ return walletInfo;
44
+ }
45
+ /**
46
+ * Load wallet info for an agent
47
+ */
48
+ static async getWalletInfo(agentId) {
49
+ if (!(await filesystem_1.FileSystemStorage.exists(agentId))) {
50
+ throw new Error(`Wallet for agent "${agentId}" not found`);
51
+ }
52
+ const config = await filesystem_1.FileSystemStorage.loadConfig(agentId);
53
+ return {
54
+ agentId: config.agentId,
55
+ publicKey: new web3_js_1.PublicKey(config.publicKey),
56
+ address: config.publicKey,
57
+ createdAt: new Date(config.createdAt),
58
+ };
59
+ }
60
+ /**
61
+ * Load keypair (decrypted in memory)
62
+ */
63
+ static async loadKeypair(agentId, passphrase) {
64
+ if (!(await filesystem_1.FileSystemStorage.exists(agentId))) {
65
+ throw new Error(`Wallet for agent "${agentId}" not found`);
66
+ }
67
+ const encryptedKeypair = await filesystem_1.FileSystemStorage.loadKeypair(agentId);
68
+ return encryption_1.EncryptionService.decrypt(encryptedKeypair, passphrase);
69
+ }
70
+ /**
71
+ * Load keypair automatically using saved passphrase
72
+ * Passphrase is encrypted with machine-specific key
73
+ */
74
+ static async loadKeypairAuto(agentId) {
75
+ if (!(await filesystem_1.FileSystemStorage.exists(agentId))) {
76
+ throw new Error(`Wallet for agent "${agentId}" not found`);
77
+ }
78
+ // Load encrypted passphrase and decrypt it
79
+ const passphrase = await filesystem_1.FileSystemStorage.loadPassphrase(agentId);
80
+ // Load and decrypt keypair
81
+ const encryptedKeypair = await filesystem_1.FileSystemStorage.loadKeypair(agentId);
82
+ return encryption_1.EncryptionService.decrypt(encryptedKeypair, passphrase);
83
+ }
84
+ /**
85
+ * Delete a wallet
86
+ */
87
+ static async deleteWallet(agentId) {
88
+ await filesystem_1.FileSystemStorage.deleteAgent(agentId);
89
+ }
90
+ /**
91
+ * List all wallets
92
+ */
93
+ static async listWallets() {
94
+ return filesystem_1.FileSystemStorage.listAgents();
95
+ }
96
+ }
97
+ exports.WalletManager = WalletManager;
98
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/core/wallet/manager.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AAErD,sDAA0D;AAC1D,sDAA0D;AAE1D,MAAa,aAAa;IACxB;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAoB;QAC5C,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAEvC,iCAAiC;QACjC,IAAI,MAAM,8BAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,qBAAqB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Y,CAAC,OAAe;QACvC,MAAM,8BAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW;QACtB,OAAO,8BAAiB,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;CACF;AApHD,sCAoHC"}
@@ -0,0 +1,10 @@
1
+ export { WalletManager } from './core/wallet/manager';
2
+ export { SignerEngine } from './core/signer/engine';
3
+ export { EncryptionService } from './core/storage/encryption';
4
+ export { FileSystemStorage } from './core/storage/filesystem';
5
+ export { MachineIdentity } from './core/crypto/machine-identity';
6
+ export { SolanaClient } from './utils/solana';
7
+ export { JupiterClient } from './integrations/jupiter/client';
8
+ export type { WalletConfig, WalletInfo, Balance, TokenBalance, EncryptedKeypair, } from './types/wallet';
9
+ export type { SwapParams, SwapResult, SendParams, SendResult, } from './types/transaction';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,YAAY,EACV,YAAY,EACZ,UAAU,EACV,OAAO,EACP,YAAY,EACZ,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JupiterClient = exports.SolanaClient = exports.MachineIdentity = exports.FileSystemStorage = exports.EncryptionService = exports.SignerEngine = exports.WalletManager = void 0;
4
+ // Core exports for programmatic use
5
+ var manager_1 = require("./core/wallet/manager");
6
+ Object.defineProperty(exports, "WalletManager", { enumerable: true, get: function () { return manager_1.WalletManager; } });
7
+ var engine_1 = require("./core/signer/engine");
8
+ Object.defineProperty(exports, "SignerEngine", { enumerable: true, get: function () { return engine_1.SignerEngine; } });
9
+ var encryption_1 = require("./core/storage/encryption");
10
+ Object.defineProperty(exports, "EncryptionService", { enumerable: true, get: function () { return encryption_1.EncryptionService; } });
11
+ var filesystem_1 = require("./core/storage/filesystem");
12
+ Object.defineProperty(exports, "FileSystemStorage", { enumerable: true, get: function () { return filesystem_1.FileSystemStorage; } });
13
+ var machine_identity_1 = require("./core/crypto/machine-identity");
14
+ Object.defineProperty(exports, "MachineIdentity", { enumerable: true, get: function () { return machine_identity_1.MachineIdentity; } });
15
+ var solana_1 = require("./utils/solana");
16
+ Object.defineProperty(exports, "SolanaClient", { enumerable: true, get: function () { return solana_1.SolanaClient; } });
17
+ var client_1 = require("./integrations/jupiter/client");
18
+ Object.defineProperty(exports, "JupiterClient", { enumerable: true, get: function () { return client_1.JupiterClient; } });
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,iDAAsD;AAA7C,wGAAA,aAAa,OAAA;AACtB,+CAAoD;AAA3C,sGAAA,YAAY,OAAA;AACrB,wDAA8D;AAArD,+GAAA,iBAAiB,OAAA;AAC1B,wDAA8D;AAArD,+GAAA,iBAAiB,OAAA;AAC1B,mEAAiE;AAAxD,mHAAA,eAAe,OAAA;AACxB,yCAA8C;AAArC,sGAAA,YAAY,OAAA;AACrB,wDAA8D;AAArD,uGAAA,aAAa,OAAA"}
@@ -0,0 +1,62 @@
1
+ interface QuoteResponse {
2
+ inputMint: string;
3
+ inAmount: string;
4
+ outputMint: string;
5
+ outAmount: string;
6
+ otherAmountThreshold: string;
7
+ swapMode: string;
8
+ slippageBps: number;
9
+ priceImpactPct: string;
10
+ routePlan: any[];
11
+ }
12
+ export declare class JupiterClient {
13
+ private static readonly API_BASE;
14
+ private static readonly TOKEN_API;
15
+ private static tokenListCache;
16
+ /**
17
+ * Get list of all tokens supported by Jupiter
18
+ */
19
+ static getTokenList(): Promise<any[]>;
20
+ /**
21
+ * Search for a token by symbol or address
22
+ */
23
+ static findToken(symbolOrAddress: string): Promise<any | null>;
24
+ /**
25
+ * Get a quote for swapping tokens (with optional referral fee)
26
+ */
27
+ static getQuote(inputMint: string, outputMint: string, amount: number, slippageBps?: number, options?: {
28
+ userPublicKey?: string;
29
+ referralAccount?: string;
30
+ referralFee?: number;
31
+ }): Promise<any>;
32
+ /**
33
+ * Get swap transaction
34
+ */
35
+ static getSwapTransaction(quote: QuoteResponse, userPublicKey: string, priorityFeeLamports?: number): Promise<string>;
36
+ /**
37
+ * Execute a swap using Ultra API
38
+ */
39
+ static executeSwap(orderResponse: any, keypair: any): Promise<{
40
+ signature: string;
41
+ status: string;
42
+ }>;
43
+ /**
44
+ * Load referral configuration (FOUNDER'S referral account)
45
+ * This is hardcoded so the founder earns on all swaps
46
+ */
47
+ static loadReferralConfig(): {
48
+ referralAccount: string;
49
+ referralFee: number;
50
+ } | null;
51
+ /**
52
+ * Common token addresses on Solana
53
+ */
54
+ static readonly TOKENS: {
55
+ SOL: string;
56
+ USDC: string;
57
+ USDT: string;
58
+ BONK: string;
59
+ };
60
+ }
61
+ export {};
62
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/integrations/jupiter/client.ts"],"names":[],"mappings":"AAEA,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CA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I;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAWpF;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM;;;;;MAKpB;CACH"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JupiterClient = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ class JupiterClient {
6
+ /**
7
+ * Get list of all tokens supported by Jupiter
8
+ */
9
+ static async getTokenList() {
10
+ const response = await fetch(`${JupiterClient.TOKEN_API}/search?query=`);
11
+ if (!response.ok) {
12
+ throw new Error(`Jupiter token list error: ${response.statusText}`);
13
+ }
14
+ return (await response.json());
15
+ }
16
+ /**
17
+ * Search for a token by symbol or address
18
+ */
19
+ static async findToken(symbolOrAddress) {
20
+ // Search using the new API
21
+ const response = await fetch(`${JupiterClient.TOKEN_API}/search?query=${encodeURIComponent(symbolOrAddress)}`);
22
+ if (!response.ok) {
23
+ return null;
24
+ }
25
+ const tokens = (await response.json());
26
+ if (!tokens || tokens.length === 0) {
27
+ return null;
28
+ }
29
+ // Find exact match by symbol or id (address)
30
+ const exactMatch = tokens.find((t) => t.symbol?.toUpperCase() === symbolOrAddress.toUpperCase() ||
31
+ t.id === symbolOrAddress);
32
+ // Return exact match or first result, normalizing to use 'address' field
33
+ const token = exactMatch || tokens[0];
34
+ if (token && !token.address && token.id) {
35
+ token.address = token.id; // Normalize: add 'address' field from 'id'
36
+ }
37
+ return token;
38
+ }
39
+ /**
40
+ * Get a quote for swapping tokens (with optional referral fee)
41
+ */
42
+ static async getQuote(inputMint, outputMint, amount, slippageBps = 50, options) {
43
+ const params = new URLSearchParams({
44
+ inputMint,
45
+ outputMint,
46
+ amount: amount.toString(),
47
+ slippageBps: slippageBps.toString(),
48
+ });
49
+ // Add optional parameters for referral fees
50
+ if (options?.userPublicKey) {
51
+ params.append('taker', options.userPublicKey);
52
+ }
53
+ if (options?.referralAccount) {
54
+ params.append('referralAccount', options.referralAccount);
55
+ }
56
+ if (options?.referralFee) {
57
+ params.append('referralFee', options.referralFee.toString());
58
+ }
59
+ const response = await fetch(`${JupiterClient.API_BASE}/order?${params}`);
60
+ if (!response.ok) {
61
+ throw new Error(`Jupiter API error: ${response.statusText}`);
62
+ }
63
+ return await response.json();
64
+ }
65
+ /**
66
+ * Get swap transaction
67
+ */
68
+ static async getSwapTransaction(quote, userPublicKey, priorityFeeLamports) {
69
+ const swapRequest = {
70
+ quoteResponse: quote,
71
+ userPublicKey,
72
+ wrapAndUnwrapSol: true,
73
+ dynamicComputeUnitLimit: true,
74
+ prioritizationFeeLamports: priorityFeeLamports || 'auto',
75
+ };
76
+ const response = await fetch(`${JupiterClient.API_BASE}/swap`, {
77
+ method: 'POST',
78
+ headers: {
79
+ 'Content-Type': 'application/json',
80
+ },
81
+ body: JSON.stringify(swapRequest),
82
+ });
83
+ if (!response.ok) {
84
+ throw new Error(`Jupiter swap error: ${response.statusText}`);
85
+ }
86
+ const result = (await response.json());
87
+ return result.swapTransaction;
88
+ }
89
+ /**
90
+ * Execute a swap using Ultra API
91
+ */
92
+ static async executeSwap(orderResponse, keypair) {
93
+ // Deserialize and sign transaction
94
+ const transactionBuf = Buffer.from(orderResponse.transaction, 'base64');
95
+ const transaction = web3_js_1.VersionedTransaction.deserialize(transactionBuf);
96
+ transaction.sign([keypair]);
97
+ // Serialize signed transaction
98
+ const signedTransaction = Buffer.from(transaction.serialize()).toString('base64');
99
+ // Execute via Ultra API
100
+ const response = await fetch(`${JupiterClient.API_BASE}/execute`, {
101
+ method: 'POST',
102
+ headers: {
103
+ 'Content-Type': 'application/json',
104
+ },
105
+ body: JSON.stringify({
106
+ signedTransaction,
107
+ requestId: orderResponse.requestId,
108
+ }),
109
+ });
110
+ if (!response.ok) {
111
+ throw new Error(`Jupiter execute error: ${response.statusText}`);
112
+ }
113
+ const result = (await response.json());
114
+ return result;
115
+ }
116
+ /**
117
+ * Load referral configuration (FOUNDER'S referral account)
118
+ * This is hardcoded so the founder earns on all swaps
119
+ */
120
+ static loadReferralConfig() {
121
+ // HARDCODED: Founder's referral account - YOU earn on every swap! 💰
122
+ const FOUNDER_REFERRAL_ACCOUNT = '2WutJ7mKajims4WiFDHwR4vbF6pYjwq8kL4K6H9he1pr';
123
+ const FOUNDER_REFERRAL_FEE = 100; // 1% fee (you keep 0.8%, Jupiter takes 0.2%)
124
+ return {
125
+ referralAccount: FOUNDER_REFERRAL_ACCOUNT,
126
+ referralFee: FOUNDER_REFERRAL_FEE,
127
+ };
128
+ }
129
+ }
130
+ exports.JupiterClient = JupiterClient;
131
+ JupiterClient.API_BASE = 'https://lite-api.jup.ag/ultra/v1';
132
+ JupiterClient.TOKEN_API = 'https://lite-api.jup.ag/tokens/v2';
133
+ JupiterClient.tokenListCache = null;
134
+ /**
135
+ * Common token addresses on Solana
136
+ */
137
+ JupiterClient.TOKENS = {
138
+ SOL: 'So11111111111111111111111111111111111111112',
139
+ USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
140
+ USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
141
+ BONK: 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263',
142
+ };
143
+ //# sourceMappingURL=client.js.map