@yesvara/svara 0.1.0 → 0.1.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/CONTRIBUTING.md +233 -0
- package/README.md +172 -22
- package/dist/{chunk-FEA5KIJN.mjs → chunk-WA3BIA3S.mjs} +356 -27
- package/dist/index.d.mts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +454 -269
- package/dist/index.mjs +81 -239
- package/dist/{retriever-4QY667XF.mjs → retriever-OTPBECGO.mjs} +1 -1
- package/package.json +27 -15
- package/src/core/agent.ts +89 -8
- package/src/core/types.ts +14 -1
- package/src/database/schema.ts +31 -6
- package/src/rag/chunker.ts +1 -0
- package/src/rag/retriever.ts +146 -33
- package/svara@1.0.0 +0 -0
- package/test-rag.ts +20 -0
- package/tsx +0 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Contributing to SvaraJS
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! We welcome all contributions—bug reports, feature requests, documentation improvements, and pull requests.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
Be respectful and constructive. We're building a framework for developers, so let's keep the community welcoming.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
### 1. Clone & Setup
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git clone https://github.com/yogiswara92/svarajs.git
|
|
17
|
+
cd svara
|
|
18
|
+
nvm use 20 # or 22
|
|
19
|
+
npm install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 2. Development
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm run dev # Watch mode for TypeScript
|
|
26
|
+
npm run build # Build for production
|
|
27
|
+
npm run typecheck # Type checking
|
|
28
|
+
npm test # Run tests
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 3. Project Structure
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
src/
|
|
35
|
+
├── core/ # Agent, LLM, types
|
|
36
|
+
├── app/ # SvaraApp HTTP wrapper
|
|
37
|
+
├── channels/ # Web, Telegram, WhatsApp
|
|
38
|
+
├── rag/ # Document loading, chunking, retrieval
|
|
39
|
+
├── memory/ # Conversation history
|
|
40
|
+
├── tools/ # Tool definition & registry
|
|
41
|
+
├── database/ # SQLite wrapper
|
|
42
|
+
├── cli/ # CLI commands
|
|
43
|
+
└── types.ts # Public API types
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Reporting Issues
|
|
49
|
+
|
|
50
|
+
**Before opening an issue:**
|
|
51
|
+
- Check [existing issues](https://github.com/yogiswara92/svarajs/issues)
|
|
52
|
+
- Try the latest dev version: `npm run dev`
|
|
53
|
+
|
|
54
|
+
**When reporting, include:**
|
|
55
|
+
- Clear title + description
|
|
56
|
+
- Steps to reproduce
|
|
57
|
+
- Expected vs actual behavior
|
|
58
|
+
- Node version, OS, environment
|
|
59
|
+
- Code snippet (if applicable)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Submitting PRs
|
|
64
|
+
|
|
65
|
+
### Before You Start
|
|
66
|
+
|
|
67
|
+
1. **Check existing PRs** to avoid duplicates
|
|
68
|
+
2. **Open an issue first** for major changes (discuss approach)
|
|
69
|
+
3. **Fork & create a branch:**
|
|
70
|
+
```bash
|
|
71
|
+
git checkout -b feature/your-feature-name
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### While Developing
|
|
75
|
+
|
|
76
|
+
- Follow **existing code style** (no strict linter, but be consistent)
|
|
77
|
+
- Keep changes **focused & minimal**
|
|
78
|
+
- Write clear commit messages (see below)
|
|
79
|
+
- Test locally: `npm run build && npm run typecheck`
|
|
80
|
+
|
|
81
|
+
### Before Submitting PR
|
|
82
|
+
|
|
83
|
+
1. **Run tests:**
|
|
84
|
+
```bash
|
|
85
|
+
npm test
|
|
86
|
+
npm run typecheck
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
2. **Update docs** if adding/changing public APIs
|
|
90
|
+
|
|
91
|
+
3. **Commit with clear messages:**
|
|
92
|
+
```bash
|
|
93
|
+
git commit -m "feat: add support for custom embeddings provider"
|
|
94
|
+
git commit -m "fix: resolve memory leak in vector store"
|
|
95
|
+
git commit -m "docs: improve RAG examples in README"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
4. **Push & open PR:**
|
|
99
|
+
```bash
|
|
100
|
+
git push origin feature/your-feature-name
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### PR Guidelines
|
|
104
|
+
|
|
105
|
+
- **Title:** Start with `feat:`, `fix:`, `docs:`, `refactor:`, etc.
|
|
106
|
+
- **Description:** What changed and why
|
|
107
|
+
- **Link issues:** "Closes #123" in description
|
|
108
|
+
- **Keep it focused:** One feature/fix per PR
|
|
109
|
+
- **Minimal dependencies:** Discuss before adding packages
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Code Style
|
|
114
|
+
|
|
115
|
+
We follow these patterns (not strict, but consistent):
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
// Imports
|
|
119
|
+
import { SvaraAgent } from '../core/agent.js';
|
|
120
|
+
import type { Tool } from '../types.js';
|
|
121
|
+
|
|
122
|
+
// Exports
|
|
123
|
+
export class MyClass { }
|
|
124
|
+
export type { MyType };
|
|
125
|
+
|
|
126
|
+
// Naming
|
|
127
|
+
const myVariable = 'value'; // camelCase
|
|
128
|
+
const MY_CONSTANT = 'VALUE'; // UPPER_SNAKE_CASE (rarely used)
|
|
129
|
+
class MyClass { } // PascalCase
|
|
130
|
+
|
|
131
|
+
// Comments
|
|
132
|
+
// Single line for brief explanation
|
|
133
|
+
/**
|
|
134
|
+
* Multi-line for public API documentation.
|
|
135
|
+
* Explain what it does, not how.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
// Error handling
|
|
139
|
+
throw new Error('[@yesvara/svara] Clear error message');
|
|
140
|
+
|
|
141
|
+
// Async/await
|
|
142
|
+
async function load() {
|
|
143
|
+
try {
|
|
144
|
+
return await operation();
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error('[SvaraJS] Error message:', error);
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Testing
|
|
155
|
+
|
|
156
|
+
Currently minimal test suite. Before submitting:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npm run typecheck
|
|
160
|
+
npm run build
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
If adding features:
|
|
164
|
+
- Test locally with `npm run dev`
|
|
165
|
+
- Consider adding tests in `src/__tests__/`
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Commit Message Format
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
<type>: <subject>
|
|
173
|
+
|
|
174
|
+
<body (optional)>
|
|
175
|
+
|
|
176
|
+
<footer (optional)>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Types:**
|
|
180
|
+
- `feat:` - New feature
|
|
181
|
+
- `fix:` - Bug fix
|
|
182
|
+
- `docs:` - Documentation
|
|
183
|
+
- `refactor:` - Code restructuring (no behavior change)
|
|
184
|
+
- `perf:` - Performance improvement
|
|
185
|
+
- `test:` - Test-related
|
|
186
|
+
- `chore:` - Dependency updates, build config, etc.
|
|
187
|
+
|
|
188
|
+
**Examples:**
|
|
189
|
+
```
|
|
190
|
+
feat: add support for Groq API provider
|
|
191
|
+
|
|
192
|
+
- Auto-detect model from "groq-" prefix
|
|
193
|
+
- Support streaming responses
|
|
194
|
+
- Add tests for Groq integration
|
|
195
|
+
|
|
196
|
+
Closes #45
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
fix: resolve memory leak in vector store
|
|
201
|
+
|
|
202
|
+
The InMemoryVectorStore was not clearing old entries.
|
|
203
|
+
Now properly clears when adding > 10k entries.
|
|
204
|
+
|
|
205
|
+
Fixes #123
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Release Process
|
|
211
|
+
|
|
212
|
+
Maintainers only:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
npm version minor # or patch, major
|
|
216
|
+
npm publish
|
|
217
|
+
git push origin main --tags
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Questions?
|
|
223
|
+
|
|
224
|
+
- **Issues:** [GitHub Issues](https://github.com/yogiswara92/svarajs/issues)
|
|
225
|
+
- **Discussions:** [GitHub Discussions](https://github.com/yogiswara92/svarajs/discussions)
|
|
226
|
+
- **Email:** yogiswaragheartha@gmail.com / admin@yesvara.com
|
|
227
|
+
- **Website:** https://yesvara.com
|
|
228
|
+
- **Whatsapp:** [+6285171010456](https://wa.me/6285171010456)
|
|
229
|
+
- **LinkedIn:** [Yogiswara Gheartha](https://www.linkedin.com/in/igb-yogiswara-gheartha-st-mmt-969b6b117/)
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
Thanks for contributing to SvaraJS!
|
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**Build AI agents in 15 lines. Ship to production.**
|
|
6
6
|
|
|
7
|
-
A batteries-included Node.js framework for building agentic AI backends
|
|
8
|
-
|
|
7
|
+
A batteries-included Node.js framework for building agentic AI backends.
|
|
8
|
+
Multi-channel, RAG-ready, and designed for developers who value simplicity.
|
|
9
9
|
|
|
10
10
|
[](https://www.npmjs.com/package/@yesvara/svara)
|
|
11
11
|
[](./LICENSE)
|
|
@@ -37,7 +37,7 @@ app.listen(3000);
|
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
That's it. No pipeline setup. No embedding boilerplate. No webhook configuration.
|
|
40
|
-
**Convention over configuration
|
|
40
|
+
**Convention over configuration (like Express, but for AI).**
|
|
41
41
|
|
|
42
42
|
---
|
|
43
43
|
|
|
@@ -45,13 +45,16 @@ That's it. No pipeline setup. No embedding boilerplate. No webhook configuration
|
|
|
45
45
|
|
|
46
46
|
| | |
|
|
47
47
|
|---|---|
|
|
48
|
-
| **Zero-config LLM** | Pass a model name
|
|
48
|
+
| **Zero-config LLM** | Pass a model name, provider is auto-detected |
|
|
49
49
|
| **Instant RAG** | Point to a folder, documents are indexed automatically |
|
|
50
50
|
| **Multi-channel** | WhatsApp, Telegram, and Web from one agent |
|
|
51
51
|
| **Tool calling** | Declarative tools with full TypeScript types |
|
|
52
52
|
| **Conversation memory** | Automatic per-session history, configurable window |
|
|
53
53
|
| **Express-compatible** | `agent.handler()` drops into any existing app |
|
|
54
|
-
| **Built-in database** |
|
|
54
|
+
| **Built-in database** | Persistent SQLite for users, sessions, RAG chunks, and state |
|
|
55
|
+
| **RAG per agent** | Each agent has isolated knowledge base, no cross-contamination |
|
|
56
|
+
| **RAG persistence** | Vector embeddings stored in SQLite, survive restarts, auto-dedup |
|
|
57
|
+
| **User tracking** | Auto-tracks users and sessions with timestamps |
|
|
55
58
|
| **CLI included** | `svara new`, `svara dev`, `svara build` |
|
|
56
59
|
|
|
57
60
|
---
|
|
@@ -101,17 +104,23 @@ npx tsx src/index.ts
|
|
|
101
104
|
```bash
|
|
102
105
|
curl -X POST http://localhost:3000/chat \
|
|
103
106
|
-H "Content-Type: application/json" \
|
|
104
|
-
-d '{
|
|
107
|
+
-d '{
|
|
108
|
+
"message": "Hello! What can you do?",
|
|
109
|
+
"userId": "user-1",
|
|
110
|
+
"sessionId": "user-1-session-1"
|
|
111
|
+
}'
|
|
105
112
|
```
|
|
106
113
|
|
|
107
114
|
```json
|
|
108
115
|
{
|
|
109
116
|
"response": "Hi! I'm Aria, your AI assistant...",
|
|
110
|
-
"sessionId": "user-1",
|
|
117
|
+
"sessionId": "user-1-session-1",
|
|
111
118
|
"usage": { "totalTokens": 142 }
|
|
112
119
|
}
|
|
113
120
|
```
|
|
114
121
|
|
|
122
|
+
The agent automatically tracks users and sessions in the SQLite database.
|
|
123
|
+
|
|
115
124
|
---
|
|
116
125
|
|
|
117
126
|
## Supported Models
|
|
@@ -143,13 +152,13 @@ The central class. Configure once, use everywhere.
|
|
|
143
152
|
```ts
|
|
144
153
|
const agent = new SvaraAgent({
|
|
145
154
|
name: 'Support Bot', // Display name (used in logs & system prompt)
|
|
146
|
-
model: 'gpt-4o-mini', // LLM model
|
|
147
|
-
systemPrompt: 'You are...', // Optional
|
|
148
|
-
knowledge: './docs', // Optional
|
|
149
|
-
memory: { window: 20 }, // Optional
|
|
150
|
-
tools: [myTool], // Optional
|
|
151
|
-
temperature: 0.7, // Optional
|
|
152
|
-
verbose: true, // Optional
|
|
155
|
+
model: 'gpt-4o-mini', // LLM model - provider auto-detected
|
|
156
|
+
systemPrompt: 'You are...', // Optional - sensible default based on name
|
|
157
|
+
knowledge: './docs', // Optional - folder/glob for RAG
|
|
158
|
+
memory: { window: 20 }, // Optional - conversation history window
|
|
159
|
+
tools: [myTool], // Optional - functions the agent can call
|
|
160
|
+
temperature: 0.7, // Optional - creativity (0–2)
|
|
161
|
+
verbose: true, // Optional - detailed logs
|
|
153
162
|
});
|
|
154
163
|
```
|
|
155
164
|
|
|
@@ -219,6 +228,85 @@ await agent.addKnowledge('./new-policy-2024.pdf');
|
|
|
219
228
|
|
|
220
229
|
Supported formats: **PDF, Markdown, TXT, DOCX, HTML, JSON**
|
|
221
230
|
|
|
231
|
+
**RAG Persistence & Per-Agent Isolation:**
|
|
232
|
+
|
|
233
|
+
Vector embeddings are automatically persisted to SQLite. Each agent has its own isolated knowledge base:
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const supportBot = new SvaraAgent({
|
|
237
|
+
name: 'SupportBot',
|
|
238
|
+
model: 'gpt-4o-mini',
|
|
239
|
+
knowledge: './docs/support', // Knowledge base 1
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
const salesBot = new SvaraAgent({
|
|
243
|
+
name: 'SalesBot',
|
|
244
|
+
model: 'gpt-4o-mini',
|
|
245
|
+
knowledge: './docs/sales', // Knowledge base 2
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
await supportBot.start();
|
|
249
|
+
await salesBot.start();
|
|
250
|
+
|
|
251
|
+
// Both agents run simultaneously with isolated RAG:
|
|
252
|
+
// - SupportBot only searches in support docs
|
|
253
|
+
// - SalesBot only searches in sales docs
|
|
254
|
+
// - No cross-contamination, efficient storage
|
|
255
|
+
// - Embeddings persist across restarts
|
|
256
|
+
// - Duplicate content skipped per agent
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**How it works:**
|
|
260
|
+
- Documents are embedded and stored in SQLite with agent name
|
|
261
|
+
- Each agent queries only its own chunks
|
|
262
|
+
- Deduplication happens per agent (same content in different agents is OK)
|
|
263
|
+
- Perfect for multi-agent systems with different domains
|
|
264
|
+
|
|
265
|
+
### User & Session Tracking
|
|
266
|
+
|
|
267
|
+
Every message automatically tracks the user and their session.
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
// Send message with userId and sessionId
|
|
271
|
+
const result = await agent.process('Help me with my order', {
|
|
272
|
+
userId: 'user-123',
|
|
273
|
+
sessionId: 'user-123-conversation-1'
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Database tracks:
|
|
277
|
+
// - svara_users: user-123 (first_seen, last_seen, metadata)
|
|
278
|
+
// - svara_sessions: session details, linked to user-123
|
|
279
|
+
// - svara_messages: conversation history for this session
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Query user data:
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
import { SvaraDB } from '@yesvara/svara';
|
|
286
|
+
|
|
287
|
+
const db = new SvaraDB('./data/svara.db');
|
|
288
|
+
|
|
289
|
+
// Get all users
|
|
290
|
+
const users = db.query('SELECT * FROM svara_users');
|
|
291
|
+
|
|
292
|
+
// Get sessions for a user
|
|
293
|
+
const sessions = db.query(
|
|
294
|
+
'SELECT * FROM svara_sessions WHERE user_id = ?',
|
|
295
|
+
['user-123']
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
// Get chat history for a session
|
|
299
|
+
const messages = db.query(
|
|
300
|
+
'SELECT * FROM svara_messages WHERE session_id = ? ORDER BY created_at',
|
|
301
|
+
['user-123-conversation-1']
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
// Check RAG chunks (with dedup tracking)
|
|
305
|
+
const chunks = db.query(
|
|
306
|
+
'SELECT id, content, content_hash FROM svara_chunks LIMIT 10'
|
|
307
|
+
);
|
|
308
|
+
```
|
|
309
|
+
|
|
222
310
|
### Channels
|
|
223
311
|
|
|
224
312
|
One agent, multiple platforms.
|
|
@@ -372,15 +460,30 @@ $ svara new my-app
|
|
|
372
460
|
|
|
373
461
|
## Built-in Database
|
|
374
462
|
|
|
375
|
-
|
|
463
|
+
Persistent SQLite for users, sessions, conversation history, and RAG vectors.
|
|
376
464
|
|
|
377
465
|
```ts
|
|
378
466
|
import { SvaraDB } from '@yesvara/svara';
|
|
379
467
|
|
|
380
|
-
const db = new SvaraDB('./data/
|
|
468
|
+
const db = new SvaraDB('./data/svara.db');
|
|
469
|
+
|
|
470
|
+
// Built-in tables (auto-created):
|
|
471
|
+
// - svara_users: user registry with timestamps
|
|
472
|
+
// - svara_sessions: conversation sessions linked to users
|
|
473
|
+
// - svara_messages: conversation history
|
|
474
|
+
// - svara_chunks: RAG vectors with deduplication
|
|
475
|
+
// - svara_kv: key-value store for app state
|
|
476
|
+
|
|
477
|
+
// Query users
|
|
478
|
+
const activeUsers = db.query(
|
|
479
|
+
'SELECT id, display_name, last_seen FROM svara_users WHERE last_seen > unixepoch() - 86400'
|
|
480
|
+
);
|
|
381
481
|
|
|
382
|
-
//
|
|
383
|
-
const
|
|
482
|
+
// Get conversation history
|
|
483
|
+
const history = db.query(
|
|
484
|
+
'SELECT role, content FROM svara_messages WHERE session_id = ? ORDER BY created_at',
|
|
485
|
+
['session-id']
|
|
486
|
+
);
|
|
384
487
|
|
|
385
488
|
// Key-value store
|
|
386
489
|
db.kv.set('feature:rag', true);
|
|
@@ -446,8 +549,8 @@ Request:
|
|
|
446
549
|
```json
|
|
447
550
|
{
|
|
448
551
|
"message": "What is the refund policy?",
|
|
449
|
-
"
|
|
450
|
-
"
|
|
552
|
+
"userId": "alice@example.com",
|
|
553
|
+
"sessionId": "alice-session-1"
|
|
451
554
|
}
|
|
452
555
|
```
|
|
453
556
|
|
|
@@ -455,7 +558,7 @@ Response:
|
|
|
455
558
|
```json
|
|
456
559
|
{
|
|
457
560
|
"response": "Our refund policy allows returns within 30 days...",
|
|
458
|
-
"sessionId": "
|
|
561
|
+
"sessionId": "alice-session-1",
|
|
459
562
|
"usage": {
|
|
460
563
|
"promptTokens": 312,
|
|
461
564
|
"completionTokens": 89,
|
|
@@ -465,16 +568,63 @@ Response:
|
|
|
465
568
|
}
|
|
466
569
|
```
|
|
467
570
|
|
|
571
|
+
**Note:** `userId` and `sessionId` are automatically tracked in the SQLite database for user management and conversation history.
|
|
572
|
+
|
|
468
573
|
**`GET /health`** — always returns `{ "status": "ok" }`
|
|
469
574
|
|
|
470
575
|
---
|
|
471
576
|
|
|
577
|
+
## Database Schema
|
|
578
|
+
|
|
579
|
+
SvaraJS automatically creates and manages these SQLite tables:
|
|
580
|
+
|
|
581
|
+
| Table | Purpose | Auto-Managed |
|
|
582
|
+
|-------|---------|--------------|
|
|
583
|
+
| `svara_users` | User registry (first_seen, last_seen, metadata) | ✅ Yes |
|
|
584
|
+
| `svara_sessions` | Conversation sessions linked to users | ✅ Yes |
|
|
585
|
+
| `svara_messages` | Full conversation history per session | ✅ Yes |
|
|
586
|
+
| `svara_chunks` | RAG vectors **isolated per agent** with deduplication | ✅ Yes |
|
|
587
|
+
| `svara_documents` | Document registry and metadata | ✅ Yes |
|
|
588
|
+
| `svara_kv` | Key-value store for app state | ✅ Yes |
|
|
589
|
+
| `svara_meta` | Framework metadata and versions | ✅ Yes |
|
|
590
|
+
|
|
591
|
+
**RAG Isolation:**
|
|
592
|
+
|
|
593
|
+
Each agent's RAG data is stored separately using the `agent_name` column:
|
|
594
|
+
|
|
595
|
+
```ts
|
|
596
|
+
// Query RAG chunks for specific agent
|
|
597
|
+
const supportChunks = db.query(
|
|
598
|
+
'SELECT COUNT(*) as count FROM svara_chunks WHERE agent_name = ?',
|
|
599
|
+
['SupportBot']
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
const salesChunks = db.query(
|
|
603
|
+
'SELECT COUNT(*) as count FROM svara_chunks WHERE agent_name = ?',
|
|
604
|
+
['SalesBot']
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
// Export conversation analytics
|
|
608
|
+
db.query(`
|
|
609
|
+
SELECT u.id, u.display_name, COUNT(m.id) as message_count
|
|
610
|
+
FROM svara_users u
|
|
611
|
+
LEFT JOIN svara_messages m ON u.id = (
|
|
612
|
+
SELECT user_id FROM svara_sessions WHERE id = m.session_id
|
|
613
|
+
)
|
|
614
|
+
WHERE u.last_seen > unixepoch() - 86400
|
|
615
|
+
GROUP BY u.id
|
|
616
|
+
ORDER BY message_count DESC
|
|
617
|
+
`);
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
---
|
|
621
|
+
|
|
472
622
|
## Contributing
|
|
473
623
|
|
|
474
624
|
Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) first.
|
|
475
625
|
|
|
476
626
|
```bash
|
|
477
|
-
git clone https://github.com/
|
|
627
|
+
git clone https://github.com/yogiswara92/svarajs
|
|
478
628
|
cd svara
|
|
479
629
|
npm install
|
|
480
630
|
npm run dev
|