@yesvara/svara 0.1.3 → 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/README.md +4 -6
- package/dist/cli/index.js +35 -37
- package/dist/cli/index.mjs +1 -1
- package/dist/{new-7K4NIDZO.mjs → new-ULRP6IUQ.mjs} +35 -37
- package/package.json +1 -1
- package/src/cli/commands/new.ts +35 -41
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<!-- # @yesvara/svara -->
|
|
5
5
|
|
|
6
|
-
**Build AI agents in
|
|
6
|
+
**Build AI agents in less than 9 lines. Ship to production.**
|
|
7
7
|
|
|
8
8
|
A batteries-included Node.js framework for building agentic AI backends.
|
|
9
9
|
Multi-channel, RAG-ready, and designed for developers who value simplicity.
|
|
@@ -22,18 +22,16 @@ Multi-channel, RAG-ready, and designed for developers who value simplicity.
|
|
|
22
22
|
Most AI frameworks make you think about infrastructure. SvaraJS makes you think about your agent.
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
import { SvaraApp, SvaraAgent } from '@yesvara/svara';
|
|
26
|
-
|
|
27
|
-
const app = new SvaraApp();
|
|
25
|
+
import { SvaraApp, SvaraAgent, createTool } from '@yesvara/svara';
|
|
28
26
|
|
|
29
27
|
const agent = new SvaraAgent({
|
|
30
28
|
name: 'Support Bot',
|
|
31
29
|
model: 'gpt-4o-mini', // provider auto-detected
|
|
32
30
|
knowledge: './docs', // PDF, MD, TXT, just point to a folder
|
|
31
|
+
tools: [tool_1, tool_2, tool_3], // Agent choose the right tool for answer
|
|
33
32
|
});
|
|
34
33
|
|
|
35
|
-
app.route('/chat', agent.handler());
|
|
36
|
-
app.listen(3000);
|
|
34
|
+
const app = new SvaraApp().route('/chat', agent.handler()).listen(3000);
|
|
37
35
|
// Done. Your agent handles 1000 conversations.
|
|
38
36
|
```
|
|
39
37
|
|
package/dist/cli/index.js
CHANGED
|
@@ -97,7 +97,7 @@ function generatePackageJson(name) {
|
|
|
97
97
|
start: "node dist/index.js"
|
|
98
98
|
},
|
|
99
99
|
dependencies: {
|
|
100
|
-
|
|
100
|
+
"@yesvara/svara": "^0.1.3",
|
|
101
101
|
dotenv: "^16.4.5"
|
|
102
102
|
},
|
|
103
103
|
devDependencies: {
|
|
@@ -144,55 +144,53 @@ function generateIndexFile(name, provider, channels) {
|
|
|
144
144
|
anthropic: "claude-opus-4-6",
|
|
145
145
|
ollama: "llama3"
|
|
146
146
|
};
|
|
147
|
-
const channelSetup = channels.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
const channelSetup = channels.includes("web") ? `const app = new SvaraApp({ cors: true });
|
|
148
|
+
app.route('/chat', agent.handler());
|
|
149
|
+
app.listen(3000);` : channels.length > 0 ? `agent
|
|
150
|
+
${channels.map((ch) => {
|
|
151
|
+
if (ch === "telegram") return `.connectChannel('telegram', { token: process.env.TELEGRAM_BOT_TOKEN! })`;
|
|
152
|
+
if (ch === "whatsapp")
|
|
153
|
+
return `.connectChannel('whatsapp', {
|
|
154
|
+
token: process.env.WA_ACCESS_TOKEN!,
|
|
155
|
+
phoneId: process.env.WA_PHONE_ID!,
|
|
156
|
+
verifyToken: process.env.WA_VERIFY_TOKEN!,
|
|
157
|
+
})`;
|
|
157
158
|
return "";
|
|
158
|
-
}).filter(Boolean).join("\n");
|
|
159
|
+
}).filter(Boolean).join("\n ")};
|
|
160
|
+
await agent.start();` : "";
|
|
159
161
|
return `import 'dotenv/config';
|
|
160
|
-
import {
|
|
162
|
+
import { SvaraApp, SvaraAgent, createTool } from '@yesvara/svara';
|
|
161
163
|
|
|
162
164
|
/**
|
|
163
165
|
* ${name} \u2014 powered by SvaraJS
|
|
164
166
|
*/
|
|
165
|
-
const agent = svara({
|
|
166
|
-
llm: {
|
|
167
|
-
provider: '${provider}',
|
|
168
|
-
model: '${modelMap[provider] ?? "gpt-4o"}',
|
|
169
|
-
},
|
|
170
|
-
systemPrompt: \`You are a helpful AI assistant called ${name}.
|
|
171
|
-
Be concise, friendly, and always try your best to help.\`,
|
|
172
|
-
memory: {
|
|
173
|
-
type: 'conversation',
|
|
174
|
-
maxMessages: 20,
|
|
175
|
-
},
|
|
176
|
-
verbose: true,
|
|
177
|
-
});
|
|
178
167
|
|
|
179
|
-
//
|
|
180
|
-
|
|
168
|
+
// Define tools
|
|
169
|
+
const timeTool = createTool({
|
|
170
|
+
name: 'get_time',
|
|
181
171
|
description: 'Get the current date and time',
|
|
182
172
|
parameters: {},
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
173
|
+
async run() {
|
|
174
|
+
return {
|
|
175
|
+
datetime: new Date().toISOString(),
|
|
176
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Create agent
|
|
182
|
+
const agent = new SvaraAgent({
|
|
183
|
+
name: '${name}',
|
|
184
|
+
model: '${modelMap[provider] ?? "gpt-4o"}',
|
|
185
|
+
systemPrompt: 'You are a helpful AI assistant. Be concise and friendly.',
|
|
186
|
+
tools: [timeTool],
|
|
187
|
+
knowledge: './docs', // Add your documents here for RAG
|
|
187
188
|
});
|
|
188
189
|
|
|
189
|
-
//
|
|
190
|
+
// Setup channels
|
|
190
191
|
${channelSetup}
|
|
191
192
|
|
|
192
|
-
|
|
193
|
-
agent.start().then(() => {
|
|
194
|
-
console.log('\u{1F680} ${name} is running!');
|
|
195
|
-
});
|
|
193
|
+
console.log('\u2728 ${name} is running!');
|
|
196
194
|
`;
|
|
197
195
|
}
|
|
198
196
|
function generateGitignore() {
|
package/dist/cli/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ var pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
|
9
9
|
var program = new Command();
|
|
10
10
|
program.name("svara").description(pkg.description).version(pkg.version, "-v, --version");
|
|
11
11
|
program.command("new <name>").description("Create a new SvaraJS project").option("--provider <provider>", "LLM provider (openai|anthropic|ollama)", "openai").option("--channel <channels...>", "Channels to include", ["web"]).option("--no-install", "Skip npm install").action(async (name, opts) => {
|
|
12
|
-
const { newProject } = await import("../new-
|
|
12
|
+
const { newProject } = await import("../new-ULRP6IUQ.mjs");
|
|
13
13
|
await newProject({
|
|
14
14
|
name,
|
|
15
15
|
provider: opts.provider,
|
|
@@ -66,7 +66,7 @@ function generatePackageJson(name) {
|
|
|
66
66
|
start: "node dist/index.js"
|
|
67
67
|
},
|
|
68
68
|
dependencies: {
|
|
69
|
-
|
|
69
|
+
"@yesvara/svara": "^0.1.3",
|
|
70
70
|
dotenv: "^16.4.5"
|
|
71
71
|
},
|
|
72
72
|
devDependencies: {
|
|
@@ -113,55 +113,53 @@ function generateIndexFile(name, provider, channels) {
|
|
|
113
113
|
anthropic: "claude-opus-4-6",
|
|
114
114
|
ollama: "llama3"
|
|
115
115
|
};
|
|
116
|
-
const channelSetup = channels.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
const channelSetup = channels.includes("web") ? `const app = new SvaraApp({ cors: true });
|
|
117
|
+
app.route('/chat', agent.handler());
|
|
118
|
+
app.listen(3000);` : channels.length > 0 ? `agent
|
|
119
|
+
${channels.map((ch) => {
|
|
120
|
+
if (ch === "telegram") return `.connectChannel('telegram', { token: process.env.TELEGRAM_BOT_TOKEN! })`;
|
|
121
|
+
if (ch === "whatsapp")
|
|
122
|
+
return `.connectChannel('whatsapp', {
|
|
123
|
+
token: process.env.WA_ACCESS_TOKEN!,
|
|
124
|
+
phoneId: process.env.WA_PHONE_ID!,
|
|
125
|
+
verifyToken: process.env.WA_VERIFY_TOKEN!,
|
|
126
|
+
})`;
|
|
126
127
|
return "";
|
|
127
|
-
}).filter(Boolean).join("\n");
|
|
128
|
+
}).filter(Boolean).join("\n ")};
|
|
129
|
+
await agent.start();` : "";
|
|
128
130
|
return `import 'dotenv/config';
|
|
129
|
-
import {
|
|
131
|
+
import { SvaraApp, SvaraAgent, createTool } from '@yesvara/svara';
|
|
130
132
|
|
|
131
133
|
/**
|
|
132
134
|
* ${name} \u2014 powered by SvaraJS
|
|
133
135
|
*/
|
|
134
|
-
const agent = svara({
|
|
135
|
-
llm: {
|
|
136
|
-
provider: '${provider}',
|
|
137
|
-
model: '${modelMap[provider] ?? "gpt-4o"}',
|
|
138
|
-
},
|
|
139
|
-
systemPrompt: \`You are a helpful AI assistant called ${name}.
|
|
140
|
-
Be concise, friendly, and always try your best to help.\`,
|
|
141
|
-
memory: {
|
|
142
|
-
type: 'conversation',
|
|
143
|
-
maxMessages: 20,
|
|
144
|
-
},
|
|
145
|
-
verbose: true,
|
|
146
|
-
});
|
|
147
136
|
|
|
148
|
-
//
|
|
149
|
-
|
|
137
|
+
// Define tools
|
|
138
|
+
const timeTool = createTool({
|
|
139
|
+
name: 'get_time',
|
|
150
140
|
description: 'Get the current date and time',
|
|
151
141
|
parameters: {},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
142
|
+
async run() {
|
|
143
|
+
return {
|
|
144
|
+
datetime: new Date().toISOString(),
|
|
145
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
146
|
+
};
|
|
147
|
+
},
|
|
156
148
|
});
|
|
157
149
|
|
|
158
|
-
//
|
|
150
|
+
// Create agent
|
|
151
|
+
const agent = new SvaraAgent({
|
|
152
|
+
name: '${name}',
|
|
153
|
+
model: '${modelMap[provider] ?? "gpt-4o"}',
|
|
154
|
+
systemPrompt: 'You are a helpful AI assistant. Be concise and friendly.',
|
|
155
|
+
tools: [timeTool],
|
|
156
|
+
knowledge: './docs', // Add your documents here for RAG
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Setup channels
|
|
159
160
|
${channelSetup}
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
agent.start().then(() => {
|
|
163
|
-
console.log('\u{1F680} ${name} is running!');
|
|
164
|
-
});
|
|
162
|
+
console.log('\u2728 ${name} is running!');
|
|
165
163
|
`;
|
|
166
164
|
}
|
|
167
165
|
function generateGitignore() {
|
package/package.json
CHANGED
package/src/cli/commands/new.ts
CHANGED
|
@@ -86,7 +86,7 @@ function generatePackageJson(name: string): string {
|
|
|
86
86
|
start: 'node dist/index.js',
|
|
87
87
|
},
|
|
88
88
|
dependencies: {
|
|
89
|
-
|
|
89
|
+
'@yesvara/svara': '^0.1.3',
|
|
90
90
|
dotenv: '^16.4.5',
|
|
91
91
|
},
|
|
92
92
|
devDependencies: {
|
|
@@ -147,59 +147,53 @@ function generateIndexFile(
|
|
|
147
147
|
ollama: 'llama3',
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
const channelSetup = channels
|
|
151
|
-
.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
.filter(Boolean)
|
|
164
|
-
.join('\n');
|
|
150
|
+
const channelSetup = channels.includes('web')
|
|
151
|
+
? `const app = new SvaraApp({ cors: true });\napp.route('/chat', agent.handler());\napp.listen(3000);`
|
|
152
|
+
: channels.length > 0
|
|
153
|
+
? `agent\n ${channels
|
|
154
|
+
.map((ch) => {
|
|
155
|
+
if (ch === 'telegram') return `.connectChannel('telegram', { token: process.env.TELEGRAM_BOT_TOKEN! })`;
|
|
156
|
+
if (ch === 'whatsapp')
|
|
157
|
+
return `.connectChannel('whatsapp', {\n token: process.env.WA_ACCESS_TOKEN!,\n phoneId: process.env.WA_PHONE_ID!,\n verifyToken: process.env.WA_VERIFY_TOKEN!,\n })`;
|
|
158
|
+
return '';
|
|
159
|
+
})
|
|
160
|
+
.filter(Boolean)
|
|
161
|
+
.join('\n ')};\nawait agent.start();`
|
|
162
|
+
: '';
|
|
165
163
|
|
|
166
164
|
return `import 'dotenv/config';
|
|
167
|
-
import {
|
|
165
|
+
import { SvaraApp, SvaraAgent, createTool } from '@yesvara/svara';
|
|
168
166
|
|
|
169
167
|
/**
|
|
170
168
|
* ${name} — powered by SvaraJS
|
|
171
169
|
*/
|
|
172
|
-
const agent = svara({
|
|
173
|
-
llm: {
|
|
174
|
-
provider: '${provider}',
|
|
175
|
-
model: '${modelMap[provider] ?? 'gpt-4o'}',
|
|
176
|
-
},
|
|
177
|
-
systemPrompt: \`You are a helpful AI assistant called ${name}.
|
|
178
|
-
Be concise, friendly, and always try your best to help.\`,
|
|
179
|
-
memory: {
|
|
180
|
-
type: 'conversation',
|
|
181
|
-
maxMessages: 20,
|
|
182
|
-
},
|
|
183
|
-
verbose: true,
|
|
184
|
-
});
|
|
185
170
|
|
|
186
|
-
//
|
|
187
|
-
|
|
171
|
+
// Define tools
|
|
172
|
+
const timeTool = createTool({
|
|
173
|
+
name: 'get_time',
|
|
188
174
|
description: 'Get the current date and time',
|
|
189
175
|
parameters: {},
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
176
|
+
async run() {
|
|
177
|
+
return {
|
|
178
|
+
datetime: new Date().toISOString(),
|
|
179
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
180
|
+
};
|
|
181
|
+
},
|
|
194
182
|
});
|
|
195
183
|
|
|
196
|
-
//
|
|
184
|
+
// Create agent
|
|
185
|
+
const agent = new SvaraAgent({
|
|
186
|
+
name: '${name}',
|
|
187
|
+
model: '${modelMap[provider] ?? 'gpt-4o'}',
|
|
188
|
+
systemPrompt: 'You are a helpful AI assistant. Be concise and friendly.',
|
|
189
|
+
tools: [timeTool],
|
|
190
|
+
knowledge: './docs', // Add your documents here for RAG
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// Setup channels
|
|
197
194
|
${channelSetup}
|
|
198
195
|
|
|
199
|
-
|
|
200
|
-
agent.start().then(() => {
|
|
201
|
-
console.log('🚀 ${name} is running!');
|
|
202
|
-
});
|
|
196
|
+
console.log('✨ ${name} is running!');
|
|
203
197
|
`;
|
|
204
198
|
}
|
|
205
199
|
|