@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/README.md
CHANGED
|
@@ -1,50 +1,477 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AriaFlow Config Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive guide to creating and managing AriaFlow agent configurations.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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"
|
|
17
31
|
},
|
|
18
|
-
|
|
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
|
+
```
|
|
19
183
|
|
|
20
|
-
|
|
184
|
+
## Tools
|
|
21
185
|
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
}
|
|
24
202
|
}
|
|
25
203
|
```
|
|
26
204
|
|
|
27
|
-
|
|
205
|
+
Tool implementation (`tools/search/index.ts`):
|
|
28
206
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
3. Project: `ariaflow.json(c)` at git root
|
|
32
|
-
4. `.ariaflow/` directories (agents/flows/tools/skills)
|
|
33
|
-
5. Inline: `ARIAFLOW_CONFIG_CONTENT`
|
|
207
|
+
```typescript
|
|
208
|
+
import type { ToolDefinition } from '@ariaflowagents/core';
|
|
34
209
|
|
|
35
|
-
|
|
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
|
+
};
|
|
36
225
|
|
|
226
|
+
export default tool;
|
|
37
227
|
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
}
|
|
44
242
|
```
|
|
45
243
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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 }));
|
|
50
477
|
```
|
package/dist/loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HarnessConfig, type Runtime } from '@ariaflowagents/core';
|
|
2
2
|
import type { LoadedConfig, LoadOptions } from './types.js';
|
|
3
|
-
type WarningType = 'invalid_frontmatter' | 'missing_prompt' | 'name_mismatch' | 'missing_ref' | 'invalid_tool_entry' | 'duplicate_agent' | 'duplicate_flow' | 'unresolved_flow_ref' | 'tool_not_found';
|
|
3
|
+
type WarningType = 'invalid_frontmatter' | 'missing_prompt' | 'missing_template' | 'name_mismatch' | 'missing_ref' | 'invalid_tool_entry' | 'duplicate_agent' | 'duplicate_flow' | 'unresolved_flow_ref' | 'tool_not_found';
|
|
4
4
|
interface ConfigWarning {
|
|
5
5
|
type: WarningType;
|
|
6
6
|
file: string;
|
package/dist/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAWA,OAAO,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAWA,OAAO,EAQL,KAAK,aAAa,EAElB,KAAK,OAAO,EAGb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAIV,YAAY,EACZ,WAAW,EAMZ,MAAM,YAAY,CAAC;AA0CpB,KAAK,WAAW,GACZ,qBAAqB,GACrB,gBAAgB,GAChB,kBAAkB,GAClB,eAAe,GACf,aAAa,GACb,oBAAoB,GACpB,iBAAiB,GACjB,gBAAgB,GAChB,qBAAqB,GACrB,gBAAgB,CAAC;AAErB,UAAU,aAAa;IACrB,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AA0yBD,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CA4PzF;AAED,wBAAsB,4BAA4B,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC;IACrF,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B,CAAC,CA+QD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAanH;AA0FD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,EACpB,SAAS,GAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,gBAAgB,GAAG,cAAc,CAAC,CAAM,GACzF,OAAO,CAST"}
|
package/dist/loader.js
CHANGED
|
@@ -9,7 +9,8 @@ import { parse as parseJsonc } from 'jsonc-parser';
|
|
|
9
9
|
import { minimatch } from 'minimatch';
|
|
10
10
|
import { tool as aiTool } from 'ai';
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
-
import { createRuntime, } from '@ariaflowagents/core';
|
|
12
|
+
import { createRuntime, getTemplate, } from '@ariaflowagents/core';
|
|
13
|
+
import { PromptTemplateBuilder } from '@ariaflowagents/core';
|
|
13
14
|
let _warnings = [];
|
|
14
15
|
let _logger = null;
|
|
15
16
|
let _silent = false;
|
|
@@ -307,6 +308,115 @@ async function resolvePrompt(value, baseDir) {
|
|
|
307
308
|
}
|
|
308
309
|
return readFile(resolvedPath, 'utf8');
|
|
309
310
|
}
|
|
311
|
+
// Handle template references
|
|
312
|
+
if (typeof value === 'object' && value !== null && 'template' in value) {
|
|
313
|
+
const templateRef = value;
|
|
314
|
+
const template = getTemplate(templateRef.template);
|
|
315
|
+
if (!template) {
|
|
316
|
+
warn('missing_template', templateRef.template, `Template "${templateRef.template}" not found`);
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
// Create builder from template
|
|
320
|
+
const builder = new PromptTemplateBuilder({
|
|
321
|
+
id: template.id,
|
|
322
|
+
name: template.name,
|
|
323
|
+
description: template.description,
|
|
324
|
+
});
|
|
325
|
+
// Apply customizations
|
|
326
|
+
if (templateRef.customize) {
|
|
327
|
+
if (templateRef.customize.personality) {
|
|
328
|
+
builder.personality(templateRef.customize.personality);
|
|
329
|
+
}
|
|
330
|
+
if (templateRef.customize.goal) {
|
|
331
|
+
builder.goal(templateRef.customize.goal);
|
|
332
|
+
}
|
|
333
|
+
if (templateRef.customize.guardrails) {
|
|
334
|
+
builder.guardrails(templateRef.customize.guardrails);
|
|
335
|
+
}
|
|
336
|
+
if (templateRef.customize.tone) {
|
|
337
|
+
builder.tone(templateRef.customize.tone);
|
|
338
|
+
}
|
|
339
|
+
if (templateRef.customize.tools) {
|
|
340
|
+
builder.tools(templateRef.customize.tools);
|
|
341
|
+
}
|
|
342
|
+
if (templateRef.customize.errorHandling) {
|
|
343
|
+
builder.errorHandling(templateRef.customize.errorHandling);
|
|
344
|
+
}
|
|
345
|
+
if (templateRef.customize.characterNormalization) {
|
|
346
|
+
builder.characterNormalization(templateRef.customize.characterNormalization);
|
|
347
|
+
}
|
|
348
|
+
if (templateRef.customize.voiceRules) {
|
|
349
|
+
builder.voiceRules(templateRef.customize.voiceRules);
|
|
350
|
+
}
|
|
351
|
+
if (templateRef.customize.glossary) {
|
|
352
|
+
builder.glossary(templateRef.customize.glossary);
|
|
353
|
+
}
|
|
354
|
+
if (templateRef.customize.systemReminder) {
|
|
355
|
+
builder.custom('System Reminder', templateRef.customize.systemReminder);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// Add additional sections
|
|
359
|
+
if (templateRef.addSections) {
|
|
360
|
+
templateRef.addSections.forEach((section) => {
|
|
361
|
+
if (section.type === 'custom') {
|
|
362
|
+
builder.custom(section.type, section.content, section.priority);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
// Use the method name directly
|
|
366
|
+
const methodName = section.type;
|
|
367
|
+
if (typeof builder[methodName] === 'function') {
|
|
368
|
+
builder[methodName](section.content);
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
builder.custom(section.type, section.content, section.priority);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
// Add glossary
|
|
377
|
+
if (templateRef.glossary) {
|
|
378
|
+
builder.glossary(templateRef.glossary.map((g) => ({
|
|
379
|
+
name: g.name,
|
|
380
|
+
description: g.description,
|
|
381
|
+
synonyms: g.synonyms,
|
|
382
|
+
category: g.category,
|
|
383
|
+
})));
|
|
384
|
+
}
|
|
385
|
+
// Add voice rules
|
|
386
|
+
if (templateRef.voiceRules) {
|
|
387
|
+
builder.voiceRules(templateRef.voiceRules);
|
|
388
|
+
}
|
|
389
|
+
// Set today date flag
|
|
390
|
+
if (templateRef.injectTodayDate !== undefined) {
|
|
391
|
+
builder.injectTodayDate(templateRef.injectTodayDate);
|
|
392
|
+
}
|
|
393
|
+
// Build and return
|
|
394
|
+
const finalTemplate = builder.build();
|
|
395
|
+
const promptBuilder = new (await import('@ariaflowagents/core')).PromptBuilder(finalTemplate);
|
|
396
|
+
return promptBuilder.build();
|
|
397
|
+
}
|
|
398
|
+
// Handle inline template definitions
|
|
399
|
+
if (typeof value === 'object' && value !== null && 'id' in value && 'sections' in value) {
|
|
400
|
+
const inlineTemplate = value;
|
|
401
|
+
const builder = new PromptTemplateBuilder({
|
|
402
|
+
id: inlineTemplate.id,
|
|
403
|
+
name: inlineTemplate.name,
|
|
404
|
+
description: inlineTemplate.description,
|
|
405
|
+
});
|
|
406
|
+
// Add sections
|
|
407
|
+
inlineTemplate.sections.forEach((section) => {
|
|
408
|
+
if (section.type === 'custom') {
|
|
409
|
+
builder.custom(section.type, section.content, section.priority);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
builder[section.type]?.(section.content);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
// Build and return
|
|
416
|
+
const finalTemplate = builder.build();
|
|
417
|
+
const promptBuilder = new (await import('@ariaflowagents/core')).PromptBuilder(finalTemplate);
|
|
418
|
+
return promptBuilder.build();
|
|
419
|
+
}
|
|
310
420
|
return null;
|
|
311
421
|
}
|
|
312
422
|
async function loadFlowFiles(root, sources) {
|
|
@@ -1026,7 +1136,7 @@ export function printLoadSummary(summary) {
|
|
|
1026
1136
|
}
|
|
1027
1137
|
console.log(` • ${summary.durationMs}ms`);
|
|
1028
1138
|
}
|
|
1029
|
-
async function normalizeAgentInput(id, input, baseDir, flows, flowMeta) {
|
|
1139
|
+
async function normalizeAgentInput(id, input, baseDir, flows, flowMeta, toolRegistry) {
|
|
1030
1140
|
const type = (input.type ?? 'llm');
|
|
1031
1141
|
const name = input.name ?? id;
|
|
1032
1142
|
const description = input.description;
|