@lantanios/agentic-server 0.1.0 ā 0.2.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/.env.example +16 -16
- package/README.md +397 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -3
- package/dist/index.js.map +1 -1
- package/dist/namespaces/context.d.ts +9 -0
- package/dist/namespaces/context.d.ts.map +1 -0
- package/dist/namespaces/context.js +247 -0
- package/dist/namespaces/context.js.map +1 -0
- package/dist/namespaces/index.d.ts +2 -0
- package/dist/namespaces/index.d.ts.map +1 -1
- package/dist/namespaces/index.js +5 -1
- package/dist/namespaces/index.js.map +1 -1
- package/dist/namespaces/sync.d.ts +13 -0
- package/dist/namespaces/sync.d.ts.map +1 -0
- package/dist/namespaces/sync.js +140 -0
- package/dist/namespaces/sync.js.map +1 -0
- package/package.json +19 -12
- package/src/config.ts +6 -3
- package/src/index.ts +31 -5
- package/src/namespaces/context.ts +283 -0
- package/src/namespaces/index.ts +2 -0
- package/src/namespaces/sync.ts +155 -0
- package/tsconfig.json +13 -13
- package/tsconfig.tsbuildinfo +1 -1
package/.env.example
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# Server
|
|
2
|
-
PORT=3847
|
|
3
|
-
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
|
|
4
|
-
|
|
5
|
-
# MongoDB
|
|
6
|
-
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/Agentic?retryWrites=true&w=majority
|
|
7
|
-
|
|
8
|
-
# OpenAI (for embeddings + TTS fallback)
|
|
9
|
-
OPENAI_API_KEY=sk-...
|
|
10
|
-
|
|
11
|
-
# Local audio server (your PC)
|
|
12
|
-
LOCAL_STT_ENDPOINT=http://localhost:8001
|
|
13
|
-
LOCAL_TTS_ENDPOINT=http://localhost:8001
|
|
14
|
-
|
|
15
|
-
# Cloud fallbacks (optional)
|
|
16
|
-
DEEPGRAM_API_KEY=
|
|
1
|
+
# Server
|
|
2
|
+
PORT=3847
|
|
3
|
+
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
|
|
4
|
+
|
|
5
|
+
# MongoDB
|
|
6
|
+
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/Agentic?retryWrites=true&w=majority
|
|
7
|
+
|
|
8
|
+
# OpenAI (for embeddings + TTS fallback)
|
|
9
|
+
OPENAI_API_KEY=sk-...
|
|
10
|
+
|
|
11
|
+
# Local audio server (your PC)
|
|
12
|
+
LOCAL_STT_ENDPOINT=http://localhost:8001
|
|
13
|
+
LOCAL_TTS_ENDPOINT=http://localhost:8001
|
|
14
|
+
|
|
15
|
+
# Cloud fallbacks (optional)
|
|
16
|
+
DEEPGRAM_API_KEY=
|
package/README.md
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
# @lantanios/agentic-server
|
|
2
|
+
|
|
3
|
+
Real-time Socket.IO server combining memory, audio, and event communication for AI agents.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- š **Socket.IO namespaces** ā Separate channels for memory, audio, events
|
|
8
|
+
- š§ **Memory namespace** ā CRUD + vector search via WebSocket
|
|
9
|
+
- šļø **Audio namespace** ā Real-time STT/TTS streaming
|
|
10
|
+
- š” **Events namespace** ā Pub/sub, broadcast, direct messaging between agents
|
|
11
|
+
- š **Priority providers** ā Local-first audio with cloud fallback
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @lantanios/agentic-server
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
Create `.env`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Server
|
|
25
|
+
PORT=3847
|
|
26
|
+
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
|
|
27
|
+
|
|
28
|
+
# MongoDB (required)
|
|
29
|
+
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/Agentic
|
|
30
|
+
|
|
31
|
+
# OpenAI (required for embeddings, optional for TTS)
|
|
32
|
+
OPENAI_API_KEY=sk-...
|
|
33
|
+
|
|
34
|
+
# Local audio server (optional, for local STT/TTS)
|
|
35
|
+
LOCAL_STT_ENDPOINT=http://localhost:8001
|
|
36
|
+
LOCAL_TTS_ENDPOINT=http://localhost:8001
|
|
37
|
+
|
|
38
|
+
# Cloud fallbacks (optional)
|
|
39
|
+
DEEPGRAM_API_KEY=...
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
### Run the Server
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Using npx
|
|
48
|
+
npx @lantanios/agentic-server
|
|
49
|
+
|
|
50
|
+
# Or in code
|
|
51
|
+
import '@lantanios/agentic-server';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Connect from Client
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { io } from 'socket.io-client';
|
|
58
|
+
|
|
59
|
+
// Connect to memory namespace
|
|
60
|
+
const memory = io('http://localhost:3847/memory', {
|
|
61
|
+
auth: { agentId: 'pip' } // Required: your agent ID
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Connect to audio namespace
|
|
65
|
+
const audio = io('http://localhost:3847/audio', {
|
|
66
|
+
auth: { agentId: 'pip' }
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Connect to events namespace
|
|
70
|
+
const events = io('http://localhost:3847/events', {
|
|
71
|
+
auth: { agentId: 'pip' }
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Socket.IO Namespaces
|
|
76
|
+
|
|
77
|
+
### `/memory` ā Memory Operations
|
|
78
|
+
|
|
79
|
+
All operations require `agentId` in auth. Agents can only access their own memories.
|
|
80
|
+
|
|
81
|
+
#### Create Memory
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
memory.emit('create', {
|
|
85
|
+
type: 'fact',
|
|
86
|
+
content: 'User prefers dark mode',
|
|
87
|
+
metadata: {
|
|
88
|
+
importance: 4,
|
|
89
|
+
tags: ['preferences', 'ui'],
|
|
90
|
+
project: 'settings',
|
|
91
|
+
}
|
|
92
|
+
}, (response) => {
|
|
93
|
+
if (response.success) {
|
|
94
|
+
console.log('Created:', response.memory);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### List Memories
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
memory.emit('list', {
|
|
103
|
+
type: 'fact', // optional filter
|
|
104
|
+
project: 'settings', // optional filter
|
|
105
|
+
minImportance: 3, // optional filter
|
|
106
|
+
limit: 20,
|
|
107
|
+
offset: 0,
|
|
108
|
+
}, (response) => {
|
|
109
|
+
console.log(response.memories);
|
|
110
|
+
console.log(`Total: ${response.total}`);
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### Vector Search
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
memory.emit('search', {
|
|
118
|
+
query: 'what are the user preferences?',
|
|
119
|
+
limit: 10,
|
|
120
|
+
minScore: 0.7,
|
|
121
|
+
}, (response) => {
|
|
122
|
+
response.results.forEach(r => {
|
|
123
|
+
console.log(`${r.score.toFixed(2)}: ${r.content}`);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Recall Context
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
memory.emit('recall', {
|
|
132
|
+
context: 'Starting work on the Lantanios project',
|
|
133
|
+
limit: 30,
|
|
134
|
+
}, (response) => {
|
|
135
|
+
console.log('Important:', response.breakdown.important);
|
|
136
|
+
console.log('Context-matched:', response.breakdown.contextMatched);
|
|
137
|
+
console.log('Recent:', response.breakdown.recent);
|
|
138
|
+
console.log('Memories:', response.memories);
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### Other Operations
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
// Get single memory
|
|
146
|
+
memory.emit('get', memoryId, callback);
|
|
147
|
+
|
|
148
|
+
// Update memory
|
|
149
|
+
memory.emit('update', { id: memoryId, content: 'Updated content' }, callback);
|
|
150
|
+
|
|
151
|
+
// Delete memory (soft delete)
|
|
152
|
+
memory.emit('delete', memoryId, callback);
|
|
153
|
+
|
|
154
|
+
// Get summary stats
|
|
155
|
+
memory.emit('summary', (response) => {
|
|
156
|
+
console.log(response.summary);
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `/audio` ā Audio Streaming
|
|
161
|
+
|
|
162
|
+
#### Stream Recording
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// Start recording
|
|
166
|
+
audio.emit('stream:start', {}, (response) => {
|
|
167
|
+
console.log('Recording started');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Send audio chunks (from microphone)
|
|
171
|
+
mediaRecorder.ondataavailable = (e) => {
|
|
172
|
+
audio.emit('stream:chunk', e.data);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Stop and get transcription
|
|
176
|
+
audio.emit('stream:stop', { language: 'en' }, (response) => {
|
|
177
|
+
if (response.success) {
|
|
178
|
+
console.log('Transcript:', response.result.text);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Also emitted as event
|
|
183
|
+
audio.on('transcription', (result) => {
|
|
184
|
+
console.log('Transcript:', result.text);
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### One-shot Transcription
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
audio.emit('transcribe', {
|
|
192
|
+
audio: audioBuffer, // Buffer or ArrayBuffer
|
|
193
|
+
language: 'en',
|
|
194
|
+
provider: 'local-whisper', // optional: force provider
|
|
195
|
+
}, (response) => {
|
|
196
|
+
console.log(response.result.text);
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Text to Speech
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
// One-shot TTS
|
|
204
|
+
audio.emit('speak', {
|
|
205
|
+
text: 'Hello, how can I help you?',
|
|
206
|
+
voice: 'nova',
|
|
207
|
+
speed: 1.0,
|
|
208
|
+
format: 'mp3',
|
|
209
|
+
}, (response) => {
|
|
210
|
+
if (response.success) {
|
|
211
|
+
playAudio(response.audio); // Buffer
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Streaming TTS
|
|
216
|
+
audio.emit('speak:stream', {
|
|
217
|
+
text: 'This is a long response that will be streamed...',
|
|
218
|
+
voice: 'nova',
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
audio.on('speak:start', () => console.log('TTS started'));
|
|
222
|
+
audio.on('speak:chunk', (chunk) => streamToSpeaker(chunk));
|
|
223
|
+
audio.on('speak:end', () => console.log('TTS finished'));
|
|
224
|
+
audio.on('speak:error', (err) => console.error(err));
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### Check Providers
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
audio.emit('providers:status', (response) => {
|
|
231
|
+
console.log(response.status);
|
|
232
|
+
// { stt: { 'local-whisper': true }, tts: { 'local-piper': false, 'openai-tts': true } }
|
|
233
|
+
});
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### `/events` ā Agent Communication
|
|
237
|
+
|
|
238
|
+
#### Subscribe to Channels
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
events.emit('subscribe', 'project-updates', (response) => {
|
|
242
|
+
console.log(`Subscribed to ${response.channel}`);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
events.emit('unsubscribe', 'project-updates', callback);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### Publish to Channel
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
events.emit('publish', {
|
|
252
|
+
channel: 'project-updates',
|
|
253
|
+
event: 'task-completed',
|
|
254
|
+
payload: { taskId: '123', status: 'done' },
|
|
255
|
+
}, (response) => {
|
|
256
|
+
console.log(`Delivered to ${response.delivered} subscribers`);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// Receive events
|
|
260
|
+
events.on('event', (data) => {
|
|
261
|
+
console.log(`[${data.channel}] ${data.event} from ${data.from}:`, data.payload);
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
#### Broadcast to All Agents
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
events.emit('broadcast', {
|
|
269
|
+
event: 'system-alert',
|
|
270
|
+
payload: { message: 'Server restarting in 5 minutes' },
|
|
271
|
+
}, (response) => {
|
|
272
|
+
console.log(`Broadcast to ${response.delivered} agents`);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
events.on('broadcast', (data) => {
|
|
276
|
+
console.log(`Broadcast from ${data.from}:`, data.event, data.payload);
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### Direct Message
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
events.emit('dm', {
|
|
284
|
+
to: 'deep', // Target agent ID
|
|
285
|
+
event: 'private-message',
|
|
286
|
+
payload: { text: 'Hey Deep, can you check the Lantanios logs?' },
|
|
287
|
+
}, (response) => {
|
|
288
|
+
console.log(response.delivered ? 'Delivered' : 'Agent not online');
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
events.on('dm', (data) => {
|
|
292
|
+
console.log(`DM from ${data.from}:`, data.event, data.payload);
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### List Online Agents
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
events.emit('agents:list', (response) => {
|
|
300
|
+
console.log('Online agents:', response.agents);
|
|
301
|
+
// ['pip', 'deep']
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## REST Endpoints
|
|
306
|
+
|
|
307
|
+
| Method | Path | Description |
|
|
308
|
+
|--------|------|-------------|
|
|
309
|
+
| `GET` | `/health` | Health check with MongoDB and socket status |
|
|
310
|
+
| `GET` | `/providers` | Audio provider availability |
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
curl http://localhost:3847/health
|
|
314
|
+
# { "status": "ok", "mongodb": "connected", "sockets": 2 }
|
|
315
|
+
|
|
316
|
+
curl http://localhost:3847/providers
|
|
317
|
+
# { "status": "ok", "providers": { "stt": {...}, "tts": {...} } }
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Architecture
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
Client (Browser/Node)
|
|
324
|
+
ā
|
|
325
|
+
āāā Socket.IO āāāāāāŗ /memory āāāāāŗ MongoDB + OpenAI Embeddings
|
|
326
|
+
ā
|
|
327
|
+
āāā Socket.IO āāāāāāŗ /audio āāāāāŗ Local Whisper/Piper
|
|
328
|
+
ā āāāāŗ Deepgram/OpenAI (fallback)
|
|
329
|
+
ā
|
|
330
|
+
āāā Socket.IO āāāāāāŗ /events āāāāāŗ Pub/Sub (in-memory)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Example: Full Agent Connection
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
import { io } from 'socket.io-client';
|
|
337
|
+
|
|
338
|
+
class AgentClient {
|
|
339
|
+
private memory;
|
|
340
|
+
private audio;
|
|
341
|
+
private events;
|
|
342
|
+
|
|
343
|
+
constructor(serverUrl: string, agentId: string) {
|
|
344
|
+
const auth = { agentId };
|
|
345
|
+
|
|
346
|
+
this.memory = io(`${serverUrl}/memory`, { auth });
|
|
347
|
+
this.audio = io(`${serverUrl}/audio`, { auth });
|
|
348
|
+
this.events = io(`${serverUrl}/events`, { auth });
|
|
349
|
+
|
|
350
|
+
// Subscribe to relevant channels
|
|
351
|
+
this.events.emit('subscribe', 'system');
|
|
352
|
+
this.events.on('event', this.handleEvent.bind(this));
|
|
353
|
+
this.events.on('dm', this.handleDM.bind(this));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async remember(content: string, type = 'fact', importance = 3) {
|
|
357
|
+
return new Promise((resolve) => {
|
|
358
|
+
this.memory.emit('create', { type, content, metadata: { importance } }, resolve);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async search(query: string) {
|
|
363
|
+
return new Promise((resolve) => {
|
|
364
|
+
this.memory.emit('search', { query, limit: 10 }, resolve);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async transcribe(audioBuffer: Buffer) {
|
|
369
|
+
return new Promise((resolve) => {
|
|
370
|
+
this.audio.emit('transcribe', { audio: audioBuffer }, resolve);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
async speak(text: string) {
|
|
375
|
+
return new Promise((resolve) => {
|
|
376
|
+
this.audio.emit('speak', { text }, resolve);
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
private handleEvent(data) {
|
|
381
|
+
console.log(`Event from ${data.from}:`, data.event);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
private handleDM(data) {
|
|
385
|
+
console.log(`DM from ${data.from}:`, data.payload);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Usage
|
|
390
|
+
const agent = new AgentClient('http://localhost:3847', 'pip');
|
|
391
|
+
await agent.remember('User asked about weather', 'conversation', 2);
|
|
392
|
+
const results = await agent.search('weather conversations');
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
## License
|
|
396
|
+
|
|
397
|
+
Private - Lantanios
|
package/dist/config.d.ts
CHANGED
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;CA0BlB,CAAC;AAEF,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAWzC"}
|
package/dist/config.js
CHANGED
|
@@ -11,6 +11,8 @@ exports.config = {
|
|
|
11
11
|
port: parseInt(process.env.PORT || '3847', 10),
|
|
12
12
|
// MongoDB
|
|
13
13
|
mongoUri: process.env.MONGODB_URI || '',
|
|
14
|
+
// Redis (optional ā system degrades gracefully without it)
|
|
15
|
+
redisUrl: process.env.REDIS_URL || '',
|
|
14
16
|
// OpenAI (for embeddings)
|
|
15
17
|
openaiApiKey: process.env.OPENAI_API_KEY || '',
|
|
16
18
|
// CORS
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AA+BA,wCAWC;AA1CD,oDAA4B;AAC5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEH,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,EAAE,EAAE,CAAC;IAE9C,UAAU;IACV,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE;IAEvC,2DAA2D;IAC3D,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE;IAErC,0BAA0B;IAC1B,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;IAE9C,OAAO;IACP,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC;IAE9E,kBAAkB;IAClB,KAAK,EAAE;QACL,GAAG,EAAE;YACH,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,uBAAuB;YACxE,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE;SACnD;QACD,GAAG,EAAE;YACH,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,uBAAuB;YACxE,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;SAC/C;KACF;CACF,CAAC;AAEF,SAAgB,cAAc;IAC5B,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,CAAC,cAAM,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,CAAC,cAAM,CAAC,YAAY,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAQnC,QAAA,MAAM,GAAG,EAAE,WAAuB,CAAC;AAInC,QAAA,MAAM,UAAU,oGAAoB,CAAC;AAErC,QAAA,MAAM,EAAE,+HAMN,CAAC;AAiJH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const mongoose_1 = __importDefault(require("mongoose"));
|
|
|
12
12
|
const config_1 = require("./config");
|
|
13
13
|
const namespaces_1 = require("./namespaces");
|
|
14
14
|
const agentic_audio_1 = require("@lantanios/agentic-audio");
|
|
15
|
+
const agentic_redis_1 = require("@lantanios/agentic-redis");
|
|
15
16
|
const app = (0, express_1.default)();
|
|
16
17
|
exports.app = app;
|
|
17
18
|
app.use((0, cors_1.default)({ origin: config_1.config.corsOrigins }));
|
|
@@ -77,10 +78,19 @@ function createAudioService() {
|
|
|
77
78
|
// Health check
|
|
78
79
|
app.get('/health', async (_req, res) => {
|
|
79
80
|
const mongoStatus = mongoose_1.default.connection.readyState === 1 ? 'connected' : 'disconnected';
|
|
81
|
+
let redisHealth = { connected: false, latencyMs: null };
|
|
82
|
+
try {
|
|
83
|
+
redisHealth = await (0, agentic_redis_1.checkRedisHealth)();
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Redis not available
|
|
87
|
+
}
|
|
80
88
|
res.json({
|
|
81
89
|
status: 'ok',
|
|
82
90
|
timestamp: new Date().toISOString(),
|
|
83
91
|
mongodb: mongoStatus,
|
|
92
|
+
redis: redisHealth.connected ? 'connected' : 'disconnected',
|
|
93
|
+
redisLatencyMs: redisHealth.latencyMs,
|
|
84
94
|
sockets: io.engine.clientsCount,
|
|
85
95
|
});
|
|
86
96
|
});
|
|
@@ -114,20 +124,38 @@ async function start() {
|
|
|
114
124
|
console.error('ā MongoDB connection failed:', err);
|
|
115
125
|
}
|
|
116
126
|
}
|
|
127
|
+
// Connect to Redis (optional ā degrades gracefully)
|
|
128
|
+
if (config_1.config.redisUrl) {
|
|
129
|
+
try {
|
|
130
|
+
(0, agentic_redis_1.initRedis)({ url: config_1.config.redisUrl });
|
|
131
|
+
await (0, agentic_redis_1.connectRedis)();
|
|
132
|
+
console.log('ā Connected to Redis');
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
console.warn('ā Redis connection failed (continuing without):', err.message);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
console.log('ā Redis not configured (set REDIS_URL to enable caching)');
|
|
140
|
+
}
|
|
117
141
|
// Create audio service
|
|
118
142
|
const audioService = createAudioService();
|
|
119
143
|
// Setup Socket.IO namespaces
|
|
120
144
|
(0, namespaces_1.setupMemoryNamespace)(io.of('/memory'));
|
|
121
145
|
(0, namespaces_1.setupAudioNamespace)(io.of('/audio'), { audioService });
|
|
122
146
|
(0, namespaces_1.setupEventsNamespace)(io.of('/events'));
|
|
147
|
+
(0, namespaces_1.setupContextNamespace)(io.of('/context'));
|
|
148
|
+
(0, namespaces_1.setupSyncNamespace)(io.of('/sync'));
|
|
123
149
|
console.log('ā Socket.IO namespaces configured');
|
|
124
150
|
// Start server
|
|
125
151
|
httpServer.listen(config_1.config.port, () => {
|
|
126
152
|
console.log(`\nā @lantanios/agentic-server running on http://localhost:${config_1.config.port}`);
|
|
127
153
|
console.log('\nNamespaces:');
|
|
128
|
-
console.log(' /memory
|
|
129
|
-
console.log(' /
|
|
130
|
-
console.log(' /
|
|
154
|
+
console.log(' /memory - Memory CRUD + vector search');
|
|
155
|
+
console.log(' /context - Context assembly + goals + search');
|
|
156
|
+
console.log(' /sync - Bidirectional SQLite ā MongoDB sync');
|
|
157
|
+
console.log(' /audio - STT/TTS streaming');
|
|
158
|
+
console.log(' /events - Pub/sub + direct messaging');
|
|
131
159
|
console.log('\nREST endpoints:');
|
|
132
160
|
console.log(' GET /health - Health check');
|
|
133
161
|
console.log(' GET /providers - Audio provider status');
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA+C;AAC/C,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AC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACzC,IAAA,+BAAkB,EAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEnC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IAEjD,eAAe;IACf,UAAU,CAAC,MAAM,CAAC,eAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QAClC,OAAO,CAAC,GAAG,CAAC,6DAA6D,eAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACxF,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /context Namespace
|
|
3
|
+
*
|
|
4
|
+
* Context assembly, search, goal management, and state tracking
|
|
5
|
+
* via Socket.IO. Central coordination point for the Context Engine.
|
|
6
|
+
*/
|
|
7
|
+
import { Namespace } from 'socket.io';
|
|
8
|
+
export declare function setupContextNamespace(io: Namespace): void;
|
|
9
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/namespaces/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAU,MAAM,WAAW,CAAC;AAqB9C,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,SAAS,QA8PlD"}
|