flow-evm-agentkit 0.1.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 (64) hide show
  1. package/.cache/replit/env/latest +59 -0
  2. package/.cache/replit/env/latest.json +1 -0
  3. package/.cache/replit/modules/nodejs-20.res +1 -0
  4. package/.cache/replit/modules/replit-rtld-loader.res +1 -0
  5. package/.cache/replit/modules/replit.res +1 -0
  6. package/.cache/replit/modules.stamp +0 -0
  7. package/.cache/replit/nix/dotreplitenv.json +1 -0
  8. package/.cache/replit/toolchain.json +1 -0
  9. package/.env.example +25 -0
  10. package/LICENSE +22 -0
  11. package/README.md +421 -0
  12. package/dist/cli/scaffold.d.ts +8 -0
  13. package/dist/cli/scaffold.d.ts.map +1 -0
  14. package/dist/cli/scaffold.js +369 -0
  15. package/dist/cli/scaffold.js.map +1 -0
  16. package/dist/config/index.d.ts +7 -0
  17. package/dist/config/index.d.ts.map +1 -0
  18. package/dist/config/index.js +42 -0
  19. package/dist/config/index.js.map +1 -0
  20. package/dist/core/agent.d.ts +38 -0
  21. package/dist/core/agent.d.ts.map +1 -0
  22. package/dist/core/agent.js +255 -0
  23. package/dist/core/agent.js.map +1 -0
  24. package/dist/examples/agent-server.d.ts +2 -0
  25. package/dist/examples/agent-server.d.ts.map +1 -0
  26. package/dist/examples/agent-server.js +212 -0
  27. package/dist/examples/agent-server.js.map +1 -0
  28. package/dist/examples/trading-agent.d.ts +2 -0
  29. package/dist/examples/trading-agent.d.ts.map +1 -0
  30. package/dist/examples/trading-agent.js +95 -0
  31. package/dist/examples/trading-agent.js.map +1 -0
  32. package/dist/examples/tx-echo-agent.d.ts +2 -0
  33. package/dist/examples/tx-echo-agent.d.ts.map +1 -0
  34. package/dist/examples/tx-echo-agent.js +67 -0
  35. package/dist/examples/tx-echo-agent.js.map +1 -0
  36. package/dist/index.d.ts +13 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +42 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/logger/index.d.ts +8 -0
  41. package/dist/logger/index.d.ts.map +1 -0
  42. package/dist/logger/index.js +49 -0
  43. package/dist/logger/index.js.map +1 -0
  44. package/dist/modules/executor.d.ts +21 -0
  45. package/dist/modules/executor.d.ts.map +1 -0
  46. package/dist/modules/executor.js +205 -0
  47. package/dist/modules/executor.js.map +1 -0
  48. package/dist/modules/knowledge.d.ts +19 -0
  49. package/dist/modules/knowledge.d.ts.map +1 -0
  50. package/dist/modules/knowledge.js +208 -0
  51. package/dist/modules/knowledge.js.map +1 -0
  52. package/dist/modules/observer.d.ts +26 -0
  53. package/dist/modules/observer.d.ts.map +1 -0
  54. package/dist/modules/observer.js +184 -0
  55. package/dist/modules/observer.js.map +1 -0
  56. package/dist/modules/planner.d.ts +15 -0
  57. package/dist/modules/planner.d.ts.map +1 -0
  58. package/dist/modules/planner.js +179 -0
  59. package/dist/modules/planner.js.map +1 -0
  60. package/dist/types/index.d.ts +67 -0
  61. package/dist/types/index.d.ts.map +1 -0
  62. package/dist/types/index.js +3 -0
  63. package/dist/types/index.js.map +1 -0
  64. package/package.json +67 -0
