@runflow-ai/cli 0.2.22 → 0.2.23
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/dist/commands/create/code-generator.d.ts +11 -0
- package/dist/commands/create/code-generator.js +532 -0
- package/dist/commands/create/code-generator.js.map +1 -0
- package/dist/commands/create/create.command.d.ts +4 -3
- package/dist/commands/create/create.command.js +236 -63
- package/dist/commands/create/create.command.js.map +1 -1
- package/dist/commands/create/provider-helpers.d.ts +18 -0
- package/dist/commands/create/provider-helpers.js +116 -0
- package/dist/commands/create/provider-helpers.js.map +1 -0
- package/package.json +1 -1
- package/static/dist-test/assets/main-BFmmScSl.js +59 -0
- package/static/dist-test/assets/main-BOItY-vU.css +1 -0
- package/static/dist-test/index-test.html +2 -2
- package/static/dist-test/assets/main-D9Orqw23.js +0 -53
- package/static/dist-test/assets/main-DRe-vdEL.css +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface GenerateAgentCodeConfig {
|
|
2
|
+
agentName: string;
|
|
3
|
+
provider: 'openai' | 'anthropic' | 'groq' | 'gemini' | 'bedrock';
|
|
4
|
+
model: string;
|
|
5
|
+
template?: 'starter' | 'rag';
|
|
6
|
+
}
|
|
7
|
+
export interface GeneratedFile {
|
|
8
|
+
path: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function generateAgentCode(config: GenerateAgentCodeConfig): GeneratedFile[];
|
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateAgentCode = generateAgentCode;
|
|
4
|
+
function generateAgentCode(config) {
|
|
5
|
+
const { agentName, provider, model, template = 'starter' } = config;
|
|
6
|
+
const agentSlug = slugify(agentName);
|
|
7
|
+
const files = [
|
|
8
|
+
{ path: 'main.ts', content: generateMainTs(config) },
|
|
9
|
+
{ path: 'tools/index.ts', content: generateToolsIndex() },
|
|
10
|
+
{ path: 'tools/weather.ts', content: generateWeatherTool() },
|
|
11
|
+
{ path: 'prompts/index.ts', content: generatePromptsIndex(agentName) },
|
|
12
|
+
{ path: 'package.json', content: generatePackageJson(agentSlug) },
|
|
13
|
+
{ path: 'tsconfig.json', content: generateTsConfig() },
|
|
14
|
+
{ path: 'README.md', content: generateReadme(agentName, agentSlug) },
|
|
15
|
+
];
|
|
16
|
+
if (template === 'rag') {
|
|
17
|
+
files[0].content = generateMainTsWithRag(config);
|
|
18
|
+
}
|
|
19
|
+
return files;
|
|
20
|
+
}
|
|
21
|
+
function generateMainTs(config) {
|
|
22
|
+
const { agentName, provider, model } = config;
|
|
23
|
+
return `import { Agent, ${provider} } from '@runflow-ai/sdk';
|
|
24
|
+
// import { identify } from '@runflow-ai/sdk'; // Uncomment to use identify
|
|
25
|
+
import { tools } from './tools';
|
|
26
|
+
import { systemPrompt } from './prompts';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ${agentName} - AI Agent powered by Runflow SDK
|
|
30
|
+
*
|
|
31
|
+
* Provider: ${provider}
|
|
32
|
+
* Model: ${model}
|
|
33
|
+
*/
|
|
34
|
+
const agent = new Agent({
|
|
35
|
+
name: '${agentName}',
|
|
36
|
+
model: ${provider}('${model}'),
|
|
37
|
+
instructions: systemPrompt,
|
|
38
|
+
tools,
|
|
39
|
+
|
|
40
|
+
// Memory - stores conversation history per session
|
|
41
|
+
// The sessionId is automatically provided by rf test or execution engine
|
|
42
|
+
memory: {
|
|
43
|
+
maxTurns: 10, // Keep last 10 conversation turns
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// Uncomment to enable RAG (Retrieval Augmented Generation)
|
|
47
|
+
// rag: {
|
|
48
|
+
// vectorStore: 'my-knowledge-base',
|
|
49
|
+
// k: 5,
|
|
50
|
+
// threshold: 0.7,
|
|
51
|
+
// },
|
|
52
|
+
|
|
53
|
+
// Uncomment to enable debug logging
|
|
54
|
+
// debug: true,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Input validation
|
|
59
|
+
*/
|
|
60
|
+
function validateInput(input: unknown): { message: string; sessionId?: string } {
|
|
61
|
+
if (!input || typeof input !== 'object') {
|
|
62
|
+
throw new Error('Input must be an object');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const { message, sessionId } = input as Record<string, unknown>;
|
|
66
|
+
|
|
67
|
+
if (!message || typeof message !== 'string') {
|
|
68
|
+
throw new Error('message is required and must be a string');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (message.trim().length === 0) {
|
|
72
|
+
throw new Error('message cannot be empty');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
message: message.trim(),
|
|
77
|
+
sessionId: typeof sessionId === 'string' ? sessionId : undefined,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Main entry point - called by Runflow runtime
|
|
83
|
+
*
|
|
84
|
+
* The input object contains:
|
|
85
|
+
* - message: User's message (required)
|
|
86
|
+
* - sessionId: Unique session identifier (auto-generated by rf test)
|
|
87
|
+
*
|
|
88
|
+
* Memory works automatically:
|
|
89
|
+
* - Same sessionId = same conversation history
|
|
90
|
+
* - Different sessionId = fresh conversation
|
|
91
|
+
*/
|
|
92
|
+
export async function main(input: { message: string; sessionId?: string }) {
|
|
93
|
+
try {
|
|
94
|
+
// Validate input
|
|
95
|
+
const validatedInput = validateInput(input);
|
|
96
|
+
|
|
97
|
+
// Uncomment to identify user for memory persistence across channels
|
|
98
|
+
// This creates a stable memory key based on user identity instead of session
|
|
99
|
+
// identify('+5511999999999'); // Auto-detects type (phone)
|
|
100
|
+
// identify('user@email.com'); // Auto-detects type (email)
|
|
101
|
+
// identify({ type: 'phone', value: '+5511999999999' });
|
|
102
|
+
// identify({ type: 'email', value: 'user@email.com' });
|
|
103
|
+
// identify({ type: 'hubspot_contact', value: 'contact_123' });
|
|
104
|
+
|
|
105
|
+
// Process message
|
|
106
|
+
const result = await agent.process(validatedInput);
|
|
107
|
+
|
|
108
|
+
return result;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
// Log error for debugging
|
|
111
|
+
console.error('[${agentName}] Error:', error instanceof Error ? error.message : error);
|
|
112
|
+
|
|
113
|
+
// Return structured error response
|
|
114
|
+
return {
|
|
115
|
+
success: false,
|
|
116
|
+
error: error instanceof Error ? error.message : 'An unexpected error occurred',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default main;
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
function generateMainTsWithRag(config) {
|
|
125
|
+
const { agentName, provider, model } = config;
|
|
126
|
+
return `import { Agent, ${provider} } from '@runflow-ai/sdk';
|
|
127
|
+
// import { identify } from '@runflow-ai/sdk'; // Uncomment to use identify
|
|
128
|
+
import { tools } from './tools';
|
|
129
|
+
import { systemPrompt } from './prompts';
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* ${agentName} - RAG-enabled AI Agent powered by Runflow SDK
|
|
133
|
+
*
|
|
134
|
+
* Provider: ${provider}
|
|
135
|
+
* Model: ${model}
|
|
136
|
+
* RAG: Enabled
|
|
137
|
+
*/
|
|
138
|
+
const agent = new Agent({
|
|
139
|
+
name: '${agentName}',
|
|
140
|
+
model: ${provider}('${model}'),
|
|
141
|
+
instructions: systemPrompt,
|
|
142
|
+
tools,
|
|
143
|
+
|
|
144
|
+
// Memory - stores conversation history per session
|
|
145
|
+
memory: {
|
|
146
|
+
maxTurns: 10,
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
// RAG - Retrieval Augmented Generation
|
|
150
|
+
rag: {
|
|
151
|
+
vectorStore: 'docs',
|
|
152
|
+
k: 5,
|
|
153
|
+
threshold: 0.7,
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
// Uncomment to enable debug logging
|
|
157
|
+
// debug: true,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Input validation
|
|
162
|
+
*/
|
|
163
|
+
function validateInput(input: unknown): { message: string; sessionId?: string } {
|
|
164
|
+
if (!input || typeof input !== 'object') {
|
|
165
|
+
throw new Error('Input must be an object');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const { message, sessionId } = input as Record<string, unknown>;
|
|
169
|
+
|
|
170
|
+
if (!message || typeof message !== 'string') {
|
|
171
|
+
throw new Error('message is required and must be a string');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (message.trim().length === 0) {
|
|
175
|
+
throw new Error('message cannot be empty');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
message: message.trim(),
|
|
180
|
+
sessionId: typeof sessionId === 'string' ? sessionId : undefined,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Main entry point - called by Runflow runtime
|
|
186
|
+
*/
|
|
187
|
+
export async function main(input: { message: string; sessionId?: string }) {
|
|
188
|
+
try {
|
|
189
|
+
// Validate input
|
|
190
|
+
const validatedInput = validateInput(input);
|
|
191
|
+
|
|
192
|
+
// Uncomment to identify user for memory persistence across channels
|
|
193
|
+
// identify('+5511999999999');
|
|
194
|
+
// identify({ type: 'email', value: 'user@email.com' });
|
|
195
|
+
|
|
196
|
+
// Process message
|
|
197
|
+
const result = await agent.process(validatedInput);
|
|
198
|
+
|
|
199
|
+
return result;
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error('[${agentName}] Error:', error instanceof Error ? error.message : error);
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
success: false,
|
|
205
|
+
error: error instanceof Error ? error.message : 'An unexpected error occurred',
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export default main;
|
|
211
|
+
`;
|
|
212
|
+
}
|
|
213
|
+
function generateToolsIndex() {
|
|
214
|
+
return `import { getWeather } from './weather';
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Agent Tools Registry
|
|
218
|
+
*
|
|
219
|
+
* Tools are registered as a Record<string, RunflowTool>
|
|
220
|
+
* The key should match the tool's 'id' property
|
|
221
|
+
*/
|
|
222
|
+
export const tools = {
|
|
223
|
+
get_weather: getWeather,
|
|
224
|
+
};
|
|
225
|
+
`;
|
|
226
|
+
}
|
|
227
|
+
function generateWeatherTool() {
|
|
228
|
+
return `import { createTool } from '@runflow-ai/sdk';
|
|
229
|
+
import { z } from 'zod';
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Weather Tool - Get current temperature for any city
|
|
233
|
+
*
|
|
234
|
+
* Uses Open-Meteo API (free, no API key required)
|
|
235
|
+
* Documentation: https://open-meteo.com/
|
|
236
|
+
*/
|
|
237
|
+
export const getWeather = createTool({
|
|
238
|
+
id: 'get_weather',
|
|
239
|
+
description: 'Get current weather and temperature for a city. Use this when the user asks about weather, temperature, or climate conditions.',
|
|
240
|
+
|
|
241
|
+
inputSchema: z.object({
|
|
242
|
+
city: z.string().describe('City name (e.g., "São Paulo", "New York", "London")'),
|
|
243
|
+
}),
|
|
244
|
+
|
|
245
|
+
execute: async ({ context }) => {
|
|
246
|
+
const { city } = context;
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
// 1. Geocoding: Convert city name to coordinates
|
|
250
|
+
const geoUrl = \`https://geocoding-api.open-meteo.com/v1/search?name=\${encodeURIComponent(city)}&count=1&language=en\`;
|
|
251
|
+
const geoResponse = await fetch(geoUrl);
|
|
252
|
+
|
|
253
|
+
if (!geoResponse.ok) {
|
|
254
|
+
return { success: false, error: 'Failed to connect to geocoding service' };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const geoData = await geoResponse.json();
|
|
258
|
+
|
|
259
|
+
if (!geoData.results || geoData.results.length === 0) {
|
|
260
|
+
return {
|
|
261
|
+
success: false,
|
|
262
|
+
error: \`City "\${city}" not found. Try a different spelling or a nearby major city.\`
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const { latitude, longitude, name, country, admin1 } = geoData.results[0];
|
|
267
|
+
|
|
268
|
+
// 2. Weather: Get current conditions
|
|
269
|
+
const weatherUrl = \`https://api.open-meteo.com/v1/forecast?latitude=\${latitude}&longitude=\${longitude}¤t=temperature_2m,relative_humidity_2m,apparent_temperature,wind_speed_10m,weather_code&timezone=auto\`;
|
|
270
|
+
const weatherResponse = await fetch(weatherUrl);
|
|
271
|
+
|
|
272
|
+
if (!weatherResponse.ok) {
|
|
273
|
+
return { success: false, error: 'Failed to fetch weather data' };
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const weatherData = await weatherResponse.json();
|
|
277
|
+
const current = weatherData.current;
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
success: true,
|
|
281
|
+
location: {
|
|
282
|
+
city: name,
|
|
283
|
+
region: admin1 || null,
|
|
284
|
+
country,
|
|
285
|
+
coordinates: { latitude, longitude },
|
|
286
|
+
},
|
|
287
|
+
weather: {
|
|
288
|
+
temperature: \`\${current.temperature_2m}°C\`,
|
|
289
|
+
feelsLike: \`\${current.apparent_temperature}°C\`,
|
|
290
|
+
humidity: \`\${current.relative_humidity_2m}%\`,
|
|
291
|
+
windSpeed: \`\${current.wind_speed_10m} km/h\`,
|
|
292
|
+
conditions: getWeatherDescription(current.weather_code),
|
|
293
|
+
},
|
|
294
|
+
timestamp: new Date().toISOString(),
|
|
295
|
+
};
|
|
296
|
+
} catch (error) {
|
|
297
|
+
return {
|
|
298
|
+
success: false,
|
|
299
|
+
error: error instanceof Error ? error.message : 'Unknown error fetching weather',
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Convert WMO weather codes to human-readable descriptions
|
|
307
|
+
* Reference: https://open-meteo.com/en/docs
|
|
308
|
+
*/
|
|
309
|
+
function getWeatherDescription(code: number): string {
|
|
310
|
+
const descriptions: Record<number, string> = {
|
|
311
|
+
0: 'Clear sky',
|
|
312
|
+
1: 'Mainly clear',
|
|
313
|
+
2: 'Partly cloudy',
|
|
314
|
+
3: 'Overcast',
|
|
315
|
+
45: 'Foggy',
|
|
316
|
+
48: 'Depositing rime fog',
|
|
317
|
+
51: 'Light drizzle',
|
|
318
|
+
53: 'Moderate drizzle',
|
|
319
|
+
55: 'Dense drizzle',
|
|
320
|
+
56: 'Light freezing drizzle',
|
|
321
|
+
57: 'Dense freezing drizzle',
|
|
322
|
+
61: 'Slight rain',
|
|
323
|
+
63: 'Moderate rain',
|
|
324
|
+
65: 'Heavy rain',
|
|
325
|
+
66: 'Light freezing rain',
|
|
326
|
+
67: 'Heavy freezing rain',
|
|
327
|
+
71: 'Slight snow',
|
|
328
|
+
73: 'Moderate snow',
|
|
329
|
+
75: 'Heavy snow',
|
|
330
|
+
77: 'Snow grains',
|
|
331
|
+
80: 'Slight rain showers',
|
|
332
|
+
81: 'Moderate rain showers',
|
|
333
|
+
82: 'Violent rain showers',
|
|
334
|
+
85: 'Slight snow showers',
|
|
335
|
+
86: 'Heavy snow showers',
|
|
336
|
+
95: 'Thunderstorm',
|
|
337
|
+
96: 'Thunderstorm with slight hail',
|
|
338
|
+
99: 'Thunderstorm with heavy hail',
|
|
339
|
+
};
|
|
340
|
+
return descriptions[code] || 'Unknown conditions';
|
|
341
|
+
}
|
|
342
|
+
`;
|
|
343
|
+
}
|
|
344
|
+
function generatePromptsIndex(agentName) {
|
|
345
|
+
return `/**
|
|
346
|
+
* System Prompts for ${agentName}
|
|
347
|
+
*
|
|
348
|
+
* These prompts define the agent's personality, capabilities, and behavior.
|
|
349
|
+
* You can customize them to match your use case.
|
|
350
|
+
*/
|
|
351
|
+
|
|
352
|
+
export const systemPrompt = \`You are ${agentName}, a helpful and knowledgeable AI assistant.
|
|
353
|
+
|
|
354
|
+
## Your Capabilities
|
|
355
|
+
- Check weather and temperature for any city worldwide using the get_weather tool
|
|
356
|
+
- Answer general questions with accuracy and clarity
|
|
357
|
+
- Engage in friendly, professional conversations
|
|
358
|
+
|
|
359
|
+
## Guidelines
|
|
360
|
+
1. When users ask about weather, temperature, or climate, ALWAYS use the get_weather tool
|
|
361
|
+
2. Provide clear, concise answers while being thorough when needed
|
|
362
|
+
3. If you're unsure about something, acknowledge it honestly
|
|
363
|
+
4. Be friendly and professional in your responses
|
|
364
|
+
5. Format responses for readability (use bullet points, headers when appropriate)
|
|
365
|
+
|
|
366
|
+
## Response Format
|
|
367
|
+
- For weather queries: Include temperature, conditions, and any relevant details
|
|
368
|
+
- For general questions: Be direct but comprehensive
|
|
369
|
+
- Always maintain a helpful and positive tone
|
|
370
|
+
\`;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Additional prompt templates you can use
|
|
374
|
+
*/
|
|
375
|
+
export const prompts = {
|
|
376
|
+
// Greeting prompt for new sessions
|
|
377
|
+
greeting: \`Hello! I'm ${agentName}. I can help you check the weather for any city, answer questions, or just chat. What can I do for you today?\`,
|
|
378
|
+
|
|
379
|
+
// Error handling prompt
|
|
380
|
+
errorRecovery: \`I encountered an issue processing that request. Could you please rephrase or try again?\`,
|
|
381
|
+
|
|
382
|
+
// Weather-specific prompt enhancement
|
|
383
|
+
weatherContext: \`When providing weather information, include the temperature, how it feels, humidity, and wind conditions.\`,
|
|
384
|
+
};
|
|
385
|
+
`;
|
|
386
|
+
}
|
|
387
|
+
function generatePackageJson(agentSlug) {
|
|
388
|
+
const packageJson = {
|
|
389
|
+
name: agentSlug,
|
|
390
|
+
version: '1.0.0',
|
|
391
|
+
description: 'AI agent built with Runflow SDK',
|
|
392
|
+
main: 'main.ts',
|
|
393
|
+
type: 'module',
|
|
394
|
+
scripts: {
|
|
395
|
+
dev: 'rf dev',
|
|
396
|
+
test: 'rf test',
|
|
397
|
+
deploy: 'rf agents deploy',
|
|
398
|
+
},
|
|
399
|
+
dependencies: {
|
|
400
|
+
'@runflow-ai/sdk': '^1.0.68',
|
|
401
|
+
zod: '^3.23.0',
|
|
402
|
+
},
|
|
403
|
+
devDependencies: {
|
|
404
|
+
'@types/node': '^20.0.0',
|
|
405
|
+
typescript: '^5.5.0',
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
return JSON.stringify(packageJson, null, 2);
|
|
409
|
+
}
|
|
410
|
+
function generateTsConfig() {
|
|
411
|
+
const tsConfig = {
|
|
412
|
+
compilerOptions: {
|
|
413
|
+
target: 'ES2022',
|
|
414
|
+
module: 'ESNext',
|
|
415
|
+
moduleResolution: 'node',
|
|
416
|
+
outDir: './dist',
|
|
417
|
+
esModuleInterop: true,
|
|
418
|
+
strict: true,
|
|
419
|
+
skipLibCheck: true,
|
|
420
|
+
},
|
|
421
|
+
include: ['*.ts', 'tools/*.ts', 'prompts/*.ts'],
|
|
422
|
+
};
|
|
423
|
+
return JSON.stringify(tsConfig, null, 2);
|
|
424
|
+
}
|
|
425
|
+
function generateReadme(agentName, agentSlug) {
|
|
426
|
+
return `# ${agentName}
|
|
427
|
+
|
|
428
|
+
AI agent built with [Runflow SDK](https://docs.runflow.ai).
|
|
429
|
+
|
|
430
|
+
## Features
|
|
431
|
+
|
|
432
|
+
- **Weather Tool**: Check real-time weather for any city worldwide (powered by [Open-Meteo](https://open-meteo.com/))
|
|
433
|
+
- **Conversational AI**: Helpful assistant with memory and context awareness
|
|
434
|
+
- **Extensible**: Easy to add new tools and capabilities
|
|
435
|
+
|
|
436
|
+
## Quick Start
|
|
437
|
+
|
|
438
|
+
\`\`\`bash
|
|
439
|
+
# Install dependencies
|
|
440
|
+
npm install
|
|
441
|
+
|
|
442
|
+
# Test locally with interactive UI
|
|
443
|
+
rf test
|
|
444
|
+
|
|
445
|
+
# Deploy to production
|
|
446
|
+
rf agents deploy
|
|
447
|
+
\`\`\`
|
|
448
|
+
|
|
449
|
+
## Project Structure
|
|
450
|
+
|
|
451
|
+
\`\`\`
|
|
452
|
+
${agentSlug}/
|
|
453
|
+
├── main.ts # Agent configuration and entry point
|
|
454
|
+
├── tools/
|
|
455
|
+
│ ├── index.ts # Tools registry
|
|
456
|
+
│ └── weather.ts # Weather tool (Open-Meteo API)
|
|
457
|
+
├── prompts/
|
|
458
|
+
│ └── index.ts # System prompts and templates
|
|
459
|
+
├── .runflow/
|
|
460
|
+
│ └── rf.json # Runflow configuration
|
|
461
|
+
├── package.json
|
|
462
|
+
└── tsconfig.json
|
|
463
|
+
\`\`\`
|
|
464
|
+
|
|
465
|
+
## Example Conversations
|
|
466
|
+
|
|
467
|
+
\`\`\`
|
|
468
|
+
User: What's the weather in São Paulo?
|
|
469
|
+
Agent: The current weather in São Paulo, Brazil:
|
|
470
|
+
- Temperature: 24°C (feels like 26°C)
|
|
471
|
+
- Conditions: Partly cloudy
|
|
472
|
+
- Humidity: 65%
|
|
473
|
+
- Wind: 12 km/h
|
|
474
|
+
|
|
475
|
+
User: How about Tokyo?
|
|
476
|
+
Agent: Here's the weather in Tokyo, Japan:
|
|
477
|
+
- Temperature: 18°C (feels like 17°C)
|
|
478
|
+
- Conditions: Clear sky
|
|
479
|
+
- Humidity: 45%
|
|
480
|
+
- Wind: 8 km/h
|
|
481
|
+
\`\`\`
|
|
482
|
+
|
|
483
|
+
## Adding New Tools
|
|
484
|
+
|
|
485
|
+
1. Create a new file in \`tools/\` (e.g., \`tools/my-tool.ts\`)
|
|
486
|
+
2. Use \`createTool\` from the SDK:
|
|
487
|
+
|
|
488
|
+
\`\`\`typescript
|
|
489
|
+
import { createTool } from '@runflow-ai/sdk';
|
|
490
|
+
import { z } from 'zod';
|
|
491
|
+
|
|
492
|
+
export const myTool = createTool({
|
|
493
|
+
id: 'my_tool',
|
|
494
|
+
description: 'Description of what the tool does',
|
|
495
|
+
inputSchema: z.object({
|
|
496
|
+
param: z.string().describe('Parameter description'),
|
|
497
|
+
}),
|
|
498
|
+
execute: async ({ context }) => {
|
|
499
|
+
const { param } = context;
|
|
500
|
+
// Your logic here
|
|
501
|
+
return { result: 'success' };
|
|
502
|
+
},
|
|
503
|
+
});
|
|
504
|
+
\`\`\`
|
|
505
|
+
|
|
506
|
+
3. Register in \`tools/index.ts\`:
|
|
507
|
+
|
|
508
|
+
\`\`\`typescript
|
|
509
|
+
import { myTool } from './my-tool';
|
|
510
|
+
|
|
511
|
+
export const tools = {
|
|
512
|
+
get_weather: getWeather,
|
|
513
|
+
my_tool: myTool, // Add here
|
|
514
|
+
};
|
|
515
|
+
\`\`\`
|
|
516
|
+
|
|
517
|
+
## Documentation
|
|
518
|
+
|
|
519
|
+
- [Runflow Docs](https://docs.runflow.ai)
|
|
520
|
+
- [SDK Reference](https://docs.runflow.ai/sdk)
|
|
521
|
+
- [Tool Creation Guide](https://docs.runflow.ai/sdk/tools)
|
|
522
|
+
- [RAG Configuration](https://docs.runflow.ai/sdk/rag)
|
|
523
|
+
`;
|
|
524
|
+
}
|
|
525
|
+
function slugify(text) {
|
|
526
|
+
return text
|
|
527
|
+
.toLowerCase()
|
|
528
|
+
.trim()
|
|
529
|
+
.replace(/\s+/g, '-')
|
|
530
|
+
.replace(/[^a-z0-9-]/g, '');
|
|
531
|
+
}
|
|
532
|
+
//# sourceMappingURL=code-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-generator.js","sourceRoot":"","sources":["../../../src/commands/create/code-generator.ts"],"names":[],"mappings":";;AAsBA,8CAoBC;AApBD,SAAgB,iBAAiB,CAAC,MAA+B;IAC/D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC;IACpE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAErC,MAAM,KAAK,GAAoB;QAC7B,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE;QACpD,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAAE;QACzD,EAAE,IAAI,EAAE,kBA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,YAAY,EAAE,cAAc,CAAC;KAChD,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAKD,SAAS,cAAc,CAAC,SAAiB,EAAE,SAAiB;IAC1D,OAAO,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BrB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEV,CAAC;AACF,CAAC;AAKD,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI;SACR,WAAW,EAAE;SACb,IAAI,EAAE;SACN,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -3,17 +3,18 @@ interface CreateOptions {
|
|
|
3
3
|
apiKey?: string;
|
|
4
4
|
api?: string;
|
|
5
5
|
name?: string;
|
|
6
|
-
|
|
6
|
+
provider?: string;
|
|
7
|
+
model?: string;
|
|
7
8
|
yes?: boolean;
|
|
8
9
|
}
|
|
9
10
|
export declare class CreateCommand extends CommandRunner {
|
|
10
11
|
run(inputs: string[], options: CreateOptions): Promise<void>;
|
|
11
12
|
private slugify;
|
|
12
|
-
private writeTreeToDisk;
|
|
13
13
|
parseApiKey(val: string): string;
|
|
14
14
|
parseApi(val: string): string;
|
|
15
15
|
parseName(val: string): string;
|
|
16
|
-
|
|
16
|
+
parseProvider(val: string): string;
|
|
17
|
+
parseModel(val: string): string;
|
|
17
18
|
parseYes(): boolean;
|
|
18
19
|
}
|
|
19
20
|
export {};
|