agent-world 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -2
- package/dist/cli/index.js +8 -8
- package/{index.ts → dist/index.js} +4 -6
- package/dist/server/index.js +50 -6
- package/package.json +26 -37
package/README.md
CHANGED
|
@@ -82,13 +82,14 @@ Each Agent World has a collection of agents that can communicate through a share
|
|
|
82
82
|
| **Direct mention** | `@alice Can you help?` | Only @alice |
|
|
83
83
|
| **Paragraph mention** | `Please review this:\n@alice` | Only @alice |
|
|
84
84
|
| **Mid-text mention** | `I think @alice should help` | Nobody (saved to memory) |
|
|
85
|
+
| **Stop World** | `<world>pass</world>` | No agents |
|
|
85
86
|
|
|
86
87
|
### Agent Behavior
|
|
87
88
|
|
|
88
89
|
**Agents always respond to:**
|
|
89
90
|
- Human messages (unless mentioned agents exist)
|
|
90
91
|
- Direct @mentions at paragraph start
|
|
91
|
-
-
|
|
92
|
+
- World messages
|
|
92
93
|
|
|
93
94
|
**Agents never respond to:**
|
|
94
95
|
- Their own messages
|
|
@@ -172,11 +173,30 @@ export AGENT_WORLD_DATA_PATH=./data/worlds
|
|
|
172
173
|
- **[Building Agents with Just Words](docs/Building%20Agents%20with%20Just%20Words.md)** - Complete guide with examples
|
|
173
174
|
|
|
174
175
|
|
|
176
|
+
## Experimental Features
|
|
177
|
+
|
|
178
|
+
- **MCP Support** - *Currently in experiment* - Model Context Protocol integration for tools like search and code execution. e.g.,
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"servers": {
|
|
183
|
+
"playwright": {
|
|
184
|
+
"command": "npx",
|
|
185
|
+
"args": [
|
|
186
|
+
"@playwright/mcp@latest"
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
It supports transport types `stdio` and `http`.
|
|
194
|
+
|
|
195
|
+
|
|
175
196
|
## Future Plans
|
|
176
197
|
|
|
177
198
|
- **Long Run Worlds** - Worlds can run for days or weeks, with agents evolving over time
|
|
178
199
|
- **Dynamic Worlds** - Worlds can provide real-time data to agents, e.g. date and time
|
|
179
|
-
- **Tools / MCP Support** - Worlds can have tools for agents to use, like search or code execution
|
|
180
200
|
- **Agent Learning** - Agents will evolve based on interactions
|
|
181
201
|
- **Agent Replication** - Agents can create new agents
|
|
182
202
|
|
package/dist/cli/index.js
CHANGED
|
@@ -100,12 +100,12 @@ function configureLLMProvidersFromEnv() {
|
|
|
100
100
|
logger.debug('Configured Google provider from environment');
|
|
101
101
|
}
|
|
102
102
|
// Azure
|
|
103
|
-
if (process.env.AZURE_OPENAI_API_KEY && process.env.
|
|
103
|
+
if (process.env.AZURE_OPENAI_API_KEY && process.env.AZURE_RESOURCE_NAME && process.env.AZURE_DEPLOYMENT) {
|
|
104
104
|
configureLLMProvider(LLMProvider.AZURE, {
|
|
105
105
|
apiKey: process.env.AZURE_OPENAI_API_KEY,
|
|
106
|
-
|
|
106
|
+
resourceName: process.env.AZURE_RESOURCE_NAME,
|
|
107
107
|
deployment: process.env.AZURE_DEPLOYMENT,
|
|
108
|
-
apiVersion: process.env.AZURE_API_VERSION || '
|
|
108
|
+
apiVersion: process.env.AZURE_API_VERSION || '2024-10-21-preview'
|
|
109
109
|
});
|
|
110
110
|
logger.debug('Configured Azure provider from environment');
|
|
111
111
|
}
|
|
@@ -124,19 +124,19 @@ function configureLLMProvidersFromEnv() {
|
|
|
124
124
|
});
|
|
125
125
|
logger.debug('Configured OpenAI-Compatible provider from environment');
|
|
126
126
|
}
|
|
127
|
-
// Ollama
|
|
127
|
+
// Ollama (OpenAI-compatible endpoint)
|
|
128
128
|
if (process.env.OLLAMA_BASE_URL) {
|
|
129
129
|
configureLLMProvider(LLMProvider.OLLAMA, {
|
|
130
130
|
baseUrl: process.env.OLLAMA_BASE_URL
|
|
131
131
|
});
|
|
132
|
-
logger.debug('Configured Ollama provider from environment');
|
|
132
|
+
logger.debug('Configured Ollama provider (OpenAI-compatible) from environment');
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
|
-
// Configure Ollama with default URL if not specified
|
|
135
|
+
// Configure Ollama with default OpenAI-compatible URL if not specified
|
|
136
136
|
configureLLMProvider(LLMProvider.OLLAMA, {
|
|
137
|
-
baseUrl: 'http://localhost:11434/
|
|
137
|
+
baseUrl: 'http://localhost:11434/v1'
|
|
138
138
|
});
|
|
139
|
-
logger.debug('Configured Ollama provider with default URL');
|
|
139
|
+
logger.debug('Configured Ollama provider (OpenAI-compatible) with default URL');
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
// Get default root path from storage-factory (no local defaults)
|
|
@@ -10,13 +10,11 @@
|
|
|
10
10
|
*
|
|
11
11
|
* This module re-exports the core functionality of Agent World for npm package usage.
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
13
|
// Re-export all core functionality
|
|
15
14
|
export * from './core/index';
|
|
16
|
-
|
|
17
15
|
// Package information
|
|
18
16
|
export const PACKAGE_INFO = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
17
|
+
name: 'agent-world',
|
|
18
|
+
version: '0.5.0',
|
|
19
|
+
description: 'A agent management system for building AI agent teams with just words.',
|
|
20
|
+
};
|
package/dist/server/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import cors from 'cors';
|
|
|
23
23
|
import path from 'path';
|
|
24
24
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
25
25
|
import apiRouter from './api.js';
|
|
26
|
+
import { initializeMCPRegistry, shutdownAllMCPServers } from '../core/mcp-server-registry.js';
|
|
26
27
|
// ES modules setup
|
|
27
28
|
const __filename = fileURLToPath(import.meta.url);
|
|
28
29
|
const __dirname = path.dirname(__filename);
|
|
@@ -47,12 +48,12 @@ function configureLLMProvidersFromEnv() {
|
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
// Azure (requires multiple env vars)
|
|
50
|
-
if (process.env.AZURE_OPENAI_API_KEY && process.env.
|
|
51
|
+
if (process.env.AZURE_OPENAI_API_KEY && process.env.AZURE_RESOURCE_NAME && process.env.AZURE_DEPLOYMENT) {
|
|
51
52
|
configureLLMProvider(LLMProvider.AZURE, {
|
|
52
53
|
apiKey: process.env.AZURE_OPENAI_API_KEY,
|
|
53
|
-
|
|
54
|
+
resourceName: process.env.AZURE_RESOURCE_NAME,
|
|
54
55
|
deployment: process.env.AZURE_DEPLOYMENT,
|
|
55
|
-
apiVersion: process.env.AZURE_API_VERSION || '
|
|
56
|
+
apiVersion: process.env.AZURE_API_VERSION || '2024-10-21-preview'
|
|
56
57
|
});
|
|
57
58
|
serverLogger.debug('Configured Azure provider from environment');
|
|
58
59
|
}
|
|
@@ -64,10 +65,10 @@ function configureLLMProvidersFromEnv() {
|
|
|
64
65
|
});
|
|
65
66
|
serverLogger.debug('Configured OpenAI-Compatible provider from environment');
|
|
66
67
|
}
|
|
67
|
-
// Ollama
|
|
68
|
-
const ollamaUrl = process.env.OLLAMA_BASE_URL || 'http://localhost:11434/
|
|
68
|
+
// Ollama (OpenAI-compatible endpoint)
|
|
69
|
+
const ollamaUrl = process.env.OLLAMA_BASE_URL || 'http://localhost:11434/v1';
|
|
69
70
|
configureLLMProvider(LLMProvider.OLLAMA, { baseUrl: ollamaUrl });
|
|
70
|
-
serverLogger.debug('Configured Ollama provider', { baseUrl: ollamaUrl });
|
|
71
|
+
serverLogger.debug('Configured Ollama provider (OpenAI-compatible)', { baseUrl: ollamaUrl });
|
|
71
72
|
}
|
|
72
73
|
// Express app setup
|
|
73
74
|
const app = express();
|
|
@@ -116,6 +117,9 @@ app.use((req, res) => {
|
|
|
116
117
|
export function startWebServer(port = PORT, host = HOST) {
|
|
117
118
|
return new Promise((resolve, reject) => {
|
|
118
119
|
configureLLMProvidersFromEnv();
|
|
120
|
+
// Initialize MCP registry
|
|
121
|
+
initializeMCPRegistry();
|
|
122
|
+
serverLogger.info('MCP registry initialized');
|
|
119
123
|
const server = app.listen(port, host, () => {
|
|
120
124
|
const serverAddress = server.address();
|
|
121
125
|
if (serverAddress && typeof serverAddress === 'object') {
|
|
@@ -129,6 +133,46 @@ export function startWebServer(port = PORT, host = HOST) {
|
|
|
129
133
|
}
|
|
130
134
|
});
|
|
131
135
|
server.on('error', reject);
|
|
136
|
+
// Setup graceful shutdown handlers
|
|
137
|
+
const gracefulShutdown = async (signal) => {
|
|
138
|
+
serverLogger.info(`Received ${signal}, initiating graceful shutdown`);
|
|
139
|
+
try {
|
|
140
|
+
// Shutdown MCP servers first
|
|
141
|
+
await shutdownAllMCPServers();
|
|
142
|
+
serverLogger.info('MCP servers shut down');
|
|
143
|
+
// Close Express server
|
|
144
|
+
server.close((err) => {
|
|
145
|
+
if (err) {
|
|
146
|
+
serverLogger.error('Error closing server', { error: err.message });
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
serverLogger.info('Express server closed');
|
|
151
|
+
process.exit(0);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
serverLogger.error('Error during graceful shutdown', {
|
|
157
|
+
error: error instanceof Error ? error.message : error
|
|
158
|
+
});
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
// Register shutdown handlers
|
|
163
|
+
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
|
|
164
|
+
process.on('SIGINT', () => gracefulShutdown('SIGINT'));
|
|
165
|
+
// Handle uncaught exceptions and unhandled rejections
|
|
166
|
+
process.on('uncaughtException', (error) => {
|
|
167
|
+
serverLogger.error('Uncaught exception', { error: error.message });
|
|
168
|
+
gracefulShutdown('uncaughtException');
|
|
169
|
+
});
|
|
170
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
171
|
+
serverLogger.error('Unhandled rejection', {
|
|
172
|
+
reason: reason instanceof Error ? reason.message : reason,
|
|
173
|
+
promise: promise.toString()
|
|
174
|
+
});
|
|
175
|
+
});
|
|
132
176
|
});
|
|
133
177
|
}
|
|
134
178
|
// Direct execution handling - check both direct execution and npm bin execution
|
package/package.json
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-world",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"main": "index.
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"./core": {
|
|
12
|
+
"import": "./dist/core/index.js",
|
|
13
|
+
"types": "./dist/core/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
5
17
|
"type": "module",
|
|
6
18
|
"workspaces": [
|
|
7
19
|
"core",
|
|
8
|
-
"next"
|
|
20
|
+
"next",
|
|
21
|
+
"web"
|
|
9
22
|
],
|
|
10
23
|
"bin": {
|
|
11
24
|
"agent-world": "dist/cli/index.js",
|
|
@@ -16,10 +29,11 @@
|
|
|
16
29
|
"start": "node dist/server/index.js",
|
|
17
30
|
"cli": "npx tsx cli/index.ts",
|
|
18
31
|
"server": "npx tsx server/index.ts",
|
|
19
|
-
"dev": "concurrently \"npm run server\" \"
|
|
32
|
+
"dev": "concurrently \"npm run server\" \"npm run dev --workspace=web\"",
|
|
20
33
|
"test": "jest --config jest.config.js",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
34
|
+
"test:db": "npx tsx tests/db/migration-tests.ts",
|
|
35
|
+
"check": "tsc --noEmit && npm run check --workspace=web",
|
|
36
|
+
"build": "npm run build --workspace=core && tsc --project tsconfig.build.json && npm run build --workspace=web",
|
|
23
37
|
"pkill": "pkill -f tsx",
|
|
24
38
|
"dev-next": "cd next && npm run dev"
|
|
25
39
|
},
|
|
@@ -34,49 +48,24 @@
|
|
|
34
48
|
],
|
|
35
49
|
"author": "",
|
|
36
50
|
"license": "ISC",
|
|
37
|
-
"exports": {
|
|
38
|
-
".": "./index.ts",
|
|
39
|
-
"./package.json": "./package.json"
|
|
40
|
-
},
|
|
41
51
|
"dependencies": {
|
|
42
|
-
"@ai-sdk/anthropic": "^2.0.0",
|
|
43
|
-
"@ai-sdk/azure": "^2.0.2",
|
|
44
|
-
"@ai-sdk/google": "^2.0.1",
|
|
45
|
-
"@ai-sdk/openai": "^2.0.2",
|
|
46
|
-
"@ai-sdk/openai-compatible": "^1.0.1",
|
|
47
|
-
"@ai-sdk/xai": "^2.0.1",
|
|
48
|
-
"ai": "^5.0.2",
|
|
49
52
|
"chalk": "^5.5.0",
|
|
50
53
|
"cors": "^2.8.5",
|
|
51
|
-
"dotenv": "^17.2.1",
|
|
52
54
|
"enquirer": "^2.4.1",
|
|
53
|
-
"events": "^3.3.0",
|
|
54
55
|
"express": "^4.21.2",
|
|
55
|
-
"nanoid": "^5.1.5",
|
|
56
|
-
"ollama-ai-provider": "^1.2.0",
|
|
57
56
|
"open": "^10.2.0",
|
|
58
|
-
"pino": "^9.7.0",
|
|
59
|
-
"pino-pretty": "^13.0.0",
|
|
60
|
-
"sqlite3": "^5.1.7",
|
|
61
57
|
"tsx": "^4.20.3",
|
|
62
|
-
"typescript": "^5.8.3"
|
|
63
|
-
"zod": "^3.25.76"
|
|
58
|
+
"typescript": "^5.8.3"
|
|
64
59
|
},
|
|
65
60
|
"devDependencies": {
|
|
66
|
-
"@types/chalk": "^2.2.4",
|
|
67
61
|
"@types/cors": "^2.8.19",
|
|
68
62
|
"@types/express": "^4.17.23",
|
|
69
|
-
"@types/jest": "^
|
|
70
|
-
"@types/node": "^
|
|
71
|
-
"@types/pino": "^7.0.4",
|
|
72
|
-
"@types/sqlite3": "^5.1.0",
|
|
73
|
-
"@types/tmp": "^0.2.0",
|
|
74
|
-
"@types/uuid": "^10.0.0",
|
|
75
|
-
"@types/ws": "^8.18.1",
|
|
63
|
+
"@types/jest": "^30.0.0",
|
|
64
|
+
"@types/node": "^24.3.0",
|
|
76
65
|
"commander": "^14.0.0",
|
|
77
|
-
"concurrently": "^9.
|
|
78
|
-
"jest": "^
|
|
79
|
-
"ts-jest": "^29.1
|
|
66
|
+
"concurrently": "^9.2.0",
|
|
67
|
+
"jest": "^30.0.5",
|
|
68
|
+
"ts-jest": "^29.4.1"
|
|
80
69
|
},
|
|
81
70
|
"engines": {
|
|
82
71
|
"node": ">=20.0.0"
|