@@ -0,0 +1,369 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scaffoldAgent = scaffoldAgent;
4
+ const commander_1 = require("commander");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const program = new commander_1.Command();
8
+ program
9
+ .name('flow-agent-scaffold')
10
+ .description('Scaffold a new Flow EVM agent')
11
+ .version('0.1.0');
12
+ program
13
+ .command('create')
14
+ .description('Create a new Flow EVM agent')
15
+ .requiredOption('-n, --name <name>', 'Agent name')
16
+ .option('-t, --type <type>', 'Agent type (observer|executor|full)', 'full')
17
+ .option('-d, --directory <dir>', 'Output directory', '.')
18
+ .action(async (options) => {
19
+ await scaffoldAgent(options);
20
+ });
21
+ async function scaffoldAgent(options) {
22
+ const { name, type, directory = '.' } = options;
23
+ const agentDir = (0, path_1.join)(directory, name);
24
+ console.log(`🚀 Creating Flow EVM agent: ${name}`);
25
+ console.log(`📁 Directory: ${agentDir}`);
26
+ console.log(`🔧 Type: ${type}`);
27
+ // Create directory if it doesn't exist
28
+ if (!(0, fs_1.existsSync)(agentDir)) {
29
+ (0, fs_1.mkdirSync)(agentDir, { recursive: true });
30
+ }
31
+ // Create package.json
32
+ const packageJson = {
33
+ name,
34
+ version: '0.1.0',
35
+ description: `Flow EVM agent: ${name}`,
36
+ main: 'dist/index.js',
37
+ scripts: {
38
+ build: 'tsc',
39
+ start: 'node dist/index.js',
40
+ dev: 'tsx src/index.ts'
41
+ },
42
+ dependencies: {
43
+ 'flow-evm-agentkit': '^0.1.0'
44
+ },
45
+ devDependencies: {
46
+ 'typescript': '^5.0.0',
47
+ 'tsx': '^4.0.0',
48
+ '@types/node': '^20.0.0'
49
+ }
50
+ };
51
+ (0, fs_1.writeFileSync)((0, path_1.join)(agentDir, 'package.json'), JSON.stringify(packageJson, null, 2));
52
+ // Create tsconfig.json
53
+ const tsConfig = {
54
+ compilerOptions: {
55
+ target: 'ES2022',
56
+ module: 'commonjs',
57
+ outDir: './dist',
58
+ rootDir: './src',
59
+ strict: true,
60
+ esModuleInterop: true,
61
+ skipLibCheck: true,
62
+ forceConsistentCasingInFileNames: true
63
+ },
64
+ include: ['src/**/*'],
65
+ exclude: ['node_modules', 'dist']
66
+ };
67
+ (0, fs_1.writeFileSync)((0, path_1.join)(agentDir, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
68
+ // Create .env.example
69
+ const envExample = `# Flow EVM Configuration
70
+ FLOW_RPC_URL=https://mainnet.evm.nodes.onflow.org
71
+ PRIVATE_KEY=your_private_key_here
72
+
73
+ # Optional: OpenAI API Key
74
+ OPENAI_API_KEY=your_openai_api_key_here
75
+
76
+ # Agent Configuration
77
+ AGENT_NAME=${name}
78
+ LOG_LEVEL=info
79
+ POLLING_INTERVAL=5000
80
+ `;
81
+ (0, fs_1.writeFileSync)((0, path_1.join)(agentDir, '.env.example'), envExample);
82
+ // Create src directory
83
+ const srcDir = (0, path_1.join)(agentDir, 'src');
84
+ if (!(0, fs_1.existsSync)(srcDir)) {
85
+ (0, fs_1.mkdirSync)(srcDir);
86
+ }
87
+ // Create main agent file based on type
88
+ let agentCode = '';
89
+ switch (type) {
90
+ case 'observer':
91
+ agentCode = generateObserverAgent(name);
92
+ break;
93
+ case 'executor':
94
+ agentCode = generateExecutorAgent(name);
95
+ break;
96
+ case 'full':
97
+ default:
98
+ agentCode = generateFullAgent(name);
99
+ break;
100
+ }
101
+ (0, fs_1.writeFileSync)((0, path_1.join)(srcDir, 'index.ts'), agentCode);
102
+ // Create README
103
+ const readme = generateReadme(name, type);
104
+ (0, fs_1.writeFileSync)((0, path_1.join)(agentDir, 'README.md'), readme);
105
+ console.log(`✅ Agent scaffolded successfully!`);
106
+ console.log(`\nNext steps:`);
107
+ console.log(`1. cd ${name}`);
108
+ console.log(`2. npm install`);
109
+ console.log(`3. cp .env.example .env`);
110
+ console.log(`4. Edit .env with your configuration`);
111
+ console.log(`5. npm run dev`);
112
+ }
113
+ function generateObserverAgent(name) {
114
+ return `import { Agent, Config, Logger } from 'flow-evm-agentkit';
115
+
116
+ async function main() {
117
+ console.log('🔍 Starting ${name} Observer Agent...');
118
+
119
+ try {
120
+ const config = Config.load();
121
+ const logger = Logger.initialize(config);
122
+ const agent = new Agent(config);
123
+
124
+ // Add observation goals
125
+ agent.addGoal('Monitor specific contract events');
126
+ agent.addGoal('Log transaction patterns');
127
+
128
+ // Set up event handlers
129
+ agent.on('event', (event) => {
130
+ if (event.type === 'transaction') {
131
+ logger.info('Transaction observed:', {
132
+ hash: event.data.transaction.hash,
133
+ from: event.data.transaction.from,
134
+ to: event.data.transaction.to
135
+ });
136
+ }
137
+
138
+ if (event.type === 'log') {
139
+ logger.info('Log event observed:', {
140
+ address: event.data.log.address,
141
+ topics: event.data.log.topics
142
+ });
143
+ }
144
+ });
145
+
146
+ agent.on('started', () => {
147
+ console.log('✅ ${name} started successfully!');
148
+ console.log('🔍 Observing Flow EVM...');
149
+ });
150
+
151
+ // Graceful shutdown
152
+ process.on('SIGINT', async () => {
153
+ console.log('\\n🛑 Shutting down...');
154
+ await agent.stop();
155
+ process.exit(0);
156
+ });
157
+
158
+ await agent.start();
159
+
160
+ } catch (error) {
161
+ console.error('❌ Failed to start agent:', error);
162
+ process.exit(1);
163
+ }
164
+ }
165
+
166
+ if (require.main === module) {
167
+ main().catch(console.error);
168
+ }
169
+ `;
170
+ }
171
+ function generateExecutorAgent(name) {
172
+ return `import { Agent, Config, Logger } from 'flow-evm-agentkit';
173
+
174
+ async function main() {
175
+ console.log('⚡ Starting ${name} Executor Agent...');
176
+
177
+ try {
178
+ const config = Config.load();
179
+ const logger = Logger.initialize(config);
180
+ const agent = new Agent(config);
181
+
182
+ // Add execution goals
183
+ agent.addGoal('Execute transactions based on conditions');
184
+ agent.addGoal('Manage portfolio automatically');
185
+
186
+ // Custom execution logic
187
+ agent.on('event', async (event) => {
188
+ // Add your custom logic here
189
+ if (event.type === 'transaction') {
190
+ // React to specific transactions
191
+ const tx = event.data.transaction;
192
+
193
+ // Example: React to large transfers
194
+ if (tx.value && Number(tx.value) > 1e18) { // > 1 FLOW
195
+ logger.info('Large transfer detected, taking action...');
196
+ // Add custom execution logic
197
+ }
198
+ }
199
+ });
200
+
201
+ agent.on('started', async () => {
202
+ console.log('✅ ${name} started successfully!');
203
+ console.log(\`👤 Agent address: \${agent.getStatus().address}\`);
204
+
205
+ // Example: Check balance on startup
206
+ const status = agent.getStatus();
207
+ logger.info('Agent status:', status);
208
+ });
209
+
210
+ // Graceful shutdown
211
+ process.on('SIGINT', async () => {
212
+ console.log('\\n🛑 Shutting down...');
213
+ await agent.stop();
214
+ process.exit(0);
215
+ });
216
+
217
+ await agent.start();
218
+
219
+ } catch (error) {
220
+ console.error('❌ Failed to start agent:', error);
221
+ process.exit(1);
222
+ }
223
+ }
224
+
225
+ if (require.main === module) {
226
+ main().catch(console.error);
227
+ }
228
+ `;
229
+ }
230
+ function generateFullAgent(name) {
231
+ return `import { Agent, Config, Logger } from 'flow-evm-agentkit';
232
+
233
+ async function main() {
234
+ console.log('🤖 Starting ${name} Full Agent...');
235
+
236
+ try {
237
+ const config = Config.load();
238
+ const logger = Logger.initialize(config);
239
+ const agent = new Agent(config);
240
+
241
+ // Add comprehensive goals
242
+ agent.addGoal('Monitor Flow EVM for opportunities');
243
+ agent.addGoal('Execute optimal strategies');
244
+ agent.addGoal('Maintain portfolio health');
245
+
246
+ // Set up comprehensive event handling
247
+ agent.on('event', async (event) => {
248
+ switch (event.type) {
249
+ case 'transaction':
250
+ const tx = event.data.transaction;
251
+ logger.info('Transaction observed:', {
252
+ hash: tx.hash,
253
+ value: tx.value?.toString(),
254
+ gasPrice: tx.gasPrice?.toString()
255
+ });
256
+ break;
257
+
258
+ case 'log':
259
+ const log = event.data.log;
260
+ logger.info('Contract event observed:', {
261
+ address: log.address,
262
+ topics: log.topics.slice(0, 2) // First 2 topics for brevity
263
+ });
264
+ break;
265
+
266
+ case 'block':
267
+ const block = event.data.block;
268
+ if (Number(block.number) % 100 === 0) { // Log every 100 blocks
269
+ logger.info(\`Block \${block.number} processed\`);
270
+ }
271
+ break;
272
+ }
273
+ });
274
+
275
+ agent.on('started', async () => {
276
+ console.log('✅ ${name} started successfully!');
277
+ console.log(\`👤 Agent address: \${agent.getStatus().address}\`);
278
+ console.log('🧠 AI planning enabled:', !!config.openaiApiKey);
279
+ console.log('🔍 Full monitoring active...');
280
+ });
281
+
282
+ // Status reporting
283
+ setInterval(() => {
284
+ const status = agent.getStatus();
285
+ console.log(\`
286
+ 📊 Agent Status:
287
+ Running: \${status.running}
288
+ Active Goals: \${status.goals.filter(g => !g.completed).length}
289
+ Completed Goals: \${status.goals.filter(g => g.completed).length}
290
+ Recent Tasks: \${status.recentTasks.length}
291
+ \`);
292
+ }, 60000); // Every minute
293
+
294
+ // Graceful shutdown
295
+ process.on('SIGINT', async () => {
296
+ console.log('\\n🛑 Shutting down...');
297
+ await agent.stop();
298
+ process.exit(0);
299
+ });
300
+
301
+ process.on('SIGTERM', async () => {
302
+ await agent.stop();
303
+ process.exit(0);
304
+ });
305
+
306
+ await agent.start();
307
+
308
+ } catch (error) {
309
+ console.error('❌ Failed to start agent:', error);
310
+ process.exit(1);
311
+ }
312
+ }
313
+
314
+ if (require.main === module) {
315
+ main().catch(console.error);
316
+ }
317
+ `;
318
+ }
319
+ function generateReadme(name, type) {
320
+ return `# ${name}
321
+
322
+ A Flow EVM agent generated by Flow EVM AgentKit.
323
+
324
+ ## Type: ${type}
325
+
326
+ ## Setup
327
+
328
+ 1. Install dependencies:
329
+ \`\`\`bash
330
+ npm install
331
+ \`\`\`
332
+
333
+ 2. Configure environment:
334
+ \`\`\`bash
335
+ cp .env.example .env
336
+ # Edit .env with your configuration
337
+ \`\`\`
338
+
339
+ 3. Run the agent:
340
+ \`\`\`bash
341
+ npm run dev
342
+ \`\`\`
343
+
344
+ ## Configuration
345
+
346
+ Edit \`.env\` with your Flow EVM configuration:
347
+
348
+ - \`FLOW_RPC_URL\`: Flow EVM RPC endpoint
349
+ - \`PRIVATE_KEY\`: Your private key (without 0x prefix)
350
+ - \`OPENAI_API_KEY\`: OpenAI API key for AI planning (optional)
351
+
352
+ ## Customization
353
+
354
+ Edit \`src/index.ts\` to customize your agent's behavior:
355
+
356
+ - Add custom goals
357
+ - Implement event handlers
358
+ - Configure execution logic
359
+ - Set up monitoring rules
360
+
361
+ ## Documentation
362
+
363
+ See the [Flow EVM AgentKit documentation](https://github.com/your-org/flow-evm-agentkit) for more details.
364
+ `;
365
+ }
366
+ if (require.main === module) {
367
+ program.parse();
368
+ }
369
+ //# sourceMappingURL=scaffold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/cli/scaffold.ts"],"names":[],"mappings":";;AAmZS,sCAAa;AAjZtB,yCAAoC;AACpC,2BAA0D;AAC1D,+BAA4B;AAE5B,MAA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;;;;;;;;;;;;;;;;;;uBA2BT,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B1B,CAAC;AACF,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO;;;6BAGoB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA0CV,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyC1B,CAAC;AACF,CAAC;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,IAAY;IAChD,OAAO,KAAK,IAAI;;;;WAIP,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCd,CAAC;AACF,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { AgentConfig } from '../types';
2
+ export declare class Config {
3
+ static load(): AgentConfig;
4
+ static validateFlowRpcUrl(url: string): boolean;
5
+ static validatePrivateKey(key: string): boolean;
6
+ }
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,qBAAa,MAAM;IACjB,MAAM,CAAC,IAAI,IAAI,WAAW;IAoB1B,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAS/C,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAIhD"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Config = void 0;
7
+ const dotenv_1 = __importDefault(require("dotenv"));
8
+ dotenv_1.default.config();
9
+ class Config {
10
+ static load() {
11
+ const requiredEnvVars = ['FLOW_RPC_URL', 'PRIVATE_KEY'];
12
+ for (const envVar of requiredEnvVars) {
13
+ if (!process.env[envVar]) {
14
+ throw new Error(`Missing required environment variable: ${envVar}`);
15
+ }
16
+ }
17
+ return {
18
+ name: process.env.AGENT_NAME || 'flow-evm-agent',
19
+ flowRpcUrl: process.env.FLOW_RPC_URL,
20
+ privateKey: process.env.PRIVATE_KEY,
21
+ openaiApiKey: process.env.OPENAI_API_KEY,
22
+ pollingInterval: parseInt(process.env.POLLING_INTERVAL || '5000'),
23
+ logLevel: process.env.LOG_LEVEL || 'info',
24
+ logFile: process.env.LOG_FILE || './logs/agent.log'
25
+ };
26
+ }
27
+ static validateFlowRpcUrl(url) {
28
+ try {
29
+ const parsed = new URL(url);
30
+ return parsed.protocol === 'http:' || parsed.protocol === 'https:';
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ static validatePrivateKey(key) {
37
+ const cleanKey = key.startsWith('0x') ? key.slice(2) : key;
38
+ return /^[0-9a-fA-F]{64}$/.test(cleanKey);
39
+ }
40
+ }
41
+ exports.Config = Config;
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;AACA,oDAA4B;AAG5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAa,MAAM;IACjB,MAAM,CAAC,IAAI;QACT,MAAM,eAAe,GAAG,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;QAExD,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,0CAA0C,MAAM,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,gBAAgB;YAChD,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,YAAa;YACrC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,WAAY;YACpC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;YACxC,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,MAAM,CAAC;YACjE,QAAQ,EAAG,OAAO,CAAC,GAAG,CAAC,SAAiB,IAAI,MAAM;YAClD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,kBAAkB;SACpD,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAW;QACnC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5B,OAAO,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC;QACrE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAW;QACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC3D,OAAO,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACF;AAlCD,wBAkCC"}
@@ -0,0 +1,38 @@
1
+ import { EventEmitter } from 'events';
2
+ import { AgentConfig, AgentGoal, AgentTask } from '../types';
3
+ export declare class Agent extends EventEmitter {
4
+ private config;
5
+ private logger;
6
+ private observer;
7
+ private executor;
8
+ private planner;
9
+ private knowledge;
10
+ private isRunning;
11
+ private goals;
12
+ private tasks;
13
+ private taskHistory;
14
+ constructor(config: AgentConfig);
15
+ private setupEventHandlers;
16
+ start(): Promise<void>;
17
+ stop(): Promise<void>;
18
+ addGoal(description: string): string;
19
+ removeGoal(goalId: string): boolean;
20
+ markGoalCompleted(goalId: string): boolean;
21
+ getGoals(): AgentGoal[];
22
+ private startMainLoop;
23
+ private planAndExecute;
24
+ private executeAction;
25
+ private getAvailableActions;
26
+ private getCurrentContext;
27
+ private evaluateGoalCompletion;
28
+ private handleObservedEvent;
29
+ private sleep;
30
+ query(question: string): Promise<string>;
31
+ getStatus(): {
32
+ running: boolean;
33
+ goals: AgentGoal[];
34
+ recentTasks: AgentTask[];
35
+ address: Promise<`0x${string}`>;
36
+ };
37
+ }
38
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/core/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAMtC,OAAO,EAAE,WAAW,EAAc,SAAS,EAAE,SAAS,EAAgB,MAAM,UAAU,CAAC;AAGvF,qBAAa,KAAM,SAAQ,YAAY;IACrC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,SAAS,CAAY;IAE7B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,WAAW,CAAmB;gBAE1B,MAAM,EAAE,WAAW;IAc/B,OAAO,CAAC,kBAAkB;IAepB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAoBpC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAUnC,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAkB1C,QAAQ,IAAI,SAAS,EAAE;YAIT,aAAa;YAYb,cAAc;YA0Ed,aAAa;IAkC3B,OAAO,CAAC,mBAAmB;YAWb,iBAAiB;YAcjB,sBAAsB;YAWtB,mBAAmB;IAgBjC,OAAO,CAAC,KAAK;IAKP,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO9C,SAAS;;;;;;CAQV"}