@ariaflowagents/config 0.7.0 → 0.8.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/dist/agent-architect/index.d.ts +10 -0
- package/dist/agent-architect/index.d.ts.map +1 -0
- package/dist/agent-architect/index.js +131 -0
- package/dist/agent-architect/index.js.map +1 -0
- package/dist/agent-architect/prompt-generator.d.ts +9 -0
- package/dist/agent-architect/prompt-generator.d.ts.map +1 -0
- package/dist/agent-architect/prompt-generator.js +155 -0
- package/dist/agent-architect/prompt-generator.js.map +1 -0
- package/dist/agent-architect/rfc-emitter.d.ts +18 -0
- package/dist/agent-architect/rfc-emitter.d.ts.map +1 -0
- package/dist/agent-architect/rfc-emitter.js +350 -0
- package/dist/agent-architect/rfc-emitter.js.map +1 -0
- package/dist/agent-architect/tool-recommender.d.ts +8 -0
- package/dist/agent-architect/tool-recommender.d.ts.map +1 -0
- package/dist/agent-architect/tool-recommender.js +87 -0
- package/dist/agent-architect/tool-recommender.js.map +1 -0
- package/dist/agent-architect/types.d.ts +904 -0
- package/dist/agent-architect/types.d.ts.map +1 -0
- package/dist/agent-architect/types.js +89 -0
- package/dist/agent-architect/types.js.map +1 -0
- package/dist/agent-architect/use-case-analyzer.d.ts +8 -0
- package/dist/agent-architect/use-case-analyzer.d.ts.map +1 -0
- package/dist/agent-architect/use-case-analyzer.js +76 -0
- package/dist/agent-architect/use-case-analyzer.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +890 -0
- package/dist/cli.js.map +1 -1
- package/dist/llm-flow-generator.d.ts.map +1 -1
- package/dist/llm-flow-generator.js +31 -73
- package/dist/llm-flow-generator.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
const STATIC_GUIDES_REFERENCE = `## Implementation Guides
|
|
2
|
+
|
|
3
|
+
### Creating Tools
|
|
4
|
+
1. Create a folder: \`.ariaflow/tools/<tool-name>/
|
|
5
|
+
2. Add \`tool.json\` with schema
|
|
6
|
+
3. Add \`index.ts\` with handler
|
|
7
|
+
|
|
8
|
+
### Creating Flows
|
|
9
|
+
1. Create \`.ariaflow/flow/<name>.json\`
|
|
10
|
+
2. Define nodes with prompts
|
|
11
|
+
3. Add transitions between nodes
|
|
12
|
+
|
|
13
|
+
### Adding Guardrails
|
|
14
|
+
1. Define refusal messages in prompts
|
|
15
|
+
2. Add validation in tool handlers
|
|
16
|
+
3. Set up escalation to human
|
|
17
|
+
|
|
18
|
+
### Running the Agent
|
|
19
|
+
1. dev: \`ariaflow dev\`
|
|
20
|
+
2. Build pack: \`ariaflow build-pack\`
|
|
21
|
+
3. Run: \`npm run dev\` or deploy to cloud
|
|
22
|
+
`;
|
|
23
|
+
const DEVELOPMENT_STEPS = `## Development Steps
|
|
24
|
+
|
|
25
|
+
### 1. Set Up Project
|
|
26
|
+
- Create new AriaFlow pack: \`ariaflow init <name>\`
|
|
27
|
+
- Or add to existing project
|
|
28
|
+
|
|
29
|
+
### 2. Implement Required Tools
|
|
30
|
+
For each required tool:
|
|
31
|
+
- Create folder: \`.ariaflow/tools/<tool-name>/
|
|
32
|
+
- Add tool.json with schema
|
|
33
|
+
- Add index.ts with handler
|
|
34
|
+
- Test tool independently
|
|
35
|
+
|
|
36
|
+
### 3. Configure Agent
|
|
37
|
+
- Add agent to ariaflow.jsonc
|
|
38
|
+
- Attach generated 6-layer system prompt
|
|
39
|
+
- Register tools
|
|
40
|
+
|
|
41
|
+
### 4. Create Flow (if flow/hybrid mode)
|
|
42
|
+
- Create flow JSON in .ariaflow/flow/
|
|
43
|
+
- Define nodes and transitions
|
|
44
|
+
- Add prompts per node
|
|
45
|
+
|
|
46
|
+
### 5. Test
|
|
47
|
+
- Run locally: \`ariaflow dev\`
|
|
48
|
+
- Verify all tools work
|
|
49
|
+
- Check error handling
|
|
50
|
+
`;
|
|
51
|
+
const USER_JOURNEY = (blueprint) => {
|
|
52
|
+
const requiredTools = blueprint.toolRecommendations.filter(t => t.priority === 'required');
|
|
53
|
+
return `## User Journey
|
|
54
|
+
|
|
55
|
+
### How the conversation flows:
|
|
56
|
+
|
|
57
|
+
${blueprint.mode === 'llm' ? `
|
|
58
|
+
1. **User starts conversation** - AI greets and asks what they need
|
|
59
|
+
2. **User explains intent** - AI understands and collects information
|
|
60
|
+
3. **AI processes** - Uses tools to get answers or complete tasks
|
|
61
|
+
4. **AI responds** - Gives helpful answer or confirmation
|
|
62
|
+
5. **Continue or end** - User continues or ends conversation
|
|
63
|
+
` : `
|
|
64
|
+
1. **User starts conversation** - Flow starts at entry point
|
|
65
|
+
2. **AI collects info** - Goes through nodes asking for required details
|
|
66
|
+
3. **AI validates** - Checks data, calculates prices, etc.
|
|
67
|
+
4. **AI confirms** - Shows summary, asks for confirmation
|
|
68
|
+
5. **AI completes** - Logs data, sends notifications, sets reminders
|
|
69
|
+
6. **Done** - User gets confirmation
|
|
70
|
+
`}
|
|
71
|
+
|
|
72
|
+
### Key conversation moments:
|
|
73
|
+
${requiredTools.slice(0, 6).map(t => `- **${t.toolName}**: ${t.whenToUse.split('.')[0]}`).join('\n')}
|
|
74
|
+
|
|
75
|
+
### Error handling:
|
|
76
|
+
- Tool fails → retry → inform user → offer alternatives
|
|
77
|
+
- User makes mistake → ask clarifying questions
|
|
78
|
+
- Can't help → escalate to human
|
|
79
|
+
`;
|
|
80
|
+
};
|
|
81
|
+
const WHAT_NEXT = (blueprint) => {
|
|
82
|
+
const requiredTools = blueprint.toolRecommendations.filter(t => t.priority === 'required');
|
|
83
|
+
return `## Implementation Checklist
|
|
84
|
+
|
|
85
|
+
### Set Up Project
|
|
86
|
+
- [ ] Initialize AriaFlow pack or add to existing project
|
|
87
|
+
|
|
88
|
+
### Implement Required Tools
|
|
89
|
+
${requiredTools.map(t => `- [ ] ${t.toolName}`).join('\n')}
|
|
90
|
+
|
|
91
|
+
### Configure Agent
|
|
92
|
+
- [ ] Add agent to ariaflow.jsonc
|
|
93
|
+
- [ ] Attach generated system prompt
|
|
94
|
+
- [ ] Register tools
|
|
95
|
+
|
|
96
|
+
### Test
|
|
97
|
+
- [ ] Run \`ariaflow dev\`
|
|
98
|
+
- [ ] Test happy path conversation
|
|
99
|
+
- [ ] Test error handling
|
|
100
|
+
|
|
101
|
+
### Deploy (when ready)
|
|
102
|
+
- [ ] Build pack: \`ariaflow build-pack\`
|
|
103
|
+
- [ ] Deploy to runtime (Hono/Cloudflare/Docker)
|
|
104
|
+
`;
|
|
105
|
+
};
|
|
106
|
+
export function generateRfcMarkdown(blueprint, artifacts, detailLevel = 'detailed') {
|
|
107
|
+
const lines = [
|
|
108
|
+
`# RFC: ${blueprint.name}`,
|
|
109
|
+
'',
|
|
110
|
+
`> Generated: ${blueprint.generationMeta.generatedAt}`,
|
|
111
|
+
`> Use case: ${blueprint.useCase}`,
|
|
112
|
+
`> Mode: ${blueprint.mode}`,
|
|
113
|
+
`> Detail Level: ${detailLevel}`,
|
|
114
|
+
`> Model: ${blueprint.generationMeta.model}`,
|
|
115
|
+
'',
|
|
116
|
+
'## Overview',
|
|
117
|
+
'',
|
|
118
|
+
blueprint.useCase,
|
|
119
|
+
'',
|
|
120
|
+
'## Domain Analysis (LLM-Generated)',
|
|
121
|
+
'',
|
|
122
|
+
`- **Domain**: ${blueprint.domainAnalysis.domain}`,
|
|
123
|
+
];
|
|
124
|
+
if (blueprint.domainAnalysis.subDomain) {
|
|
125
|
+
lines.push(`- **Sub-domain**: ${blueprint.domainAnalysis.subDomain}`);
|
|
126
|
+
}
|
|
127
|
+
lines.push(`- **Entities**: ${blueprint.domainAnalysis.entities.join(', ')}`, `- **Workflows**: ${blueprint.domainAnalysis.workflows.join(', ')}`, `- **User Intents**: ${blueprint.domainAnalysis.userIntents.join(', ')}`, `- **Key Outcomes**: ${blueprint.domainAnalysis.keyOutcomes.join(', ')}`);
|
|
128
|
+
lines.push('');
|
|
129
|
+
lines.push('## Recommended Tools');
|
|
130
|
+
lines.push('');
|
|
131
|
+
const requiredTools = blueprint.toolRecommendations.filter(t => t.priority === 'required');
|
|
132
|
+
const recommendedTools = blueprint.toolRecommendations.filter(t => t.priority === 'recommended');
|
|
133
|
+
const optionalTools = blueprint.toolRecommendations.filter(t => t.priority === 'optional');
|
|
134
|
+
if (detailLevel === 'simple') {
|
|
135
|
+
lines.push('### Required Tools');
|
|
136
|
+
for (const tool of requiredTools) {
|
|
137
|
+
lines.push(`- **${tool.toolName}**: ${tool.description}`);
|
|
138
|
+
}
|
|
139
|
+
lines.push('');
|
|
140
|
+
if (recommendedTools.length > 0) {
|
|
141
|
+
lines.push('### Recommended Tools (Future)');
|
|
142
|
+
for (const tool of recommendedTools) {
|
|
143
|
+
lines.push(`- **${tool.toolName}**: ${tool.description}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
for (const tool of blueprint.toolRecommendations) {
|
|
149
|
+
lines.push(`### ${tool.toolName}`);
|
|
150
|
+
lines.push(`- **Description**: ${tool.description}`);
|
|
151
|
+
lines.push(`- **Priority**: ${tool.priority}`);
|
|
152
|
+
lines.push(`- **Reason**: ${tool.reason}`);
|
|
153
|
+
lines.push(`- **When to use**: ${tool.whenToUse}`);
|
|
154
|
+
if (tool.onError) {
|
|
155
|
+
lines.push(`- **On error**: ${tool.onError}`);
|
|
156
|
+
}
|
|
157
|
+
lines.push('');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
lines.push('## Tool Policy (LLM-Generated)', '');
|
|
161
|
+
for (const [toolName, policy] of Object.entries(blueprint.toolPolicy)) {
|
|
162
|
+
lines.push(`### ${toolName}`);
|
|
163
|
+
lines.push(policy);
|
|
164
|
+
lines.push('');
|
|
165
|
+
}
|
|
166
|
+
lines.push('## Prompt Layers Summary (LLM-Generated)', '');
|
|
167
|
+
lines.push('');
|
|
168
|
+
lines.push('### 1. Identity and Role');
|
|
169
|
+
lines.push('');
|
|
170
|
+
lines.push(blueprint.promptLayers.identityAndRole.content.slice(0, 500) + (blueprint.promptLayers.identityAndRole.content.length > 500 ? '...' : ''));
|
|
171
|
+
lines.push('');
|
|
172
|
+
lines.push('### 2. Safety and Guardrails');
|
|
173
|
+
lines.push('');
|
|
174
|
+
lines.push(blueprint.promptLayers.safetyAndGuardrails.content.slice(0, 500) + (blueprint.promptLayers.safetyAndGuardrails.content.length > 500 ? '...' : ''));
|
|
175
|
+
lines.push('');
|
|
176
|
+
lines.push('### 3. Tool Contract');
|
|
177
|
+
lines.push('');
|
|
178
|
+
lines.push(blueprint.promptLayers.toolContract.content.slice(0, 500) + (blueprint.promptLayers.toolContract.content.length > 500 ? '...' : ''));
|
|
179
|
+
lines.push('');
|
|
180
|
+
lines.push('');
|
|
181
|
+
lines.push(STATIC_GUIDES_REFERENCE);
|
|
182
|
+
lines.push('');
|
|
183
|
+
lines.push(WHAT_NEXT(blueprint));
|
|
184
|
+
lines.push('');
|
|
185
|
+
lines.push(DEVELOPMENT_STEPS);
|
|
186
|
+
lines.push('');
|
|
187
|
+
lines.push(USER_JOURNEY(blueprint));
|
|
188
|
+
lines.push('');
|
|
189
|
+
if (detailLevel === 'detailed' && blueprint.flowDesign) {
|
|
190
|
+
lines.push('## Flow Design (LLM-Generated)', '');
|
|
191
|
+
lines.push(`**Entry Point**: ${blueprint.flowDesign.entryPoint}`);
|
|
192
|
+
lines.push('');
|
|
193
|
+
lines.push('### Nodes');
|
|
194
|
+
for (const node of blueprint.flowDesign.nodes) {
|
|
195
|
+
lines.push(`#### ${node.id}: ${node.name}`);
|
|
196
|
+
lines.push(`- Purpose: ${node.purpose}`);
|
|
197
|
+
if (node.toolCalls && node.toolCalls.length > 0) {
|
|
198
|
+
lines.push(`- Tools: ${node.toolCalls.join(', ')}`);
|
|
199
|
+
}
|
|
200
|
+
lines.push('- Success criteria:');
|
|
201
|
+
for (const criterion of node.successCriteria) {
|
|
202
|
+
lines.push(` - ${criterion}`);
|
|
203
|
+
}
|
|
204
|
+
lines.push('');
|
|
205
|
+
}
|
|
206
|
+
lines.push('### Transitions');
|
|
207
|
+
for (const transition of blueprint.flowDesign.transitions) {
|
|
208
|
+
lines.push(`- ${transition.from} → ${transition.to}`);
|
|
209
|
+
lines.push(` - Trigger: ${transition.trigger}`);
|
|
210
|
+
if (transition.condition) {
|
|
211
|
+
lines.push(` - Condition: ${transition.condition}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
lines.push('');
|
|
215
|
+
}
|
|
216
|
+
lines.push('## Evaluation Scenarios', '');
|
|
217
|
+
for (const scenario of blueprint.evalPlan.scenarios) {
|
|
218
|
+
lines.push(`- ${scenario}`);
|
|
219
|
+
}
|
|
220
|
+
lines.push('');
|
|
221
|
+
return lines.filter(Boolean).join('\n');
|
|
222
|
+
}
|
|
223
|
+
export function generateToolSpecifications(recommendations) {
|
|
224
|
+
return recommendations.map(tool => ({
|
|
225
|
+
name: tool.toolName,
|
|
226
|
+
description: tool.description,
|
|
227
|
+
inputSchema: generateInputSchemaForTool(tool.toolName),
|
|
228
|
+
outputSchema: generateOutputSchemaForTool(tool.toolName),
|
|
229
|
+
integrationSteps: generateIntegrationSteps(tool),
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
function generateInputSchemaForTool(toolName) {
|
|
233
|
+
const lower = toolName.toLowerCase();
|
|
234
|
+
if (lower.includes('log') || lower.includes('sheet') || lower.includes('create_record')) {
|
|
235
|
+
return {
|
|
236
|
+
type: 'object',
|
|
237
|
+
properties: {
|
|
238
|
+
data: { type: 'object', description: 'Data to log' },
|
|
239
|
+
sheetId: { type: 'string', description: 'Google Sheet ID (optional)' },
|
|
240
|
+
},
|
|
241
|
+
required: ['data'],
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (lower.includes('send') && (lower.includes('message') || lower.includes('whatsapp') || lower.includes('sms'))) {
|
|
245
|
+
return {
|
|
246
|
+
type: 'object',
|
|
247
|
+
properties: {
|
|
248
|
+
to: { type: 'string', description: 'Recipient phone number' },
|
|
249
|
+
message: { type: 'string', description: 'Message content' },
|
|
250
|
+
},
|
|
251
|
+
required: ['to', 'message'],
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
if (lower.includes('calendar') || lower.includes('event') || lower.includes('reminder')) {
|
|
255
|
+
return {
|
|
256
|
+
type: 'object',
|
|
257
|
+
properties: {
|
|
258
|
+
title: { type: 'string', description: 'Event title' },
|
|
259
|
+
startTime: { type: 'string', description: 'ISO 8601 datetime' },
|
|
260
|
+
endTime: { type: 'string', description: 'ISO 8601 datetime' },
|
|
261
|
+
description: { type: 'string', description: 'Event description' },
|
|
262
|
+
attendees: { type: 'array', items: { type: 'string' }, description: 'Email addresses' },
|
|
263
|
+
},
|
|
264
|
+
required: ['title', 'startTime'],
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
if (lower.includes('lookup') || lower.includes('get') || lower.includes('query')) {
|
|
268
|
+
return {
|
|
269
|
+
type: 'object',
|
|
270
|
+
properties: {
|
|
271
|
+
query: { type: 'string', description: 'Search query' },
|
|
272
|
+
filters: { type: 'object', description: 'Optional filters' },
|
|
273
|
+
limit: { type: 'number', description: 'Max results' },
|
|
274
|
+
},
|
|
275
|
+
required: ['query'],
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
type: 'object',
|
|
280
|
+
properties: {},
|
|
281
|
+
description: 'Tool-specific parameters',
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function generateOutputSchemaForTool(toolName) {
|
|
285
|
+
const lower = toolName.toLowerCase();
|
|
286
|
+
if (lower.includes('log') || lower.includes('create') || lower.includes('send')) {
|
|
287
|
+
return {
|
|
288
|
+
type: 'object',
|
|
289
|
+
properties: {
|
|
290
|
+
success: { type: 'boolean' },
|
|
291
|
+
message: { type: 'string', description: 'Result message' },
|
|
292
|
+
id: { type: 'string', description: 'Created record ID (if applicable)' },
|
|
293
|
+
},
|
|
294
|
+
required: ['success'],
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (lower.includes('lookup') || lower.includes('get') || lower.includes('query')) {
|
|
298
|
+
return {
|
|
299
|
+
type: 'object',
|
|
300
|
+
properties: {
|
|
301
|
+
found: { type: 'boolean' },
|
|
302
|
+
data: { type: 'array', description: 'Results array' },
|
|
303
|
+
count: { type: 'number' },
|
|
304
|
+
},
|
|
305
|
+
required: ['found'],
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
type: 'object',
|
|
310
|
+
properties: {
|
|
311
|
+
success: { type: 'boolean' },
|
|
312
|
+
},
|
|
313
|
+
required: ['success'],
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function generateIntegrationSteps(tool) {
|
|
317
|
+
const steps = [];
|
|
318
|
+
const lower = tool.toolName.toLowerCase();
|
|
319
|
+
if (lower.includes('sheet') || lower.includes('google')) {
|
|
320
|
+
steps.push('1. Set up Google Cloud project with Sheets API enabled');
|
|
321
|
+
steps.push('2. Create service account and download credentials');
|
|
322
|
+
steps.push('3. Configure OAuth or service account access to the spreadsheet');
|
|
323
|
+
steps.push('4. Implement tool using googleapis npm package');
|
|
324
|
+
}
|
|
325
|
+
else if (lower.includes('whatsapp') || lower.includes('twilio')) {
|
|
326
|
+
steps.push('1. Set up Twilio account and WhatsApp sandbox');
|
|
327
|
+
steps.push('2. Configure credentials in environment variables');
|
|
328
|
+
steps.push('3. Implement tool using @twilio/node SDK');
|
|
329
|
+
steps.push('4. Test with Twilio console');
|
|
330
|
+
}
|
|
331
|
+
else if (lower.includes('calendar') || lower.includes('google')) {
|
|
332
|
+
steps.push('1. Set up Google Cloud project with Calendar API enabled');
|
|
333
|
+
steps.push('2. Create service account and add to calendar ACLs');
|
|
334
|
+
steps.push('3. Implement tool using googleapis npm package');
|
|
335
|
+
steps.push('4. Test event creation');
|
|
336
|
+
}
|
|
337
|
+
else if (lower.includes('database') || lower.includes('db')) {
|
|
338
|
+
steps.push('1. Configure database connection in environment');
|
|
339
|
+
steps.push('2. Implement tool with appropriate database driver');
|
|
340
|
+
steps.push('3. Add connection pooling for production');
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
steps.push(`1. Implement ${tool.toolName} tool in .ariaflow/tools/`);
|
|
344
|
+
steps.push('2. Define input/output schemas');
|
|
345
|
+
steps.push('3. Add error handling');
|
|
346
|
+
steps.push('4. Test tool independently');
|
|
347
|
+
}
|
|
348
|
+
return steps;
|
|
349
|
+
}
|
|
350
|
+
//# sourceMappingURL=rfc-emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rfc-emitter.js","sourceRoot":"","sources":["../../src/agent-architect/rfc-emitter.ts"],"names":[],"mappings":"AAEA,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;CAqB/B,CAAC;AAEF,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BzB,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,SAAyB,EAAE,EAAE;IACjD,MAAM,aAAa,GAAG,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC;IAE3F,OAAO;;;;EAIP,SAAS,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC;;;;;;CAM5B,CAAC,CAAC,CAAC;;;;;;;CAOH;;;EAGC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;CAMnG,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,SAAyB,EAAE,EAAE;IAC9C,MAAM,aAAa,GAAG,SAAS,CAAC,mBAAmB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C,IAAI,CAAC,gBAAgB,IAAI,CAAC,QAAQ,2BAA2B,CAAC,CAAC;QACrE,KAAK,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DomainAnalysis, type ToolRecommendation } from './types.js';
|
|
2
|
+
export interface ToolRecommenderOptions {
|
|
3
|
+
model?: string;
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function recommendTools(useCase: string, domainAnalysis: DomainAnalysis, options?: ToolRecommenderOptions): Promise<ToolRecommendation[]>;
|
|
7
|
+
export declare function getToolPolicy(recommendations: ToolRecommendation[]): Record<string, string>;
|
|
8
|
+
//# sourceMappingURL=tool-recommender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-recommender.d.ts","sourceRoot":"","sources":["../../src/agent-architect/tool-recommender.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAwD1E,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,cAAc,EAC9B,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAgC/B;AAED,wBAAgB,aAAa,CAAC,eAAe,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ3F"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { generateObject } from 'ai';
|
|
2
|
+
import { openai } from '@ai-sdk/openai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const ToolRecommendationLLMSchema = z.object({
|
|
5
|
+
recommendations: z.array(z.object({
|
|
6
|
+
toolName: z.string().describe('Name of the tool'),
|
|
7
|
+
description: z.string().describe('What the tool does'),
|
|
8
|
+
reason: z.string().describe('Why this tool is needed'),
|
|
9
|
+
whenToUse: z.string().describe('When to call this tool'),
|
|
10
|
+
onError: z.string().describe('How to handle errors'),
|
|
11
|
+
priority: z.enum(['required', 'recommended', 'optional']).describe('Priority level'),
|
|
12
|
+
})),
|
|
13
|
+
});
|
|
14
|
+
function resolveModel(modelInput) {
|
|
15
|
+
const requested = modelInput?.trim() || 'gpt-5-mini';
|
|
16
|
+
const modelId = requested.startsWith('openai:') ? requested.slice('openai:'.length).trim() : requested;
|
|
17
|
+
return openai(modelId || 'gpt-5-mini');
|
|
18
|
+
}
|
|
19
|
+
function buildToolRecommendationPrompt(useCase, domainAnalysis) {
|
|
20
|
+
return `Analyze this use case and recommend the tools the agent needs.
|
|
21
|
+
|
|
22
|
+
## Use Case
|
|
23
|
+
${useCase}
|
|
24
|
+
|
|
25
|
+
## Domain Analysis
|
|
26
|
+
- Domain: ${domainAnalysis.domain}
|
|
27
|
+
${domainAnalysis.subDomain ? `- Sub-domain: ${domainAnalysis.subDomain}` : ''}
|
|
28
|
+
- Entities: ${domainAnalysis.entities.join(', ')}
|
|
29
|
+
- Workflows: ${domainAnalysis.workflows.join(', ')}
|
|
30
|
+
- User Intents: ${domainAnalysis.userIntents.join(', ')}
|
|
31
|
+
- Key Outcomes: ${domainAnalysis.keyOutcomes.join(', ')}
|
|
32
|
+
|
|
33
|
+
## Your Task
|
|
34
|
+
Recommend ALL tools the agent needs to accomplish the key outcomes. Think about:
|
|
35
|
+
- What data needs to be stored or retrieved?
|
|
36
|
+
- What external systems need to be integrated?
|
|
37
|
+
- What notifications need to be sent?
|
|
38
|
+
- What scheduling or calendar operations?
|
|
39
|
+
- What e-commerce or business operations?
|
|
40
|
+
- What handoffs or escalations?
|
|
41
|
+
|
|
42
|
+
For EACH recommendation:
|
|
43
|
+
1. toolName: Descriptive name (e.g., "log_order_to_sheet", "send_notification", "create_reminder")
|
|
44
|
+
2. description: What the tool does
|
|
45
|
+
3. reason: Why this tool is needed based on workflows and outcomes
|
|
46
|
+
4. whenToUse: At what point in the conversation should this be called
|
|
47
|
+
5. onError: How to handle failures
|
|
48
|
+
6. priority: required | recommended | optional
|
|
49
|
+
|
|
50
|
+
Be thorough - think about the complete user journey from start to finish.`;
|
|
51
|
+
}
|
|
52
|
+
export async function recommendTools(useCase, domainAnalysis, options = {}) {
|
|
53
|
+
const model = resolveModel(options.model);
|
|
54
|
+
const timeoutMs = options.timeoutMs ?? 60000;
|
|
55
|
+
if (!process.env.OPENAI_API_KEY) {
|
|
56
|
+
throw new Error('OPENAI_API_KEY is required for LLM tool recommendation');
|
|
57
|
+
}
|
|
58
|
+
const result = await Promise.race([
|
|
59
|
+
generateObject({
|
|
60
|
+
model,
|
|
61
|
+
schema: ToolRecommendationLLMSchema,
|
|
62
|
+
system: `You are an expert at designing tools for conversational AI agents.
|
|
63
|
+
Given a use case and domain analysis, recommend the tools needed to accomplish the agent's goals.
|
|
64
|
+
Think about the complete user journey and what integrations are needed.
|
|
65
|
+
|
|
66
|
+
Create descriptive tool names that indicate their purpose. For example:
|
|
67
|
+
- log_order_to_sheet
|
|
68
|
+
- send_whatsapp_notification
|
|
69
|
+
- create_calendar_reminder
|
|
70
|
+
- lookup_customer_record
|
|
71
|
+
- calculate_order_total
|
|
72
|
+
|
|
73
|
+
Do NOT limit yourself to predefined tools - recommend what is needed.`,
|
|
74
|
+
prompt: buildToolRecommendationPrompt(useCase, domainAnalysis),
|
|
75
|
+
}),
|
|
76
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`Tool recommendation timed out after ${timeoutMs}ms`)), timeoutMs)),
|
|
77
|
+
]);
|
|
78
|
+
return result.object.recommendations;
|
|
79
|
+
}
|
|
80
|
+
export function getToolPolicy(recommendations) {
|
|
81
|
+
const policy = {};
|
|
82
|
+
for (const rec of recommendations) {
|
|
83
|
+
policy[rec.toolName] = `When: ${rec.whenToUse}. On error: ${rec.onError ?? 'Explain limitation and propose next step'}`;
|
|
84
|
+
}
|
|
85
|
+
return policy;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=tool-recommender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-recommender.js","sourceRoot":"","sources":["../../src/agent-architect/tool-recommender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACjD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QACtD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QACtD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACxD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACpD,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC;KACrF,CAAC,CAAC;CACJ,CAAC,CAAC;AAEH,SAAS,YAAY,CAAC,UAAmB;IACvC,MAAM,SAAS,GAAG,UAAU,EAAE,IA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