@theaiinc/yggdrasil 0.1.0 → 0.2.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@theaiinc/yggdrasil",
3
- "version": "0.1.0",
4
- "description": "Distributed orchestration system for agent containers with auto-scaling",
3
+ "version": "0.2.1",
4
+ "description": "Distributed runner orchestration receives runner registrations and heartbeats via Ratatoskr",
5
5
  "author": "The AI Inc",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -10,14 +10,8 @@
10
10
  "build": "tsc -p ./tsconfig.json",
11
11
  "dev": "nodemon --exec \"node --loader ts-node/esm src/orchestration-controller.ts\"",
12
12
  "start": "node dist/src/orchestration-controller.js",
13
- "test": "vitest",
14
- "test:coverage": "vitest --coverage",
13
+ "test": "echo 'No tests yet'",
15
14
  "lint": "eslint . --ext .ts",
16
- "docker:build": "docker build -t yggdrasil-agent ./agent",
17
- "docker:compose": "docker-compose up -d",
18
- "docker:compose:dev": "docker-compose -f docker-compose.dev.yml up",
19
- "load:test": "node scripts/load-test.js",
20
- "health:check": "node scripts/health-check.js",
21
15
  "prepublishOnly": "npm run build"
22
16
  },
23
17
  "files": [
@@ -26,29 +20,18 @@
26
20
  "LICENSE"
27
21
  ],
28
22
  "dependencies": {
29
- "async-lock": "^1.4.0",
30
- "axios": "^1.6.7",
31
23
  "compression": "^1.7.4",
32
24
  "cors": "^2.8.5",
33
- "dotenv": "^17.2.0",
34
25
  "express": "^4.19.2",
35
26
  "helmet": "^8.1.0",
36
27
  "nanoid": "^5.0.6",
37
- "node-cron": "^3.0.3",
38
- "prom-client": "^15.1.0",
39
- "redis": "^4.6.12",
40
- "socket.io": "^4.7.4",
41
- "uuid": "^9.0.1",
42
- "winston": "^3.11.0",
43
- "zod": "^3.22.4"
28
+ "winston": "^3.11.0"
44
29
  },
