@ariaflowagents/config 0.4.0 → 0.4.3
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 +500 -33
- package/dist/loader.d.ts +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +279 -11
- package/dist/loader.js.map +1 -1
- package/dist/types.d.ts +89 -3
- package/dist/types.d.ts.map +1 -1
- package/guide/README.md +477 -0
- package/package.json +12 -4
package/dist/loader.js
CHANGED
|
@@ -9,7 +9,10 @@ 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';
|
|
14
|
+
import { createStaticKnowledgeSource, createMarkdownChunker, createLLMRetriever } from '@ariaflowagents/rag';
|
|
15
|
+
import { createCagTool, createCagAnswerTool } from '@ariaflowagents/tools';
|
|
13
16
|
let _warnings = [];
|
|
14
17
|
let _logger = null;
|
|
15
18
|
let _silent = false;
|
|
@@ -212,6 +215,9 @@ async function loadMarkdownAgents(root, sources) {
|
|
|
212
215
|
const name = typeof data.name === 'string' ? data.name : id;
|
|
213
216
|
const modelId = typeof data.model === 'string' ? data.model : undefined;
|
|
214
217
|
const tools = normalizeToolSelection(data.tools);
|
|
218
|
+
const autoRetrieve = typeof data.autoRetrieve === 'object' && data.autoRetrieve
|
|
219
|
+
? data.autoRetrieve
|
|
220
|
+
: undefined;
|
|
215
221
|
const mode = data.mode === 'hybrid'
|
|
216
222
|
? 'hybrid'
|
|
217
223
|
: data.mode === 'strict'
|
|
@@ -230,10 +236,12 @@ async function loadMarkdownAgents(root, sources) {
|
|
|
230
236
|
toolNames: tools,
|
|
231
237
|
maxTurns: typeof data.maxTurns === 'number' ? data.maxTurns : undefined,
|
|
232
238
|
maxSteps: typeof data.maxSteps === 'number' ? data.maxSteps : undefined,
|
|
239
|
+
autoRetrieve,
|
|
233
240
|
};
|
|
234
241
|
if (type === 'triage') {
|
|
235
242
|
const routes = Array.isArray(data.routes) ? data.routes : [];
|
|
236
243
|
const defaultAgent = typeof data.defaultAgent === 'string' ? data.defaultAgent : undefined;
|
|
244
|
+
const triageMode = data.triageMode === 'structured' ? 'structured' : data.triageMode === 'llm' ? 'llm' : undefined;
|
|
237
245
|
const basePrompt = typeof data.systemPrompt === 'string' ? data.systemPrompt : prompt;
|
|
238
246
|
baseAgent.systemPrompt = basePrompt;
|
|
239
247
|
agents[id] = {
|
|
@@ -241,6 +249,7 @@ async function loadMarkdownAgents(root, sources) {
|
|
|
241
249
|
type: 'triage',
|
|
242
250
|
routes,
|
|
243
251
|
defaultAgent,
|
|
252
|
+
triageMode,
|
|
244
253
|
};
|
|
245
254
|
}
|
|
246
255
|
else if (type === 'flow') {
|
|
@@ -307,6 +316,115 @@ async function resolvePrompt(value, baseDir) {
|
|
|
307
316
|
}
|
|
308
317
|
return readFile(resolvedPath, 'utf8');
|
|
309
318
|
}
|
|
319
|
+
// Handle template references
|
|
320
|
+
if (typeof value === 'object' && value !== null && 'template' in value) {
|
|
321
|
+
const templateRef = value;
|
|
322
|
+
const template = getTemplate(templateRef.template);
|
|
323
|
+
if (!template) {
|
|
324
|
+
warn('missing_template', templateRef.template, `Template "${templateRef.template}" not found`);
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
// Create builder from template
|
|
328
|
+
const builder = new PromptTemplateBuilder({
|
|
329
|
+
id: template.id,
|
|
330
|
+
name: template.name,
|
|
331
|
+
description: template.description,
|
|
332
|
+
});
|
|
333
|
+
// Apply customizations
|
|
334
|
+
if (templateRef.customize) {
|
|
335
|
+
if (templateRef.customize.personality) {
|
|
336
|
+
builder.personality(templateRef.customize.personality);
|
|
337
|
+
}
|
|
338
|
+
if (templateRef.customize.goal) {
|
|
339
|
+
builder.goal(templateRef.customize.goal);
|
|
340
|
+
}
|
|
341
|
+
if (templateRef.customize.guardrails) {
|
|
342
|
+
builder.guardrails(templateRef.customize.guardrails);
|
|
343
|
+
}
|
|
344
|
+
if (templateRef.customize.tone) {
|
|
345
|
+
builder.tone(templateRef.customize.tone);
|
|
346
|
+
}
|
|
347
|
+
if (templateRef.customize.tools) {
|
|
348
|
+
builder.tools(templateRef.customize.tools);
|
|
349
|
+
}
|
|
350
|
+
if (templateRef.customize.errorHandling) {
|
|
351
|
+
builder.errorHandling(templateRef.customize.errorHandling);
|
|
352
|
+
}
|
|
353
|
+
if (templateRef.customize.characterNormalization) {
|
|
354
|
+
builder.characterNormalization(templateRef.customize.characterNormalization);
|
|
355
|
+
}
|
|
356
|
+
if (templateRef.customize.voiceRules) {
|
|
357
|
+
builder.voiceRules(templateRef.customize.voiceRules);
|
|
358
|
+
}
|
|
359
|
+
if (templateRef.customize.glossary) {
|
|
360
|
+
builder.glossary(templateRef.customize.glossary);
|
|
361
|
+
}
|
|
362
|
+
if (templateRef.customize.systemReminder) {
|
|
363
|
+
builder.custom('System Reminder', templateRef.customize.systemReminder);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
// Add additional sections
|
|
367
|
+
if (templateRef.addSections) {
|
|
368
|
+
templateRef.addSections.forEach((section) => {
|
|
369
|
+
if (section.type === 'custom') {
|
|
370
|
+
builder.custom(section.type, section.content, section.priority);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
// Use the method name directly
|
|
374
|
+
const methodName = section.type;
|
|
375
|
+
if (typeof builder[methodName] === 'function') {
|
|
376
|
+
builder[methodName](section.content);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
builder.custom(section.type, section.content, section.priority);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
// Add glossary
|
|
385
|
+
if (templateRef.glossary) {
|
|
386
|
+
builder.glossary(templateRef.glossary.map((g) => ({
|
|
387
|
+
name: g.name,
|
|
388
|
+
description: g.description,
|
|
389
|
+
synonyms: g.synonyms,
|
|
390
|
+
category: g.category,
|
|
391
|
+
})));
|
|
392
|
+
}
|
|
393
|
+
// Add voice rules
|
|
394
|
+
if (templateRef.voiceRules) {
|
|
395
|
+
builder.voiceRules(templateRef.voiceRules);
|
|
396
|
+
}
|
|
397
|
+
// Set today date flag
|
|
398
|
+
if (templateRef.injectTodayDate !== undefined) {
|
|
399
|
+
builder.injectTodayDate(templateRef.injectTodayDate);
|
|
400
|
+
}
|
|
401
|
+
// Build and return
|
|
402
|
+
const finalTemplate = builder.build();
|
|
403
|
+
const promptBuilder = new (await import('@ariaflowagents/core')).PromptBuilder(finalTemplate);
|
|
404
|
+
return promptBuilder.build();
|
|
405
|
+
}
|
|
406
|
+
// Handle inline template definitions
|
|
407
|
+
if (typeof value === 'object' && value !== null && 'id' in value && 'sections' in value) {
|
|
408
|
+
const inlineTemplate = value;
|
|
409
|
+
const builder = new PromptTemplateBuilder({
|
|
410
|
+
id: inlineTemplate.id,
|
|
411
|
+
name: inlineTemplate.name,
|
|
412
|
+
description: inlineTemplate.description,
|
|
413
|
+
});
|
|
414
|
+
// Add sections
|
|
415
|
+
inlineTemplate.sections.forEach((section) => {
|
|
416
|
+
if (section.type === 'custom') {
|
|
417
|
+
builder.custom(section.type, section.content, section.priority);
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
builder[section.type]?.(section.content);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
// Build and return
|
|
424
|
+
const finalTemplate = builder.build();
|
|
425
|
+
const promptBuilder = new (await import('@ariaflowagents/core')).PromptBuilder(finalTemplate);
|
|
426
|
+
return promptBuilder.build();
|
|
427
|
+
}
|
|
310
428
|
return null;
|
|
311
429
|
}
|
|
312
430
|
async function loadFlowFiles(root, sources) {
|
|
@@ -548,7 +666,7 @@ function hydrateFlowTools(flow, toolRegistry) {
|
|
|
548
666
|
})),
|
|
549
667
|
};
|
|
550
668
|
}
|
|
551
|
-
async function loadToolConfigEntries(toolsConfig, baseDir, registry, builtinTools, skills, permissions, sources) {
|
|
669
|
+
async function loadToolConfigEntries(toolsConfig, baseDir, registry, builtinTools, skills, permissions, sources, knowledgePacks, aliasMap, modelRegistry, defaultModel) {
|
|
552
670
|
if (!toolsConfig) {
|
|
553
671
|
return;
|
|
554
672
|
}
|
|
@@ -588,7 +706,137 @@ async function loadToolConfigEntries(toolsConfig, baseDir, registry, builtinTool
|
|
|
588
706
|
registry[name] = createSkillTool(allowedSkills);
|
|
589
707
|
continue;
|
|
590
708
|
}
|
|
709
|
+
if (config.type === 'cag') {
|
|
710
|
+
const packName = config.pack;
|
|
711
|
+
if (!packName) {
|
|
712
|
+
throw new Error(`Tool "${name}" is missing pack name`);
|
|
713
|
+
}
|
|
714
|
+
const source = knowledgePacks[packName];
|
|
715
|
+
if (!source) {
|
|
716
|
+
throw new Error(`Tool "${name}" references unknown knowledge pack "${packName}"`);
|
|
717
|
+
}
|
|
718
|
+
const model = resolveModel(config.retrieverModel, aliasMap, modelRegistry, defaultModel);
|
|
719
|
+
if (!model) {
|
|
720
|
+
throw new Error(`Tool "${name}" is missing retrieverModel`);
|
|
721
|
+
}
|
|
722
|
+
const retriever = createLLMRetriever({
|
|
723
|
+
model: model,
|
|
724
|
+
topK: config.topK,
|
|
725
|
+
includeReasons: config.includeReasons,
|
|
726
|
+
candidateMaxChars: config.candidateMaxChars,
|
|
727
|
+
});
|
|
728
|
+
registry[name] = createCagTool({
|
|
729
|
+
sources: [source],
|
|
730
|
+
retriever,
|
|
731
|
+
topK: config.topK,
|
|
732
|
+
});
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
if (config.type === 'cag-answer') {
|
|
736
|
+
const model = resolveModel(config.generatorModel, aliasMap, modelRegistry, defaultModel);
|
|
737
|
+
if (!model) {
|
|
738
|
+
throw new Error(`Tool "${name}" is missing generatorModel`);
|
|
739
|
+
}
|
|
740
|
+
registry[name] = createCagAnswerTool({
|
|
741
|
+
generatorModel: model,
|
|
742
|
+
systemPrompt: config.systemPrompt,
|
|
743
|
+
});
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
function normalizeAutoRetrieveResult(result) {
|
|
749
|
+
if (!result)
|
|
750
|
+
return null;
|
|
751
|
+
if (typeof result === 'string') {
|
|
752
|
+
return { text: result };
|
|
753
|
+
}
|
|
754
|
+
if (typeof result !== 'object')
|
|
755
|
+
return null;
|
|
756
|
+
const record = result;
|
|
757
|
+
if (typeof record.text === 'string') {
|
|
758
|
+
return {
|
|
759
|
+
text: record.text,
|
|
760
|
+
chunks: Array.isArray(record.chunks) ? record.chunks : undefined,
|
|
761
|
+
metadata: typeof record.metadata === 'object' && record.metadata ? record.metadata : undefined,
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
if (Array.isArray(record.chunks)) {
|
|
765
|
+
const text = record.chunks
|
|
766
|
+
.map(chunk => {
|
|
767
|
+
if (!chunk || typeof chunk !== 'object')
|
|
768
|
+
return '';
|
|
769
|
+
const textValue = chunk.text;
|
|
770
|
+
return typeof textValue === 'string' ? textValue : '';
|
|
771
|
+
})
|
|
772
|
+
.filter(Boolean)
|
|
773
|
+
.join('\n\n');
|
|
774
|
+
if (text.trim().length > 0) {
|
|
775
|
+
return { text, chunks: record.chunks };
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
function buildAutoRetrieveProvider(autoRetrieve, toolRegistry) {
|
|
781
|
+
if (!autoRetrieve)
|
|
782
|
+
return undefined;
|
|
783
|
+
const tool = toolRegistry[autoRetrieve.tool];
|
|
784
|
+
if (!tool) {
|
|
785
|
+
throw new Error(`Auto-retrieve tool "${autoRetrieve.tool}" not found`);
|
|
786
|
+
}
|
|
787
|
+
return {
|
|
788
|
+
toolName: autoRetrieve.tool,
|
|
789
|
+
label: autoRetrieve.label,
|
|
790
|
+
message: autoRetrieve.message,
|
|
791
|
+
run: async ({ input }) => {
|
|
792
|
+
const args = { query: input };
|
|
793
|
+
if (autoRetrieve.topK !== undefined) {
|
|
794
|
+
args.topK = autoRetrieve.topK;
|
|
795
|
+
}
|
|
796
|
+
if (autoRetrieve.hint !== undefined) {
|
|
797
|
+
args.hint = autoRetrieve.hint;
|
|
798
|
+
}
|
|
799
|
+
const result = await tool.execute(args);
|
|
800
|
+
return normalizeAutoRetrieveResult(result);
|
|
801
|
+
},
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
async function loadKnowledgePacks(layers, inlineLayer) {
|
|
805
|
+
const packs = {};
|
|
806
|
+
const ingest = async (packId, input, baseDir) => {
|
|
807
|
+
const sourcePath = path.isAbsolute(input.source)
|
|
808
|
+
? input.source
|
|
809
|
+
: path.resolve(baseDir, input.source);
|
|
810
|
+
const content = await readFile(sourcePath, 'utf8');
|
|
811
|
+
const chunker = createMarkdownChunker({
|
|
812
|
+
maxChars: input.chunk?.maxChars,
|
|
813
|
+
overlapChars: input.chunk?.overlapChars,
|
|
814
|
+
});
|
|
815
|
+
const source = createStaticKnowledgeSource({
|
|
816
|
+
id: packId,
|
|
817
|
+
name: input.name ?? packId,
|
|
818
|
+
description: input.description,
|
|
819
|
+
content,
|
|
820
|
+
chunker,
|
|
821
|
+
chunkOptions: {
|
|
822
|
+
maxChars: input.chunk?.maxChars,
|
|
823
|
+
overlapChars: input.chunk?.overlapChars,
|
|
824
|
+
},
|
|
825
|
+
});
|
|
826
|
+
packs[packId] = source;
|
|
827
|
+
};
|
|
828
|
+
for (const layer of layers) {
|
|
829
|
+
const configs = layer.config.knowledge?.packs ?? {};
|
|
830
|
+
for (const [packId, input] of Object.entries(configs)) {
|
|
831
|
+
await ingest(packId, input, layer.dir);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (inlineLayer?.config.knowledge?.packs) {
|
|
835
|
+
for (const [packId, input] of Object.entries(inlineLayer.config.knowledge.packs)) {
|
|
836
|
+
await ingest(packId, input, inlineLayer.dir);
|
|
837
|
+
}
|
|
591
838
|
}
|
|
839
|
+
return packs;
|
|
592
840
|
}
|
|
593
841
|
export async function loadAriaflowConfig(options = {}) {
|
|
594
842
|
const startTime = Date.now();
|
|
@@ -633,6 +881,8 @@ export async function loadAriaflowConfig(options = {}) {
|
|
|
633
881
|
if (inlineLayer) {
|
|
634
882
|
mergedConfig = deepMerge(mergedConfig, inlineLayer.config);
|
|
635
883
|
}
|
|
884
|
+
const aliasMap = mergedConfig.models ?? {};
|
|
885
|
+
const defaultModel = resolveModel(mergedConfig.runtime?.defaultModel, aliasMap, options.modelRegistry, options.defaultModel);
|
|
636
886
|
const roots = [];
|
|
637
887
|
for (const layer of baseLayers) {
|
|
638
888
|
const root = path.join(layer.dir, '.ariaflow');
|
|
@@ -646,6 +896,7 @@ export async function loadAriaflowConfig(options = {}) {
|
|
|
646
896
|
roots.push(dir);
|
|
647
897
|
}
|
|
648
898
|
}
|
|
899
|
+
const knowledgePacks = await loadKnowledgePacks(baseLayers, inlineLayer);
|
|
649
900
|
const flows = {};
|
|
650
901
|
const flowMeta = {};
|
|
651
902
|
for (const layer of baseLayers) {
|
|
@@ -707,20 +958,19 @@ export async function loadAriaflowConfig(options = {}) {
|
|
|
707
958
|
}
|
|
708
959
|
const mergedPermissions = mergedConfig.permissions;
|
|
709
960
|
for (const layer of baseLayers) {
|
|
710
|
-
await loadToolConfigEntries(layer.config.tools, layer.dir, toolsRegistry, options.builtinTools, skills, mergedPermissions, sources);
|
|
961
|
+
await loadToolConfigEntries(layer.config.tools, layer.dir, toolsRegistry, options.builtinTools, skills, mergedPermissions, sources, knowledgePacks, aliasMap, options.modelRegistry, defaultModel);
|
|
711
962
|
}
|
|
712
963
|
if (inlineLayer) {
|
|
713
|
-
await loadToolConfigEntries(inlineLayer.config.tools, inlineLayer.dir, toolsRegistry, options.builtinTools, skills, mergedPermissions, sources);
|
|
964
|
+
await loadToolConfigEntries(inlineLayer.config.tools, inlineLayer.dir, toolsRegistry, options.builtinTools, skills, mergedPermissions, sources, knowledgePacks, aliasMap, options.modelRegistry, defaultModel);
|
|
714
965
|
}
|
|
715
966
|
const agents = [];
|
|
716
|
-
const aliasMap = mergedConfig.models ?? {};
|
|
717
|
-
const defaultModel = resolveModel(mergedConfig.runtime?.defaultModel, aliasMap, options.modelRegistry, options.defaultModel);
|
|
718
967
|
for (const agent of Object.values(agentDefs)) {
|
|
719
968
|
const model = resolveModel(agent.modelId, aliasMap, options.modelRegistry, defaultModel);
|
|
720
969
|
if (!model) {
|
|
721
970
|
throw new Error(`Agent "${agent.id}" is missing a model (resolved from config)`);
|
|
722
971
|
}
|
|
723
972
|
const tools = buildToolSet(toolsRegistry, agent.toolNames);
|
|
973
|
+
const autoRetrieve = buildAutoRetrieveProvider(agent.autoRetrieve, toolsRegistry);
|
|
724
974
|
if (agent.type === 'triage') {
|
|
725
975
|
agents.push({
|
|
726
976
|
id: agent.id,
|
|
@@ -729,6 +979,7 @@ export async function loadAriaflowConfig(options = {}) {
|
|
|
729
979
|
systemPrompt: triagePromptTemplate(agent.systemPrompt, agent.routes, agent.defaultAgent),
|
|
730
980
|
model: model,
|
|
731
981
|
tools: tools,
|
|
982
|
+
autoRetrieve,
|
|
732
983
|
maxTurns: agent.maxTurns,
|
|
733
984
|
maxSteps: agent.maxSteps,
|
|
734
985
|
type: 'triage',
|
|
@@ -737,6 +988,7 @@ export async function loadAriaflowConfig(options = {}) {
|
|
|
737
988
|
description: route.description,
|
|
738
989
|
})),
|
|
739
990
|
defaultAgent: agent.defaultAgent,
|
|
991
|
+
triageMode: agent.triageMode,
|
|
740
992
|
});
|
|
741
993
|
continue;
|
|
742
994
|
}
|
|
@@ -749,6 +1001,7 @@ export async function loadAriaflowConfig(options = {}) {
|
|
|
749
1001
|
systemPrompt: agent.systemPrompt,
|
|
750
1002
|
model: model,
|
|
751
1003
|
tools: tools,
|
|
1004
|
+
autoRetrieve,
|
|
752
1005
|
maxTurns: agent.maxTurns,
|
|
753
1006
|
maxSteps: agent.maxSteps,
|
|
754
1007
|
type: 'flow',
|
|
@@ -765,6 +1018,7 @@ export async function loadAriaflowConfig(options = {}) {
|
|
|
765
1018
|
systemPrompt: agent.systemPrompt,
|
|
766
1019
|
model: model,
|
|
767
1020
|
tools: tools,
|
|
1021
|
+
autoRetrieve,
|
|
768
1022
|
maxTurns: agent.maxTurns,
|
|
769
1023
|
maxSteps: agent.maxSteps,
|
|
770
1024
|
type: 'llm',
|
|
@@ -785,6 +1039,8 @@ export async function loadAriaflowConfig(options = {}) {
|
|
|
785
1039
|
maxSteps: runtimeConfig?.maxSteps,
|
|
786
1040
|
maxTurns: runtimeConfig?.maxTurns,
|
|
787
1041
|
maxHandoffs: runtimeConfig?.maxHandoffs,
|
|
1042
|
+
alwaysRouteThroughTriage: runtimeConfig?.alwaysRouteThroughTriage,
|
|
1043
|
+
triageAgentId: runtimeConfig?.triageAgent,
|
|
788
1044
|
},
|
|
789
1045
|
agents,
|
|
790
1046
|
flows,
|
|
@@ -835,6 +1091,8 @@ export async function loadAriaflowConfigWithResult(options = {}) {
|
|
|
835
1091
|
if (inlineLayer) {
|
|
836
1092
|
mergedConfig = deepMerge(mergedConfig, inlineLayer.config);
|
|
837
1093
|
}
|
|
1094
|
+
const aliasMap = mergedConfig.models ?? {};
|
|
1095
|
+
const defaultModel = resolveModel(mergedConfig.runtime?.defaultModel, aliasMap, options.modelRegistry, options.defaultModel);
|
|
838
1096
|
const roots = [];
|
|
839
1097
|
for (const layer of baseLayers) {
|
|
840
1098
|
const root = path.join(layer.dir, '.ariaflow');
|
|
@@ -848,6 +1106,7 @@ export async function loadAriaflowConfigWithResult(options = {}) {
|
|
|
848
1106
|
roots.push(dir);
|
|
849
1107
|
}
|
|
850
1108
|
}
|
|
1109
|
+
const knowledgePacks = await loadKnowledgePacks(baseLayers, inlineLayer);
|
|
851
1110
|
const flows = {};
|
|
852
1111
|
const flowMeta = {};
|
|
853
1112
|
for (const layer of baseLayers) {
|
|
@@ -908,20 +1167,19 @@ export async function loadAriaflowConfigWithResult(options = {}) {
|
|
|
908
1167
|
}
|
|
909
1168
|
const mergedPermissions = mergedConfig.permissions;
|
|
910
1169
|
for (const layer of baseLayers) {
|
|
911
|
-
await loadToolConfigEntries(layer.config.tools, layer.dir, toolsRegistry, options.builtinTools, skills, mergedPermissions, sources);
|
|
1170
|
+
await loadToolConfigEntries(layer.config.tools, layer.dir, toolsRegistry, options.builtinTools, skills, mergedPermissions, sources, knowledgePacks, aliasMap, options.modelRegistry, defaultModel);
|
|
912
1171
|
}
|
|
913
1172
|
if (inlineLayer) {
|
|
914
|
-
await loadToolConfigEntries(inlineLayer.config.tools, inlineLayer.dir, toolsRegistry, options.builtinTools, skills, mergedPermissions, sources);
|
|
1173
|
+
await loadToolConfigEntries(inlineLayer.config.tools, inlineLayer.dir, toolsRegistry, options.builtinTools, skills, mergedPermissions, sources, knowledgePacks, aliasMap, options.modelRegistry, defaultModel);
|
|
915
1174
|
}
|
|
916
1175
|
const agents = [];
|
|
917
|
-
const aliasMap = mergedConfig.models ?? {};
|
|
918
|
-
const defaultModel = resolveModel(mergedConfig.runtime?.defaultModel, aliasMap, options.modelRegistry, options.defaultModel);
|
|
919
1176
|
for (const agent of Object.values(agentDefs)) {
|
|
920
1177
|
const model = resolveModel(agent.modelId, aliasMap, options.modelRegistry, defaultModel);
|
|
921
1178
|
if (!model) {
|
|
922
1179
|
throw new Error(`Agent "${agent.id}" is missing a model (resolved from config)`);
|
|
923
1180
|
}
|
|
924
1181
|
const tools = buildToolSet(toolsRegistry, agent.toolNames);
|
|
1182
|
+
const autoRetrieve = buildAutoRetrieveProvider(agent.autoRetrieve, toolsRegistry);
|
|
925
1183
|
if (agent.type === 'triage') {
|
|
926
1184
|
agents.push({
|
|
927
1185
|
id: agent.id,
|
|
@@ -930,6 +1188,7 @@ export async function loadAriaflowConfigWithResult(options = {}) {
|
|
|
930
1188
|
systemPrompt: triagePromptTemplate(agent.systemPrompt, agent.routes, agent.defaultAgent),
|
|
931
1189
|
model: model,
|
|
932
1190
|
tools: tools,
|
|
1191
|
+
autoRetrieve,
|
|
933
1192
|
maxTurns: agent.maxTurns,
|
|
934
1193
|
maxSteps: agent.maxSteps,
|
|
935
1194
|
type: 'triage',
|
|
@@ -938,6 +1197,7 @@ export async function loadAriaflowConfigWithResult(options = {}) {
|
|
|
938
1197
|
description: route.description,
|
|
939
1198
|
})),
|
|
940
1199
|
defaultAgent: agent.defaultAgent,
|
|
1200
|
+
triageMode: agent.triageMode,
|
|
941
1201
|
});
|
|
942
1202
|
continue;
|
|
943
1203
|
}
|
|
@@ -950,6 +1210,7 @@ export async function loadAriaflowConfigWithResult(options = {}) {
|
|
|
950
1210
|
systemPrompt: agent.systemPrompt,
|
|
951
1211
|
model: model,
|
|
952
1212
|
tools: tools,
|
|
1213
|
+
autoRetrieve,
|
|
953
1214
|
maxTurns: agent.maxTurns,
|
|
954
1215
|
maxSteps: agent.maxSteps,
|
|
955
1216
|
type: 'flow',
|
|
@@ -966,6 +1227,7 @@ export async function loadAriaflowConfigWithResult(options = {}) {
|
|
|
966
1227
|
systemPrompt: agent.systemPrompt,
|
|
967
1228
|
model: model,
|
|
968
1229
|
tools: tools,
|
|
1230
|
+
autoRetrieve,
|
|
969
1231
|
maxTurns: agent.maxTurns,
|
|
970
1232
|
maxSteps: agent.maxSteps,
|
|
971
1233
|
type: 'llm',
|
|
@@ -993,6 +1255,8 @@ export async function loadAriaflowConfigWithResult(options = {}) {
|
|
|
993
1255
|
maxSteps: runtimeConfig?.maxSteps,
|
|
994
1256
|
maxTurns: runtimeConfig?.maxTurns,
|
|
995
1257
|
maxHandoffs: runtimeConfig?.maxHandoffs,
|
|
1258
|
+
alwaysRouteThroughTriage: runtimeConfig?.alwaysRouteThroughTriage,
|
|
1259
|
+
triageAgentId: runtimeConfig?.triageAgent,
|
|
996
1260
|
},
|
|
997
1261
|
agents,
|
|
998
1262
|
flows,
|
|
@@ -1026,7 +1290,7 @@ export function printLoadSummary(summary) {
|
|
|
1026
1290
|
}
|
|
1027
1291
|
console.log(` • ${summary.durationMs}ms`);
|
|
1028
1292
|
}
|
|
1029
|
-
async function normalizeAgentInput(id, input, baseDir, flows, flowMeta) {
|
|
1293
|
+
async function normalizeAgentInput(id, input, baseDir, flows, flowMeta, toolRegistry) {
|
|
1030
1294
|
const type = (input.type ?? 'llm');
|
|
1031
1295
|
const name = input.name ?? id;
|
|
1032
1296
|
const description = input.description;
|
|
@@ -1044,6 +1308,7 @@ async function normalizeAgentInput(id, input, baseDir, flows, flowMeta) {
|
|
|
1044
1308
|
toolNames: normalizeToolSelection(input.tools),
|
|
1045
1309
|
maxTurns: input.maxTurns,
|
|
1046
1310
|
maxSteps: input.maxSteps,
|
|
1311
|
+
autoRetrieve: input.autoRetrieve,
|
|
1047
1312
|
};
|
|
1048
1313
|
if (type === 'triage') {
|
|
1049
1314
|
const triage = input;
|
|
@@ -1054,6 +1319,7 @@ async function normalizeAgentInput(id, input, baseDir, flows, flowMeta) {
|
|
|
1054
1319
|
type: 'triage',
|
|
1055
1320
|
routes,
|
|
1056
1321
|
defaultAgent: triage.defaultAgent,
|
|
1322
|
+
triageMode: triage.triageMode,
|
|
1057
1323
|
systemPrompt: basePrompt ?? promptValue ?? `[Missing prompt for agent: ${id}]`,
|
|
1058
1324
|
};
|
|
1059
1325
|
}
|
|
@@ -1103,6 +1369,8 @@ export function createRuntimeFromConfig(config, overrides = {}) {
|
|
|
1103
1369
|
defaultModel: config.runtime.defaultModel,
|
|
1104
1370
|
maxSteps: config.runtime.maxSteps,
|
|
1105
1371
|
maxHandoffs: config.runtime.maxHandoffs,
|
|
1372
|
+
alwaysRouteThroughTriage: config.runtime.alwaysRouteThroughTriage,
|
|
1373
|
+
triageAgentId: config.runtime.triageAgentId,
|
|
1106
1374
|
...overrides,
|
|
1107
1375
|
});
|
|
1108
1376
|
}
|