@ariaflowagents/config 0.3.5 → 0.4.2
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 +460 -33
- package/dist/loader.d.ts +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +112 -2
- package/dist/loader.js.map +1 -1
- package/dist/types.d.ts +58 -2
- package/dist/types.d.ts.map +1 -1
- package/guide/README.md +477 -0
- package/package.json +5 -3
package/guide/README.md
ADDED
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
# AriaFlow Config Guide
|
|
2
|
+
|
|
3
|
+
A comprehensive guide to creating and managing AriaFlow agent configurations.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The AriaFlow Config package (`@ariaflowagents/config`) provides:
|
|
8
|
+
- Configuration loading from `ari aflow.jsonc` files
|
|
9
|
+
- Agent and flow definition parsing
|
|
10
|
+
- Tool registration and loading
|
|
11
|
+
- Runtime creation from config
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @ariaflowagents/config
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuration File
|
|
20
|
+
|
|
21
|
+
### Basic Structure
|
|
22
|
+
|
|
23
|
+
```jsonc
|
|
24
|
+
{
|
|
25
|
+
"$schema": "https://ariaflow.ai/config.json",
|
|
26
|
+
"name": "my-agent",
|
|
27
|
+
"version": "1.0.0",
|
|
28
|
+
"runtime": {
|
|
29
|
+
"defaultAgent": "chat",
|
|
30
|
+
"defaultModel": "default"
|
|
31
|
+
},
|
|
32
|
+
"models": {
|
|
33
|
+
"default": "openai:gpt-4o-mini"
|
|
34
|
+
},
|
|
35
|
+
"agents": { /* ... */ },
|
|
36
|
+
"tools": { /* ... */ },
|
|
37
|
+
"providers": { /* ... */ }
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Runtime Configuration
|
|
42
|
+
|
|
43
|
+
### Default Agent & Model
|
|
44
|
+
|
|
45
|
+
```jsonc
|
|
46
|
+
{
|
|
47
|
+
"runtime": {
|
|
48
|
+
"defaultAgent": "chat",
|
|
49
|
+
"defaultModel": "default"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Model Registry
|
|
55
|
+
|
|
56
|
+
Define available models with providers:
|
|
57
|
+
|
|
58
|
+
```jsonc
|
|
59
|
+
{
|
|
60
|
+
"models": {
|
|
61
|
+
"default": "openai:gpt-4o-mini",
|
|
62
|
+
"gpt-4": "openai:gpt-4",
|
|
63
|
+
"claude-3": "anthropic:claude-3-5-sonnet-20241022"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Agents
|
|
69
|
+
|
|
70
|
+
Agents are the core components that handle user interactions.
|
|
71
|
+
|
|
72
|
+
### LLM Agent
|
|
73
|
+
|
|
74
|
+
```jsonc
|
|
75
|
+
{
|
|
76
|
+
"agents": {
|
|
77
|
+
"chat": {
|
|
78
|
+
"type": "llm",
|
|
79
|
+
"description": "A helpful assistant",
|
|
80
|
+
"prompt": {
|
|
81
|
+
"inline": "You are a helpful assistant. Be concise."
|
|
82
|
+
},
|
|
83
|
+
"tools": ["search", "calculator"]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Triage Agent
|
|
90
|
+
|
|
91
|
+
Routes users to specialized agents:
|
|
92
|
+
|
|
93
|
+
```jsonc
|
|
94
|
+
{
|
|
95
|
+
"agents": {
|
|
96
|
+
"triage": {
|
|
97
|
+
"type": "triage",
|
|
98
|
+
"description": "Routes customers to the right department",
|
|
99
|
+
"prompt": { "file": "./prompts/triage.md" },
|
|
100
|
+
"routes": [
|
|
101
|
+
{
|
|
102
|
+
"agentId": "sales",
|
|
103
|
+
"description": "Handles sales inquiries"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"agentId": "support",
|
|
107
|
+
"description": "Handles support issues"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"defaultAgent": "sales"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Flow Agent
|
|
117
|
+
|
|
118
|
+
Guided workflow agents:
|
|
119
|
+
|
|
120
|
+
```jsonc
|
|
121
|
+
{
|
|
122
|
+
"agents": {
|
|
123
|
+
"booking": {
|
|
124
|
+
"type": "flow",
|
|
125
|
+
"description": "Hotel booking flow",
|
|
126
|
+
"prompt": { "file": "./prompts/booking.md" },
|
|
127
|
+
"flowRef": "booking-flow",
|
|
128
|
+
"mode": "hybrid"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Inline Prompt
|
|
135
|
+
|
|
136
|
+
For simple agents, use inline prompts:
|
|
137
|
+
|
|
138
|
+
```jsonc
|
|
139
|
+
{
|
|
140
|
+
"agents": {
|
|
141
|
+
"chat": {
|
|
142
|
+
"type": "llm",
|
|
143
|
+
"description": "A helpful assistant",
|
|
144
|
+
"prompt": {
|
|
145
|
+
"inline": "You are a helpful assistant. Be concise and friendly."
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### File-based Prompt
|
|
153
|
+
|
|
154
|
+
For complex prompts, use external files:
|
|
155
|
+
|
|
156
|
+
```jsonc
|
|
157
|
+
{
|
|
158
|
+
"agents": {
|
|
159
|
+
"support": {
|
|
160
|
+
"type": "llm",
|
|
161
|
+
"description": "Customer support",
|
|
162
|
+
"prompt": { "file": "./prompts/support.md" }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Create the prompt file:
|
|
169
|
+
|
|
170
|
+
```markdown
|
|
171
|
+
# System Prompt
|
|
172
|
+
|
|
173
|
+
You are a customer support agent for our company.
|
|
174
|
+
|
|
175
|
+
## Guidelines
|
|
176
|
+
- Be empathetic and patient
|
|
177
|
+
- Always verify customer identity before sharing sensitive info
|
|
178
|
+
- Escalate complex issues to human agents
|
|
179
|
+
|
|
180
|
+
## Tools Available
|
|
181
|
+
- create_ticket: Create support tickets
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Tools
|
|
185
|
+
|
|
186
|
+
### External Tools
|
|
187
|
+
|
|
188
|
+
Define tools that agents can use:
|
|
189
|
+
|
|
190
|
+
```jsonc
|
|
191
|
+
{
|
|
192
|
+
"tools": {
|
|
193
|
+
"search": {
|
|
194
|
+
"type": "module",
|
|
195
|
+
"entry": "./tools/search/index.ts"
|
|
196
|
+
},
|
|
197
|
+
"calculator": {
|
|
198
|
+
"type": "module",
|
|
199
|
+
"entry": "./tools/calculator/index.ts"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Tool implementation (`tools/search/index.ts`):
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import type { ToolDefinition } from '@ariaflowagents/core';
|
|
209
|
+
|
|
210
|
+
export const tool: ToolDefinition = {
|
|
211
|
+
description: 'Search for information',
|
|
212
|
+
inputSchema: {
|
|
213
|
+
type: 'object',
|
|
214
|
+
properties: {
|
|
215
|
+
query: { type: 'string', description: 'Search query' }
|
|
216
|
+
},
|
|
217
|
+
required: ['query']
|
|
218
|
+
},
|
|
219
|
+
execute: async (input: unknown) => {
|
|
220
|
+
const { query } = input as { query: string };
|
|
221
|
+
// Implementation
|
|
222
|
+
return { results: [...] };
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export default tool;
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Skill Loader
|
|
230
|
+
|
|
231
|
+
Load skills from a directory:
|
|
232
|
+
|
|
233
|
+
```jsonc
|
|
234
|
+
{
|
|
235
|
+
"tools": {
|
|
236
|
+
"skill": {
|
|
237
|
+
"type": "skill-loader",
|
|
238
|
+
"paths": ["./skill"]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Flows
|
|
245
|
+
|
|
246
|
+
Define reusable workflow patterns:
|
|
247
|
+
|
|
248
|
+
```jsonc
|
|
249
|
+
{
|
|
250
|
+
"flows": {
|
|
251
|
+
"booking-flow": {
|
|
252
|
+
"steps": [
|
|
253
|
+
{
|
|
254
|
+
"id": "collect-info",
|
|
255
|
+
"tool": "collect_info"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"id": "confirm",
|
|
259
|
+
"tool": "confirm_booking"
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Providers
|
|
268
|
+
|
|
269
|
+
Configure API providers:
|
|
270
|
+
|
|
271
|
+
```jsonc
|
|
272
|
+
{
|
|
273
|
+
"providers": {
|
|
274
|
+
"openai": {
|
|
275
|
+
"apiKey": "OPENAI_API_KEY",
|
|
276
|
+
"baseUrl": "https://api.openai.com/v1"
|
|
277
|
+
},
|
|
278
|
+
"anthropic": {
|
|
279
|
+
"apiKey": "ANTHROPIC_API_KEY"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Loading Configuration
|
|
286
|
+
|
|
287
|
+
### Basic Loading
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
import { loadAriaflowConfig } from '@ariaflowagents/config';
|
|
291
|
+
|
|
292
|
+
const config = await loadAriaflowConfig({
|
|
293
|
+
configPath: './ari aflow.jsonc'
|
|
294
|
+
});
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### With Model Registry
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
import { loadAriaflowConfigWithResult } from '@ariaflowagents/config';
|
|
301
|
+
import { openai } from '@ai-sdk/openai';
|
|
302
|
+
|
|
303
|
+
const model = openai('gpt-4o-mini') as any;
|
|
304
|
+
|
|
305
|
+
const { config, summary, warnings } = await loadAriaflowConfigWithResult({
|
|
306
|
+
configPath: './ari aflow.jsonc',
|
|
307
|
+
modelRegistry: {
|
|
308
|
+
default: model,
|
|
309
|
+
'openai:gpt-4o-mini': model
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
console.log(`Loaded ${summary.agents} agents`);
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Create Runtime
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
import { createRuntimeFromConfig } from '@ariaflowagents/config';
|
|
320
|
+
|
|
321
|
+
const { config } = await loadAriaflowConfigWithResult({
|
|
322
|
+
configPath: './ari aflow.jsonc'
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
const runtime = createRuntimeFromConfig(config);
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Directory Structure
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
my-agent/
|
|
332
|
+
├── ariaflow.jsonc # Main configuration
|
|
333
|
+
├── .ariaflow/
|
|
334
|
+
│ ├── prompts/
|
|
335
|
+
│ │ ├── system.md # System prompts
|
|
336
|
+
│ │ ├── chat.md # Agent prompts
|
|
337
|
+
│ │ └── triage.md # Triage prompts
|
|
338
|
+
│ ├── tools/
|
|
339
|
+
│ │ ├── search/
|
|
340
|
+
│ │ │ ├── index.ts # Tool implementation
|
|
341
|
+
│ │ │ └── tool.json # Tool metadata
|
|
342
|
+
│ │ └── calculator/
|
|
343
|
+
│ │ ├── index.ts
|
|
344
|
+
│ │ └── tool.json
|
|
345
|
+
│ ├── skill/
|
|
346
|
+
│ │ └── my-skill/
|
|
347
|
+
│ │ └── SKILL.md
|
|
348
|
+
│ └── flow/
|
|
349
|
+
│ └── booking-flow.json # Flow definitions
|
|
350
|
+
└── package.json # Optional: Tool dependencies
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Example: Complete Configuration
|
|
354
|
+
|
|
355
|
+
```jsonc
|
|
356
|
+
{
|
|
357
|
+
"$schema": "https://ariaflow.ai/config.json",
|
|
358
|
+
"name": "support-agent",
|
|
359
|
+
"version": "1.0.0",
|
|
360
|
+
"runtime": {
|
|
361
|
+
"defaultAgent": "triage",
|
|
362
|
+
"defaultModel": "gpt-4o-mini"
|
|
363
|
+
},
|
|
364
|
+
"models": {
|
|
365
|
+
"default": "openai:gpt-4o-mini",
|
|
366
|
+
"gpt-4": "openai:gpt-4"
|
|
367
|
+
},
|
|
368
|
+
"agents": {
|
|
369
|
+
"triage": {
|
|
370
|
+
"type": "triage",
|
|
371
|
+
"description": "Routes support requests",
|
|
372
|
+
"prompt": { "file": "./prompts/triage.md" },
|
|
373
|
+
"routes": [
|
|
374
|
+
{ "agentId": "billing", "description": "Billing inquiries" },
|
|
375
|
+
{ "agentId": "technical", "description": "Technical support" }
|
|
376
|
+
],
|
|
377
|
+
"defaultAgent": "billing"
|
|
378
|
+
},
|
|
379
|
+
"billing": {
|
|
380
|
+
"type": "llm",
|
|
381
|
+
"description": "Handles billing questions",
|
|
382
|
+
"prompt": { "file": "./prompts/billing.md" },
|
|
383
|
+
"tools": ["create_ticket"]
|
|
384
|
+
},
|
|
385
|
+
"technical": {
|
|
386
|
+
"type": "llm",
|
|
387
|
+
"description": "Technical support",
|
|
388
|
+
"prompt": { "file": "./prompts/technical.md" },
|
|
389
|
+
"tools": ["diagnose", "create_ticket"]
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
"tools": {
|
|
393
|
+
"create_ticket": {
|
|
394
|
+
"type": "module",
|
|
395
|
+
"entry": "./tools/create_ticket/index.ts"
|
|
396
|
+
},
|
|
397
|
+
"diagnose": {
|
|
398
|
+
"type": "module",
|
|
399
|
+
"entry": "./tools/diagnose/index.ts"
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
"providers": {
|
|
403
|
+
"openai": {
|
|
404
|
+
"apiKey": "OPENAI_API_KEY"
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## Configuration Reference
|
|
411
|
+
|
|
412
|
+
### Root Properties
|
|
413
|
+
|
|
414
|
+
| Property | Type | Required | Description |
|
|
415
|
+
|----------|------|----------|-------------|
|
|
416
|
+
| `$schema` | string | No | JSON schema URI |
|
|
417
|
+
| `name` | string | Yes | Agent name |
|
|
418
|
+
| `version` | string | No | Version number |
|
|
419
|
+
| `runtime` | object | Yes | Runtime configuration |
|
|
420
|
+
| `models` | object | Yes | Model registry |
|
|
421
|
+
| `agents` | object | Yes | Agent definitions |
|
|
422
|
+
| `tools` | object | No | Tool definitions |
|
|
423
|
+
| `providers` | object | No | Provider configurations |
|
|
424
|
+
| `permissions` | object | No | Permission settings |
|
|
425
|
+
|
|
426
|
+
### Runtime Properties
|
|
427
|
+
|
|
428
|
+
| Property | Type | Description |
|
|
429
|
+
|----------|------|-------------|
|
|
430
|
+
| `defaultAgent` | string | Default agent ID |
|
|
431
|
+
| `defaultModel` | string | Default model key |
|
|
432
|
+
|
|
433
|
+
### Agent Properties
|
|
434
|
+
|
|
435
|
+
| Property | Type | Description |
|
|
436
|
+
|----------|------|-------------|
|
|
437
|
+
| `type` | string | Agent type: `llm`, `triage`, `flow` |
|
|
438
|
+
| `description` | string | Agent description |
|
|
439
|
+
| `prompt` | object | Prompt configuration |
|
|
440
|
+
| `tools` | array | List of tool names |
|
|
441
|
+
| `routes` | array | Triage routes (triage only) |
|
|
442
|
+
| `defaultAgent` | string | Default route (triage only) |
|
|
443
|
+
| `flowRef` | string | Flow reference (flow only) |
|
|
444
|
+
| `mode` | string | Flow mode: `guided`, `hybrid` (flow only) |
|
|
445
|
+
|
|
446
|
+
### Prompt Properties
|
|
447
|
+
|
|
448
|
+
| Property | Type | Description |
|
|
449
|
+
|----------|------|-------------|
|
|
450
|
+
| `inline` | string | Inline prompt text |
|
|
451
|
+
| `file` | string | Path to prompt file |
|
|
452
|
+
|
|
453
|
+
## Best Practices
|
|
454
|
+
|
|
455
|
+
1. **Use file-based prompts** for complex prompts (>100 lines)
|
|
456
|
+
2. **Organize tools** in separate directories with `tool.json` metadata
|
|
457
|
+
3. **Use triage agents** for multi-agent routing
|
|
458
|
+
4. **Version your config** using semantic versioning
|
|
459
|
+
5. **Test locally** using the Hono server before deployment
|
|
460
|
+
6. **Use environment variables** for API keys
|
|
461
|
+
|
|
462
|
+
## Integration with Hono Server
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
import { loadAriaflowConfigWithResult, createRuntimeFromConfig } from '@ariaflowagents/config';
|
|
466
|
+
import { createAriaChatRouter } from '@ariaflowagents/hono-server';
|
|
467
|
+
|
|
468
|
+
const { config, summary } = await loadAriaflowConfigWithResult({
|
|
469
|
+
configPath: './ari aflow.jsonc',
|
|
470
|
+
modelRegistry: { default: model }
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
const runtime = createRuntimeFromConfig(config);
|
|
474
|
+
|
|
475
|
+
const app = new Hono();
|
|
476
|
+
app.route('/', createAriaChatRouter({ runtime }));
|
|
477
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ariaflowagents/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Config loader for AriaFlow (agents, flows, tools, skills)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,14 +21,15 @@
|
|
|
21
21
|
"gray-matter": "^4.0.3",
|
|
22
22
|
"jsonc-parser": "^3.2.0",
|
|
23
23
|
"minimatch": "^9.0.5",
|
|
24
|
-
"zod": "^3.23.8"
|
|
24
|
+
"zod": "^3.23.8",
|
|
25
|
+
"@ariaflowagents/core": "0.4.1"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"@ariaflowagents/core": "^0.3.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@ai-sdk/openai": "^3.0.0",
|
|
31
|
-
"@ariaflowagents/core": "
|
|
32
|
+
"@ariaflowagents/core": "0.4.1",
|
|
32
33
|
"@types/node": "^20.11.0",
|
|
33
34
|
"dotenv": "^16.4.0",
|
|
34
35
|
"tsx": "^4.7.0",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
},
|
|
48
49
|
"files": [
|
|
49
50
|
"dist",
|
|
51
|
+
"guide",
|
|
50
52
|
"README.md"
|
|
51
53
|
]
|
|
52
54
|
}
|