45
30
  "devDependencies": {
46
31
  "@types/compression": "^1.7.5",
47
32
  "@types/cors": "^2.8.17",
48
33
  "@types/express": "^4.17.21",
49
34
  "@types/node": "^20.17.24",
50
- "@types/node-cron": "^3.0.11",
51
- "@types/uuid": "^9.0.7",
52
35
  "@typescript-eslint/eslint-plugin": "^8.26.1",
53
36
  "@typescript-eslint/parser": "^8.26.1",
54
37
  "eslint": "^9.22.0",
@@ -63,9 +46,8 @@
63
46
  "keywords": [
64
47
  "ai",
65
48
  "orchestration",
49
+ "ratatoskr",
66
50
  "distributed-systems",
67
- "auto-scaling",
68
- "containers",
69
- "agents"
51
+ "runners"
70
52
  ]
71
53
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 The AI Inc
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,340 +0,0 @@
1
- # @theaiinc/yggdrasil - Distributed Orchestration System
2
-
3
- A robust, scalable orchestration system for agent containers with auto-scaling capabilities, built with stable, well-documented technologies.
4
-
5
- ## 🏗️ Architecture
6
-
7
- ```
8
- ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
9
- │ Orchestration │ │ Load Balancer │ │ Agent Pool │
10
- │ Controller │───▶│ (Nginx) │───▶│ (Docker) │
11
- │ (Node.js) │ │ │ │ │
12
- └─────────────────┘ └─────────────────┘ └─────────────────┘
13
- │ │ │
14
- │ │ │
15
- ▼ ▼ ▼
16
- ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
17
- │ Monitoring │ │ Health Checks │ │ Auto-scaling │
18
- │ (Prometheus) │ │ (Express) │ │ (Docker) │
19
- └─────────────────┘ └─────────────────┘ └─────────────────┘
20
- ```
21
-
22
- ## 🚀 Technology Stack
23
-
24
- ### Core Technologies
25
-
26
- - **Node.js + TypeScript** - Stable, well-documented runtime
27
- - **Express.js** - Battle-tested web framework
28
- - **Docker** - Industry standard containerization
29
- - **Socket.IO** - Real-time communication
30
-
31
- ### Infrastructure
32
-
33
- - **Docker Compose** - Local orchestration
34
- - **Nginx** - Load balancing and session affinity
35
- - **Prometheus + Grafana** - Monitoring and alerting
36
- - **Redis** - Session storage (optional)
37
-
38
- ### Key Features
39
-
40
- - ✅ **Low Maintenance** - Uses stable, mature technologies
41
- - ✅ **Excellent Documentation** - All components well-documented
42
- - ✅ **Auto-scaling** - Automatic agent scaling based on load
43
- - ✅ **Session Affinity** - Sticky sessions for stateful workflows
44
- - ✅ **Health Monitoring** - Comprehensive health checks
45
- - ✅ **Circuit Breaker** - Fault tolerance and error handling
46
- - ✅ **Metrics Collection** - Prometheus integration
47
-
48
- ## 📋 Prerequisites
49
-
50
- - Docker and Docker Compose
51
- - Node.js 18+ (for local development)
52
- - 4GB+ RAM available for containers
53
-
54
- ## 🛠️ Quick Start
55
-
56
- ### 1. Clone and Setup
57
-
58
- ```bash
59
- cd yggdrasil
60
- npm install
61
- ```
62
-
63
- ### 2. Start the System
64
-
65
- ```bash
66
- # Start all services
67
- docker-compose up -d
68
-
69
- # Or start with development mode
70
- docker-compose -f docker-compose.dev.yml up
71
- ```
72
-
73
- ### 3. Access Services
74
-
75
- - **Load Balancer**: http://localhost:80
76
- - **Orchestration Controller**: http://localhost:3000
77
- - **Grafana Dashboard**: http://localhost:3001 (admin/admin)
78
- - **Prometheus**: http://localhost:9090
79
-
80
- ### 4. Health Check
81
-
82
- ```bash
83
- # Check system health
84
- curl http://localhost/health
85
-
86
- # Check agent health
87
- curl http://localhost/agent/agent-1/health
88
- ```
89
-
90
- ## 🔧 Configuration
91
-
92
- ### Environment Variables
93
-
94
- ```bash
95
- # Orchestration Controller
96
- NODE_ENV=development
97
- LOG_LEVEL=info
98
- HEALTH_CHECK_INTERVAL=30000
99
- MAX_CONCURRENCY=80
100
- MIN_INSTANCES=1
101
- MAX_INSTANCES=10
102
-
103
- # Agent Configuration
104
- AGENT_ID=agent-1
105
- PORT=8080
106
- ```
107
-
108
- ### Load Balancer Settings
109
-
110
- Edit `nginx.conf` to modify:
111
-
112
- - Load balancing algorithm
113
- - Session affinity settings
114
- - Rate limiting
115
- - Health check endpoints
116
-
117
- ### Monitoring Configuration
118
-
119
- Edit `prometheus.yml` to customize:
120
-
121
- - Scrape intervals
122
- - Target endpoints
123
- - Alert rules
124
-
125
- ## 📊 Monitoring
126
-
127
- ### Metrics Available
128
-
129
- - **Agent Health**: Response time, error rates, CPU/memory usage
130
- - **Load Balancer**: Request distribution, session affinity stats
131
- - **Orchestration**: Queue depth, scaling events, circuit breaker status
132
- - **System**: Container resource usage, network metrics
133
-
134
- ### Grafana Dashboards
135
-
136
- Pre-configured dashboards for:
137
-
138
- - Agent Performance
139
- - Load Balancer Metrics
140
- - System Health
141
- - Scaling Events
142
-
143
- ## 🧪 Testing
144
-
145
- ### Load Testing
146
-
147
- ```bash
148
- # Run load test
149
- npm run load:test
150
-
151
- # Or use hey tool
152
- hey -n 1000 -c 10 http://localhost/api/test
153
- ```
154
-
155
- ### Health Checks
156
-
157
- ```bash
158
- # Check all agents
159
- npm run health:check
160
-
161
- # Individual agent check
162
- curl http://localhost/agent/agent-1/health
163
- ```
164
-
165
- ### Unit Tests
166
-
167
- ```bash
168
- npm test
169
- npm run test:coverage
170
- ```
171
-
172
- ## 🔄 Auto-scaling
173
-
174
- ### Local Simulation
175
-
176
- The system simulates Cloud Run auto-scaling behavior locally:
177
-
178
- 1. **Resource Monitoring**: CPU and memory usage tracking
179
- 2. **Scaling Triggers**: Automatic agent scaling based on metrics
180
- 3. **Queue Management**: Request queuing when at capacity
181
- 4. **Health Checks**: Continuous agent health monitoring
182
-
183
- ### Scaling Configuration
184
-
185
- ```yaml
186
- # docker-compose.yml
187
- deploy:
188
- resources:
189
- limits:
190
- cpus: '0.5'
191
- memory: 512M
192
- reservations:
193
- cpus: '0.25'
194
- memory: 256M
195
- ```
196
-
197
- ## 🚨 Error Handling
198
-
199
- ### Circuit Breaker
200
-
201
- - **Failure Threshold**: Configurable failure count
202
- - **Recovery Time**: Automatic recovery after timeout
203
- - **Fallback**: Graceful degradation when agents fail
204
-
205
- ### Retry Logic
206
-
207
- - **Exponential Backoff**: Smart retry with increasing delays
208
- - **Max Retries**: Configurable retry limits
209
- - **Timeout Handling**: Request timeout management
210
-
211
- ## 📈 Performance
212
-
213
- ### Benchmarks
214
-
215
- - **Latency**: < 200ms (95th percentile)
216
- - **Throughput**: > 1000 requests/second
217
- - **Error Rate**: < 1%
218
- - **Uptime**: 99.9%
219
-
220
- ### Optimization
221
-
222
- - **Connection Pooling**: Reuse connections
223
- - **Compression**: Gzip compression enabled
224
- - **Caching**: Response caching where appropriate
225
- - **Resource Limits**: Container resource constraints
226
-
227
- ## 🔒 Security
228
-
229
- ### Best Practices
230
-
231
- - **Non-root Containers**: All containers run as non-root users
232
- - **Resource Limits**: CPU and memory constraints
233
- - **Network Isolation**: Docker network isolation
234
- - **Input Validation**: Request validation and sanitization
235
-
236
- ### Authentication
237
-
238
- ```bash
239
- # Add authentication middleware
240
- npm run add:auth
241
- ```
242
-
243
- ## 🚀 Deployment
244
-
245
- ### Local Development
246
-
247
- ```bash
248
- # Development mode with hot reload
249
- docker-compose -f docker-compose.dev.yml up
250
-
251
- # With debugging
252
- docker-compose -f docker-compose.dev.yml up --build
253
- ```
254
-
255
- ### Staging Environment
256
-
257
- ```bash
258
- # Deploy to staging
259
- docker-compose -f docker-compose.staging.yml up -d
260
- ```
261
-
262
- ### Production Environment
263
-
264
- ```bash
265
- # Deploy to production
266
- docker-compose -f docker-compose.prod.yml up -d
267
- ```
268
-
269
- ## 📚 API Documentation
270
-
271
- ### Orchestration Controller
272
-
273
- ```bash
274
- # Get system status
275
- GET /status
276
-
277
- # Get metrics
278
- GET /metrics
279
-
280
- # Health check
281
- GET /health
282
- ```
283
-
284
- ### Agent Endpoints
285
-
286
- ```bash
287
- # Agent health
288
- GET /agent/{agentId}/health
289
-
290
- # Agent metrics
291
- GET /agent/{agentId}/metrics
292
-
293
- # Process request
294
- POST /agent/{agentId}/process
295
- ```
296
-
297
- ### Load Balancer
298
-
299
- ```bash
300
- # Health check
301
- GET /health
302
-
303
- # Status page
304
- GET /status
305
-
306
- # Metrics
307
- GET /metrics
308
- ```
309
-
310
- ## 🤝 Contributing
311
-
312
- 1. Follow the existing code style
313
- 2. Add tests for new features
314
- 3. Update documentation
315
- 4. Use conventional commits
316
-
317
- ## 📄 License
318
-
319
- MIT - See [LICENSE](LICENSE) file for details
320
-
321
- ## 🆘 Support
322
-
323
- - **Documentation**: Check the docs/ directory
324
- - **Issues**: Create GitHub issues
325
- - **Discussions**: Use GitHub discussions
326
-
327
- ## 🔄 Roadmap
328
-
329
- - [ ] Cloud Run integration
330
- - [ ] Advanced metrics
331
- - [ ] Machine learning scaling
332
- - [ ] Multi-region deployment
333
- - [ ] Advanced authentication
334
- - [ ] API rate limiting
335
- - [ ] WebSocket support
336
- - [ ] GraphQL API
337
-
338
- ---
339
-
340
- **Built with ❤️ by The AI Inc using stable, well-documented technologies**
@@ -1,69 +0,0 @@
1
- import { AgentInfo, AgentMetrics, HealthCheckResult } from '@/types';
2
- /**
3
- * Manages agent registration, health checks, and lifecycle
4
- * Uses stable, well-documented libraries for reliability
5
- */
6
- export declare class AgentManager {
7
- private agents;
8
- private logger;
9
- private healthCheckInterval;
10
- private healthCheckPath;
11
- constructor(healthCheckPath?: string);
12
- /**
13
- * Register a new agent
14
- */
15
- registerAgent(url: string, sessionId?: string): string;
16
- /**
17
- * Unregister an agent
18
- */
19
- unregisterAgent(agentId: string): boolean;
20
- /**
21
- * Get all healthy agents
22
- */
23
- getHealthyAgents(): AgentInfo[];
24
- /**
25
- * Get agent by ID
26
- */
27
- getAgent(agentId: string): AgentInfo | undefined;
28
- /**
29
- * Get agent by session ID
30
- */
31
- getAgentBySession(sessionId: string): AgentInfo | undefined;
32
- /**
33
- * Start health check monitoring
34
- */
35
- startHealthChecks(intervalMs?: number): void;
36
- /**
37
- * Stop health check monitoring
38
- */
39
- stopHealthChecks(): void;
40
- /**
41
- * Perform health check on a specific agent
42
- */
43
- checkAgentHealth(agentId: string): Promise<HealthCheckResult>;
44
- /**
45
- * Perform health checks on all agents
46
- */
47
- private performHealthChecks;
48
- /**
49
- * Update agent metrics
50
- */
51
- updateAgentMetrics(agentId: string, metrics: Partial<AgentMetrics>): void;
52
- /**
53
- * Get all agents
54
- */
55
- getAllAgents(): AgentInfo[];
56
- /**
57
- * Get agent count by health status
58
- */
59
- getAgentCounts(): {
60
- total: number;
61
- healthy: number;
62
- unhealthy: number;
63
- };
64
- /**
65
- * Clean up stale agents (not seen for more than threshold)
66
- */
67
- cleanupStaleAgents(thresholdMs?: number): number;
68
- }
69
- //# sourceMappingURL=agent-manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-manager.d.ts","sourceRoot":"","sources":["../../../src/services/agent-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAIrE;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAqC;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