@yesvara/svara 0.1.3 → 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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  <!-- # @yesvara/svara -->
5
5
 
6
- **Build AI agents in 15 lines. Ship to production.**
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
- svarajs: "latest",
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.map((ch) => {
148
- if (ch === "web") return `agent.use('web', { port: 3000, cors: true });`;
149
- if (ch === "telegram") return `agent.use('telegram', { token: process.env.TELEGRAM_BOT_TOKEN! });`;
150
- if (ch === "whatsapp") return [
151
- `agent.use('whatsapp', {`,
152
- ` token: process.env.WA_ACCESS_TOKEN!,`,
153
- ` phoneId: process.env.WA_PHONE_ID!,`,
154
- ` verifyToken: process.env.WA_VERIFY_TOKEN!,`,
155
- `});`
156
- ].join("\n");
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 { svara } from 'svarajs';
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
- // \u2500\u2500 Tools \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
180
- agent.tool('get_time', {
168
+ // Define tools
169
+ const timeTool = createTool({
170
+ name: 'get_time',
181
171
  description: 'Get the current date and time',
182
172
  parameters: {},
183
- execute: async () => ({
184
- datetime: new Date().toISOString(),
185
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
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
- // \u2500\u2500 Channels \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
190
+ // Setup channels
190
191
  ${channelSetup}
191
192
 
192
- // \u2500\u2500 Start \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
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() {
@@ -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-7K4NIDZO.mjs");
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
- svarajs: "latest",
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.map((ch) => {
117
- if (ch === "web") return `agent.use('web', { port: 3000, cors: true });`;
118
- if (ch === "telegram") return `agent.use('telegram', { token: process.env.TELEGRAM_BOT_TOKEN! });`;
119
- if (ch === "whatsapp") return [
120
- `agent.use('whatsapp', {`,
121
- ` token: process.env.WA_ACCESS_TOKEN!,`,
122
- ` phoneId: process.env.WA_PHONE_ID!,`,
123
- ` verifyToken: process.env.WA_VERIFY_TOKEN!,`,
124
- `});`
125
- ].join("\n");
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 { svara } from 'svarajs';
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
- // \u2500\u2500 Tools \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
149
- agent.tool('get_time', {
137
+ // Define tools
138
+ const timeTool = createTool({
139
+ name: 'get_time',
150
140
  description: 'Get the current date and time',
151
141
  parameters: {},
152
- execute: async () => ({
153
- datetime: new Date().toISOString(),
154
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
155
- }),
142
+ async run() {
143
+ return {
144
+ datetime: new Date().toISOString(),
145
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
146
+ };
147
+ },
156
148
  });
157
149
 
158
- // \u2500\u2500 Channels \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
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
- // \u2500\u2500 Start \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yesvara/svara",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "Build AI agents in 15 lines of code. Multi-channel, RAG-ready, production-grade.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -47,6 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@anthropic-ai/sdk": ">=0.20.0",
50
+ "@yesvara/svara": "^0.2.0",
50
51
  "better-sqlite3": "^12.8.0",
51
52
  "chalk": "^5.3.0",
52
53
  "commander": "^12.1.0",
@@ -86,7 +86,7 @@ function generatePackageJson(name: string): string {
86
86
  start: 'node dist/index.js',
87
87
  },
88
88
  dependencies: {
89
- svarajs: 'latest',
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
- .map((ch) => {
152
- if (ch === 'web') return `agent.use('web', { port: 3000, cors: true });`;
153
- if (ch === 'telegram') return `agent.use('telegram', { token: process.env.TELEGRAM_BOT_TOKEN! });`;
154
- if (ch === 'whatsapp') return [
155
- `agent.use('whatsapp', {`,
156
- ` token: process.env.WA_ACCESS_TOKEN!,`,
157
- ` phoneId: process.env.WA_PHONE_ID!,`,
158
- ` verifyToken: process.env.WA_VERIFY_TOKEN!,`,
159
- `});`,
160
- ].join('\n');
161
- return '';
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 { svara } from 'svarajs';
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
- // ── Tools ──────────────────────────────────────────────────────────────────
187
- agent.tool('get_time', {
171
+ // Define tools
172
+ const timeTool = createTool({
173
+ name: 'get_time',
188
174
  description: 'Get the current date and time',
189
175
  parameters: {},
190
- execute: async () => ({
191
- datetime: new Date().toISOString(),
192
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
193
- }),
176
+ async run() {
177
+ return {
178
+ datetime: new Date().toISOString(),
179
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
180
+ };
181
+ },
194
182
  });
195
183
 
196
- // ── Channels ────────────────────────────────────────────────────────────────
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
- // ── Start ────────────────────────────────────────────────────────────────────
200
- agent.start().then(() => {
201
- console.log('🚀 ${name} is running!');
202
- });
196
+ console.log('✨ ${name} is running!');
203
197
  `;
204
198
  }
205
199