@ariaflowagents/core 0.7.1 → 0.9.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/README.md +90 -1
- package/dist/agents/Agent.d.ts +188 -9
- package/dist/agents/Agent.d.ts.map +1 -1
- package/dist/agents/Agent.js +246 -24
- package/dist/agents/Agent.js.map +1 -1
- package/dist/agents/CompositeAgent.d.ts +4 -3
- package/dist/agents/CompositeAgent.d.ts.map +1 -1
- package/dist/agents/CompositeAgent.js +19 -9
- package/dist/agents/CompositeAgent.js.map +1 -1
- package/dist/agents/FlowAgent.d.ts +3 -2
- package/dist/agents/FlowAgent.d.ts.map +1 -1
- package/dist/agents/FlowAgent.js +16 -6
- package/dist/agents/FlowAgent.js.map +1 -1
- package/dist/agents/TriageAgent.d.ts +8 -2
- package/dist/agents/TriageAgent.d.ts.map +1 -1
- package/dist/agents/TriageAgent.js +39 -6
- package/dist/agents/TriageAgent.js.map +1 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +0 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/capabilities/AutoRetrieveCapability.d.ts +30 -0
- package/dist/capabilities/AutoRetrieveCapability.d.ts.map +1 -0
- package/dist/capabilities/AutoRetrieveCapability.js +36 -0
- package/dist/capabilities/AutoRetrieveCapability.js.map +1 -0
- package/dist/capabilities/ExtractionCapability.d.ts +25 -0
- package/dist/capabilities/ExtractionCapability.d.ts.map +1 -0
- package/dist/capabilities/ExtractionCapability.js +74 -0
- package/dist/capabilities/ExtractionCapability.js.map +1 -0
- package/dist/capabilities/FlowCapability.d.ts +81 -0
- package/dist/capabilities/FlowCapability.d.ts.map +1 -0
- package/dist/capabilities/FlowCapability.js +482 -0
- package/dist/capabilities/FlowCapability.js.map +1 -0
- package/dist/capabilities/GuardrailCapability.d.ts +30 -0
- package/dist/capabilities/GuardrailCapability.d.ts.map +1 -0
- package/dist/capabilities/GuardrailCapability.js +38 -0
- package/dist/capabilities/GuardrailCapability.js.map +1 -0
- package/dist/capabilities/HandoffCapability.d.ts +19 -0
- package/dist/capabilities/HandoffCapability.d.ts.map +1 -0
- package/dist/capabilities/HandoffCapability.js +58 -0
- package/dist/capabilities/HandoffCapability.js.map +1 -0
- package/dist/capabilities/LivePromptAssembler.d.ts +108 -0
- package/dist/capabilities/LivePromptAssembler.d.ts.map +1 -0
- package/dist/capabilities/LivePromptAssembler.js +157 -0
- package/dist/capabilities/LivePromptAssembler.js.map +1 -0
- package/dist/capabilities/TriageCapability.d.ts +16 -0
- package/dist/capabilities/TriageCapability.d.ts.map +1 -0
- package/dist/capabilities/TriageCapability.js +61 -0
- package/dist/capabilities/TriageCapability.js.map +1 -0
- package/dist/capabilities/adapters/ai-sdk.d.ts +14 -0
- package/dist/capabilities/adapters/ai-sdk.d.ts.map +1 -0
- package/dist/capabilities/adapters/ai-sdk.js +29 -0
- package/dist/capabilities/adapters/ai-sdk.js.map +1 -0
- package/dist/capabilities/adapters/gemini.d.ts +15 -0
- package/dist/capabilities/adapters/gemini.d.ts.map +1 -0
- package/dist/capabilities/adapters/gemini.js +40 -0
- package/dist/capabilities/adapters/gemini.js.map +1 -0
- package/dist/capabilities/index.d.ts +154 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +128 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/eval/EvalRunner.d.ts +12 -0
- package/dist/eval/EvalRunner.d.ts.map +1 -0
- package/dist/eval/EvalRunner.js +64 -0
- package/dist/eval/EvalRunner.js.map +1 -0
- package/dist/eval/scoring.d.ts +15 -0
- package/dist/eval/scoring.d.ts.map +1 -0
- package/dist/eval/scoring.js +152 -0
- package/dist/eval/scoring.js.map +1 -0
- package/dist/eval/types.d.ts +59 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +2 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/flows/FlowGraph.d.ts +3 -1
- package/dist/flows/FlowGraph.d.ts.map +1 -1
- package/dist/flows/FlowGraph.js +5 -0
- package/dist/flows/FlowGraph.js.map +1 -1
- package/dist/flows/FlowManager.d.ts +68 -1
- package/dist/flows/FlowManager.d.ts.map +1 -1
- package/dist/flows/FlowManager.js +499 -36
- package/dist/flows/FlowManager.js.map +1 -1
- package/dist/flows/extraction.d.ts +16 -1
- package/dist/flows/extraction.d.ts.map +1 -1
- package/dist/flows/extraction.js +34 -0
- package/dist/flows/extraction.js.map +1 -1
- package/dist/flows/index.d.ts +2 -0
- package/dist/flows/index.d.ts.map +1 -1
- package/dist/flows/index.js +1 -0
- package/dist/flows/index.js.map +1 -1
- package/dist/flows/validation.d.ts +1 -1
- package/dist/flows/validation.d.ts.map +1 -1
- package/dist/flows/validation.js +13 -1
- package/dist/flows/validation.js.map +1 -1
- package/dist/foundation/AgentDefinition.d.ts +18 -0
- package/dist/foundation/AgentDefinition.d.ts.map +1 -0
- package/dist/foundation/AgentDefinition.js +2 -0
- package/dist/foundation/AgentDefinition.js.map +1 -0
- package/dist/foundation/AgentStateController.d.ts +26 -0
- package/dist/foundation/AgentStateController.d.ts.map +1 -0
- package/dist/foundation/AgentStateController.js +2 -0
- package/dist/foundation/AgentStateController.js.map +1 -0
- package/dist/foundation/ConversationEventLog.d.ts +72 -0
- package/dist/foundation/ConversationEventLog.d.ts.map +1 -0
- package/dist/foundation/ConversationEventLog.js +2 -0
- package/dist/foundation/ConversationEventLog.js.map +1 -0
- package/dist/foundation/ConversationState.d.ts +31 -0
- package/dist/foundation/ConversationState.d.ts.map +1 -0
- package/dist/foundation/ConversationState.js +2 -0
- package/dist/foundation/ConversationState.js.map +1 -0
- package/dist/foundation/DefaultAgentStateController.d.ts +24 -0
- package/dist/foundation/DefaultAgentStateController.d.ts.map +1 -0
- package/dist/foundation/DefaultAgentStateController.js +49 -0
- package/dist/foundation/DefaultAgentStateController.js.map +1 -0
- package/dist/foundation/DefaultConversationEventLog.d.ts +28 -0
- package/dist/foundation/DefaultConversationEventLog.d.ts.map +1 -0
- package/dist/foundation/DefaultConversationEventLog.js +195 -0
- package/dist/foundation/DefaultConversationEventLog.js.map +1 -0
- package/dist/foundation/DefaultConversationState.d.ts +34 -0
- package/dist/foundation/DefaultConversationState.d.ts.map +1 -0
- package/dist/foundation/DefaultConversationState.js +100 -0
- package/dist/foundation/DefaultConversationState.js.map +1 -0
- package/dist/foundation/DefaultToolExecutor.d.ts +58 -0
- package/dist/foundation/DefaultToolExecutor.d.ts.map +1 -0
- package/dist/foundation/DefaultToolExecutor.js +128 -0
- package/dist/foundation/DefaultToolExecutor.js.map +1 -0
- package/dist/foundation/ToolExecutor.d.ts +44 -0
- package/dist/foundation/ToolExecutor.d.ts.map +1 -0
- package/dist/foundation/ToolExecutor.js +2 -0
- package/dist/foundation/ToolExecutor.js.map +1 -0
- package/dist/foundation/createFoundation.d.ts +33 -0
- package/dist/foundation/createFoundation.d.ts.map +1 -0
- package/dist/foundation/createFoundation.js +34 -0
- package/dist/foundation/createFoundation.js.map +1 -0
- package/dist/foundation/index.d.ts +15 -0
- package/dist/foundation/index.d.ts.map +1 -0
- package/dist/foundation/index.js +8 -0
- package/dist/foundation/index.js.map +1 -0
- package/dist/hooks/HookRunner.d.ts +5 -1
- package/dist/hooks/HookRunner.d.ts.map +1 -1
- package/dist/hooks/HookRunner.js +7 -0
- package/dist/hooks/HookRunner.js.map +1 -1
- package/dist/hooks/builtin/metrics.d.ts.map +1 -1
- package/dist/hooks/builtin/metrics.js +12 -0
- package/dist/hooks/builtin/metrics.js.map +1 -1
- package/dist/hooks/builtin/observability.d.ts +21 -0
- package/dist/hooks/builtin/observability.d.ts.map +1 -0
- package/dist/hooks/builtin/observability.js +535 -0
- package/dist/hooks/builtin/observability.js.map +1 -0
- package/dist/index.d.ts +24 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/memory/MemoryService.d.ts +40 -0
- package/dist/memory/MemoryService.d.ts.map +1 -0
- package/dist/memory/MemoryService.js +2 -0
- package/dist/memory/MemoryService.js.map +1 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +3 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/preloadMemory.d.ts +17 -0
- package/dist/memory/preloadMemory.d.ts.map +1 -0
- package/dist/memory/preloadMemory.js +62 -0
- package/dist/memory/preloadMemory.js.map +1 -0
- package/dist/memory/stores/InMemoryMemoryService.d.ts +20 -0
- package/dist/memory/stores/InMemoryMemoryService.d.ts.map +1 -0
- package/dist/memory/stores/InMemoryMemoryService.js +92 -0
- package/dist/memory/stores/InMemoryMemoryService.js.map +1 -0
- package/dist/memory/types.d.ts +49 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +8 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/orchestration/DefaultOrchestrationAuthority.d.ts +91 -0
- package/dist/orchestration/DefaultOrchestrationAuthority.d.ts.map +1 -0
- package/dist/orchestration/DefaultOrchestrationAuthority.js +786 -0
- package/dist/orchestration/DefaultOrchestrationAuthority.js.map +1 -0
- package/dist/orchestration/OrchestrationAuthority.d.ts +119 -0
- package/dist/orchestration/OrchestrationAuthority.d.ts.map +1 -0
- package/dist/orchestration/OrchestrationAuthority.js +2 -0
- package/dist/orchestration/OrchestrationAuthority.js.map +1 -0
- package/dist/orchestration/RealtimeExtractionRunner.d.ts +25 -0
- package/dist/orchestration/RealtimeExtractionRunner.d.ts.map +1 -0
- package/dist/orchestration/RealtimeExtractionRunner.js +62 -0
- package/dist/orchestration/RealtimeExtractionRunner.js.map +1 -0
- package/dist/orchestration/index.d.ts +5 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +4 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/types.d.ts +134 -0
- package/dist/orchestration/types.d.ts.map +1 -0
- package/dist/orchestration/types.js +2 -0
- package/dist/orchestration/types.js.map +1 -0
- package/dist/prompts/AgentPrompt.d.ts +110 -0
- package/dist/prompts/AgentPrompt.d.ts.map +1 -0
- package/dist/prompts/AgentPrompt.js +373 -0
- package/dist/prompts/AgentPrompt.js.map +1 -0
- package/dist/prompts/PromptAssembly.d.ts +119 -0
- package/dist/prompts/PromptAssembly.d.ts.map +1 -0
- package/dist/prompts/PromptAssembly.js +150 -0
- package/dist/prompts/PromptAssembly.js.map +1 -0
- package/dist/prompts/PromptBuilder.d.ts +22 -3
- package/dist/prompts/PromptBuilder.d.ts.map +1 -1
- package/dist/prompts/PromptBuilder.js +242 -13
- package/dist/prompts/PromptBuilder.js.map +1 -1
- package/dist/prompts/PromptRenderer.d.ts +43 -0
- package/dist/prompts/PromptRenderer.d.ts.map +1 -0
- package/dist/prompts/PromptRenderer.js +114 -0
- package/dist/prompts/PromptRenderer.js.map +1 -0
- package/dist/prompts/brandVoice.d.ts +10 -0
- package/dist/prompts/brandVoice.d.ts.map +1 -0
- package/dist/prompts/brandVoice.js +87 -0
- package/dist/prompts/brandVoice.js.map +1 -0
- package/dist/prompts/index.d.ts +11 -4
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +7 -2
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/security.d.ts +5 -0
- package/dist/prompts/security.d.ts.map +1 -0
- package/dist/prompts/security.js +52 -0
- package/dist/prompts/security.js.map +1 -0
- package/dist/prompts/types.d.ts +65 -1
- package/dist/prompts/types.d.ts.map +1 -1
- package/dist/prompts/types.js +26 -0
- package/dist/prompts/types.js.map +1 -1
- package/dist/realtime/RealtimeAudioClient.d.ts +105 -0
- package/dist/realtime/RealtimeAudioClient.d.ts.map +1 -0
- package/dist/realtime/RealtimeAudioClient.js +15 -0
- package/dist/realtime/RealtimeAudioClient.js.map +1 -0
- package/dist/realtime/RealtimeRuntime.d.ts +136 -0
- package/dist/realtime/RealtimeRuntime.d.ts.map +1 -0
- package/dist/realtime/RealtimeRuntime.js +270 -0
- package/dist/realtime/RealtimeRuntime.js.map +1 -0
- package/dist/realtime/index.d.ts +4 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +2 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/runtime/ContextBudget.d.ts +57 -0
- package/dist/runtime/ContextBudget.d.ts.map +1 -0
- package/dist/runtime/ContextBudget.js +103 -0
- package/dist/runtime/ContextBudget.js.map +1 -0
- package/dist/runtime/ContextManager.d.ts +8 -5
- package/dist/runtime/ContextManager.d.ts.map +1 -1
- package/dist/runtime/ContextManager.js +47 -14
- package/dist/runtime/ContextManager.js.map +1 -1
- package/dist/runtime/ExtractionEngine.d.ts +2 -1
- package/dist/runtime/ExtractionEngine.d.ts.map +1 -1
- package/dist/runtime/ExtractionEngine.js +11 -0
- package/dist/runtime/ExtractionEngine.js.map +1 -1
- package/dist/runtime/FlowExecutor.d.ts +22 -15
- package/dist/runtime/FlowExecutor.d.ts.map +1 -1
- package/dist/runtime/FlowExecutor.js +102 -149
- package/dist/runtime/FlowExecutor.js.map +1 -1
- package/dist/runtime/Runtime.d.ts +53 -78
- package/dist/runtime/Runtime.d.ts.map +1 -1
- package/dist/runtime/Runtime.js +272 -1406
- package/dist/runtime/Runtime.js.map +1 -1
- package/dist/runtime/SessionCache.d.ts +16 -0
- package/dist/runtime/SessionCache.d.ts.map +1 -0
- package/dist/runtime/SessionCache.js +49 -0
- package/dist/runtime/SessionCache.js.map +1 -0
- package/dist/runtime/SessionMutex.d.ts +37 -0
- package/dist/runtime/SessionMutex.d.ts.map +1 -0
- package/dist/runtime/SessionMutex.js +59 -0
- package/dist/runtime/SessionMutex.js.map +1 -0
- package/dist/runtime/StreamEmitter.d.ts +34 -0
- package/dist/runtime/StreamEmitter.d.ts.map +1 -0
- package/dist/runtime/StreamEmitter.js +91 -0
- package/dist/runtime/StreamEmitter.js.map +1 -0
- package/dist/runtime/handoffFilters.d.ts +60 -0
- package/dist/runtime/handoffFilters.d.ts.map +1 -0
- package/dist/runtime/handoffFilters.js +95 -0
- package/dist/runtime/handoffFilters.js.map +1 -0
- package/dist/runtime/pipeline/AgentExecuteStage.d.ts +22 -0
- package/dist/runtime/pipeline/AgentExecuteStage.d.ts.map +1 -0
- package/dist/runtime/pipeline/AgentExecuteStage.js +958 -0
- package/dist/runtime/pipeline/AgentExecuteStage.js.map +1 -0
- package/dist/runtime/pipeline/ContextAssembleStage.d.ts +26 -0
- package/dist/runtime/pipeline/ContextAssembleStage.d.ts.map +1 -0
- package/dist/runtime/pipeline/ContextAssembleStage.js +253 -0
- package/dist/runtime/pipeline/ContextAssembleStage.js.map +1 -0
- package/dist/runtime/pipeline/ContextGatherStage.d.ts +21 -0
- package/dist/runtime/pipeline/ContextGatherStage.d.ts.map +1 -0
- package/dist/runtime/pipeline/ContextGatherStage.js +161 -0
- package/dist/runtime/pipeline/ContextGatherStage.js.map +1 -0
- package/dist/runtime/pipeline/IntakeStage.d.ts +25 -0
- package/dist/runtime/pipeline/IntakeStage.d.ts.map +1 -0
- package/dist/runtime/pipeline/IntakeStage.js +126 -0
- package/dist/runtime/pipeline/IntakeStage.js.map +1 -0
- package/dist/runtime/pipeline/PostStreamStage.d.ts +26 -0
- package/dist/runtime/pipeline/PostStreamStage.d.ts.map +1 -0
- package/dist/runtime/pipeline/PostStreamStage.js +129 -0
- package/dist/runtime/pipeline/PostStreamStage.js.map +1 -0
- package/dist/runtime/pipeline/TurnPipeline.d.ts +54 -0
- package/dist/runtime/pipeline/TurnPipeline.d.ts.map +1 -0
- package/dist/runtime/pipeline/TurnPipeline.js +15 -0
- package/dist/runtime/pipeline/TurnPipeline.js.map +1 -0
- package/dist/runtime/pipeline/TurnServices.d.ts +48 -0
- package/dist/runtime/pipeline/TurnServices.d.ts.map +1 -0
- package/dist/runtime/pipeline/TurnServices.js +2 -0
- package/dist/runtime/pipeline/TurnServices.js.map +1 -0
- package/dist/runtime/pipeline/agentTypeGuards.d.ts +4 -0
- package/dist/runtime/pipeline/agentTypeGuards.d.ts.map +1 -0
- package/dist/runtime/pipeline/agentTypeGuards.js +7 -0
- package/dist/runtime/pipeline/agentTypeGuards.js.map +1 -0
- package/dist/runtime/pipeline/index.d.ts +11 -0
- package/dist/runtime/pipeline/index.d.ts.map +1 -0
- package/dist/runtime/pipeline/index.js +13 -0
- package/dist/runtime/pipeline/index.js.map +1 -0
- package/dist/runtime/pipeline/outputProcessing.d.ts +23 -0
- package/dist/runtime/pipeline/outputProcessing.d.ts.map +1 -0
- package/dist/runtime/pipeline/outputProcessing.js +63 -0
- package/dist/runtime/pipeline/outputProcessing.js.map +1 -0
- package/dist/runtime/pipeline/sessionUtils.d.ts +12 -0
- package/dist/runtime/pipeline/sessionUtils.d.ts.map +1 -0
- package/dist/runtime/pipeline/sessionUtils.js +73 -0
- package/dist/runtime/pipeline/sessionUtils.js.map +1 -0
- package/dist/tools/Tool.d.ts +7 -0
- package/dist/tools/Tool.d.ts.map +1 -1
- package/dist/tools/Tool.js +12 -3
- package/dist/tools/Tool.js.map +1 -1
- package/dist/tools/memory.d.ts +26 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +51 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/types/index.d.ts +238 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/telemetry.d.ts +107 -0
- package/dist/types/telemetry.d.ts.map +1 -1
- package/guides/AGENTS.md +173 -0
- package/guides/README.md +12 -0
- package/guides/TOOLS.md +93 -27
- package/package.json +25 -4
- package/dist/agents/LLMAgent.d.ts +0 -11
- package/dist/agents/LLMAgent.d.ts.map +0 -1
- package/dist/agents/LLMAgent.js +0 -31
- package/dist/agents/LLMAgent.js.map +0 -1
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { Agent } from './Agent.js';
|
|
2
2
|
export class CompositeAgent extends Agent {
|
|
3
|
+
compositeConfig;
|
|
3
4
|
agents = new Map();
|
|
4
5
|
entryAgentId;
|
|
5
|
-
|
|
6
|
+
maxHandoffsLimit;
|
|
6
7
|
constructor(config) {
|
|
7
|
-
super(
|
|
8
|
+
super({
|
|
9
|
+
id: config.id,
|
|
10
|
+
name: config.name,
|
|
11
|
+
description: config.description,
|
|
12
|
+
model: config.model,
|
|
13
|
+
prompt: config.prompt ?? '',
|
|
14
|
+
tools: config.tools,
|
|
15
|
+
canHandoffTo: config.canHandoffTo,
|
|
16
|
+
});
|
|
17
|
+
this.compositeConfig = config;
|
|
8
18
|
this.entryAgentId = config.entryAgent;
|
|
9
|
-
this.
|
|
19
|
+
this.maxHandoffsLimit = config.maxHandoffs ?? 10;
|
|
10
20
|
for (const agent of config.agents) {
|
|
11
21
|
this.agents.set(agent.id, agent);
|
|
12
22
|
}
|
|
@@ -23,11 +33,11 @@ export class CompositeAgent extends Agent {
|
|
|
23
33
|
}
|
|
24
34
|
await super.cleanup(context);
|
|
25
35
|
}
|
|
26
|
-
async *
|
|
36
|
+
async *run(input, context) {
|
|
27
37
|
let currentAgentId = context.session.activeAgentId || this.entryAgentId;
|
|
28
38
|
let currentInput = input;
|
|
29
39
|
let handoffCount = 0;
|
|
30
|
-
while (handoffCount < this.
|
|
40
|
+
while (handoffCount < this.maxHandoffsLimit) {
|
|
31
41
|
const agent = this.agents.get(currentAgentId);
|
|
32
42
|
if (!agent) {
|
|
33
43
|
yield { type: 'error', error: `Agent "${currentAgentId}" not found in composite agent "${this.id}"` };
|
|
@@ -36,7 +46,7 @@ export class CompositeAgent extends Agent {
|
|
|
36
46
|
let handoffTriggered = false;
|
|
37
47
|
let nextAgentId;
|
|
38
48
|
// Delegate processing to the sub-agent
|
|
39
|
-
for await (const part of agent.
|
|
49
|
+
for await (const part of agent.run(currentInput, context)) {
|
|
40
50
|
yield part;
|
|
41
51
|
if (part.type === 'handoff') {
|
|
42
52
|
handoffTriggered = true;
|
|
@@ -44,7 +54,7 @@ export class CompositeAgent extends Agent {
|
|
|
44
54
|
handoffCount += 1;
|
|
45
55
|
}
|
|
46
56
|
if (part.type === 'turn-end' && part.metadata?.response) {
|
|
47
|
-
// In a composite agent, we might want to collect all messages
|
|
57
|
+
// In a composite agent, we might want to collect all messages
|
|
48
58
|
// but for now we just yield it up so the orchestrator can persist.
|
|
49
59
|
}
|
|
50
60
|
}
|
|
@@ -59,8 +69,8 @@ export class CompositeAgent extends Agent {
|
|
|
59
69
|
context.session.activeAgentId = nextAgentId;
|
|
60
70
|
currentInput = ''; // Clear input for the next agent in the sequence
|
|
61
71
|
}
|
|
62
|
-
if (handoffCount >= this.
|
|
63
|
-
yield { type: 'error', error: `Maximum internal handoffs (${this.
|
|
72
|
+
if (handoffCount >= this.maxHandoffsLimit) {
|
|
73
|
+
yield { type: 'error', error: `Maximum internal handoffs (${this.maxHandoffsLimit}) exceeded in composite agent "${this.id}"` };
|
|
64
74
|
}
|
|
65
75
|
}
|
|
66
76
|
getAgent(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeAgent.js","sourceRoot":"","sources":["../../src/agents/CompositeAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASnC,MAAM,OAAO,cAAe,SAAQ,
|
|
1
|
+
{"version":3,"file":"CompositeAgent.js","sourceRoot":"","sources":["../../src/agents/CompositeAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASnC,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC/B,eAAe,CAAuB;IACtC,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IAClC,YAAY,CAAS;IACrB,gBAAgB,CAAS;IAEjC,YAAY,MAA4B;QACtC,KAAK,CAAC;YACJ,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,KAAK,EAAE,MAAM,CAAC,KAAM;YACpB,MAAM,EAAE,MAAM,CAAC,MAAM,IA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C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QAClI,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Agent } from './Agent.js';
|
|
2
2
|
import type { AgentContext, AgentStreamPart, FlowAgentConfig } from '../types/index.js';
|
|
3
|
-
export declare class FlowAgent extends Agent
|
|
3
|
+
export declare class FlowAgent extends Agent {
|
|
4
|
+
private flowConfig;
|
|
4
5
|
private flowManager?;
|
|
5
6
|
constructor(config: FlowAgentConfig);
|
|
6
|
-
|
|
7
|
+
run(input: string, context: AgentContext): AsyncGenerator<AgentStreamPart>;
|
|
7
8
|
get collectedData(): Record<string, unknown>;
|
|
8
9
|
get currentNode(): string | undefined;
|
|
9
10
|
transitionTo(node: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowAgent.d.ts","sourceRoot":"","sources":["../../src/agents/FlowAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAExF,qBAAa,SAAU,SAAQ,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"FlowAgent.d.ts","sourceRoot":"","sources":["../../src/agents/FlowAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAExF,qBAAa,SAAU,SAAQ,KAAK;IAClC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,WAAW,CAAC,CAAc;gBAEtB,MAAM,EAAE,eAAe;IAgB5B,GAAG,CACR,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,YAAY,GACpB,cAAc,CAAC,eAAe,CAAC;IAyBlC,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE3C;IAED,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAEK,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhD"}
|
package/dist/agents/FlowAgent.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import { Agent } from './Agent.js';
|
|
2
2
|
import { FlowManager } from '../flows/FlowManager.js';
|
|
3
3
|
export class FlowAgent extends Agent {
|
|
4
|
+
flowConfig;
|
|
4
5
|
flowManager;
|
|
5
6
|
constructor(config) {
|
|
6
|
-
super(
|
|
7
|
+
super({
|
|
8
|
+
id: config.id,
|
|
9
|
+
name: config.name,
|
|
10
|
+
description: config.description,
|
|
11
|
+
model: config.model,
|
|
12
|
+
prompt: config.prompt ?? '',
|
|
13
|
+
tools: config.tools,
|
|
14
|
+
canHandoffTo: config.canHandoffTo,
|
|
15
|
+
});
|
|
16
|
+
this.flowConfig = config;
|
|
7
17
|
if (!config.model) {
|
|
8
18
|
throw new Error(`FlowAgent "${config.id}" requires a model`);
|
|
9
19
|
}
|
|
10
20
|
}
|
|
11
|
-
async *
|
|
21
|
+
async *run(input, context) {
|
|
12
22
|
if (!this.flowManager) {
|
|
13
23
|
this.flowManager = new FlowManager({
|
|
14
|
-
flow: this.
|
|
15
|
-
initialNode: this.
|
|
16
|
-
model: this.
|
|
17
|
-
defaultRolePrompt: this.
|
|
24
|
+
flow: this.flowConfig.flow,
|
|
25
|
+
initialNode: this.flowConfig.initialNode,
|
|
26
|
+
model: this.flowConfig.model,
|
|
27
|
+
defaultRolePrompt: await this.resolveSystemPrompt(),
|
|
18
28
|
contextMessages: context.messages,
|
|
19
29
|
abortSignal: context.abortSignal,
|
|
20
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowAgent.js","sourceRoot":"","sources":["../../src/agents/FlowAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,MAAM,OAAO,SAAU,SAAQ,
|
|
1
|
+
{"version":3,"file":"FlowAgent.js","sourceRoot":"","sources":["../../src/agents/FlowAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAC1B,UAAU,CAAkB;IAC5B,WAAW,CAAe;IAElC,YAAY,MAAuB;QACjC,KAAK,CAAC;YACJ,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,KAAK,EAAE,MAAM,CAAC,KAAM;YACpB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;YAC3B,KAAK,EAAE,MAAM,CAAC,KAAY;YAC1B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,cAAc,MAAM,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,GAAG,CACR,KAAa,EACb,OAAqB;QAErB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC;gBACjC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI;gBAC1B,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW;gBACxC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAM;gBAC7B,iBAAiB,EAAE,MAAM,IAAI,CAAC,mBAAmB,EAAE;gBACnD,eAAe,EAAE,OAAO,CAAC,QAAQ;gBACjC,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;YAEH,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,CAAC;gBACvD,MAAM,IAAI,CAAC;YACb,CAAC;QACH,CAAC;QAED,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,CAAC;YAEX,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,WAAW,EAAE,aAAa,IAAI,EAAE,CAAC;IAC/C,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAY;QAC7B,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Agent } from './Agent.js';
|
|
2
2
|
import type { AgentContext, AgentStreamPart, TriageAgentConfig } from '../types/index.js';
|
|
3
|
-
export declare class TriageAgent extends Agent
|
|
3
|
+
export declare class TriageAgent extends Agent {
|
|
4
|
+
private triageConfig;
|
|
4
5
|
private routes;
|
|
5
6
|
private defaultAgent?;
|
|
6
7
|
constructor(config: TriageAgentConfig);
|
|
7
|
-
|
|
8
|
+
run(_input: string, context: AgentContext): AsyncGenerator<AgentStreamPart>;
|
|
8
9
|
private buildRoutingPrompt;
|
|
10
|
+
/**
|
|
11
|
+
* Builds the system prompt with working memory appended.
|
|
12
|
+
* Mirrors the old BaseAgent.buildSystemPrompt() behavior.
|
|
13
|
+
*/
|
|
14
|
+
private buildSystemPromptWithMemory;
|
|
9
15
|
private createHandoffTool;
|
|
10
16
|
}
|
|
11
17
|
//# sourceMappingURL=TriageAgent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TriageAgent.d.ts","sourceRoot":"","sources":["../../src/agents/TriageAgent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAc,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"TriageAgent.d.ts","sourceRoot":"","sources":["../../src/agents/TriageAgent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAc,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtG,qBAAa,WAAY,SAAQ,KAAK;IACpC,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,MAAM,EAAE,iBAAiB;IAkB9B,GAAG,CACR,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,GACpB,cAAc,CAAC,eAAe,CAAC;IAoBlC,OAAO,CAAC,kBAAkB;IAwB1B;;;OAGG;IACH,OAAO,CAAC,2BAA2B;IAmBnC,OAAO,CAAC,iBAAiB;CAmB1B"}
|
|
@@ -3,27 +3,37 @@ import { z } from 'zod';
|
|
|
3
3
|
import { Agent } from './Agent.js';
|
|
4
4
|
import { processAIStream } from '../utils/aiStream.js';
|
|
5
5
|
export class TriageAgent extends Agent {
|
|
6
|
+
triageConfig;
|
|
6
7
|
routes;
|
|
7
8
|
defaultAgent;
|
|
8
9
|
constructor(config) {
|
|
9
|
-
super(
|
|
10
|
+
super({
|
|
11
|
+
id: config.id,
|
|
12
|
+
name: config.name,
|
|
13
|
+
description: config.description,
|
|
14
|
+
model: config.model,
|
|
15
|
+
prompt: config.prompt ?? '',
|
|
16
|
+
tools: config.tools,
|
|
17
|
+
canHandoffTo: config.canHandoffTo,
|
|
18
|
+
});
|
|
19
|
+
this.triageConfig = config;
|
|
10
20
|
if (!config.model) {
|
|
11
21
|
throw new Error(`TriageAgent "${config.id}" requires a model`);
|
|
12
22
|
}
|
|
13
23
|
this.routes = config.routes;
|
|
14
24
|
this.defaultAgent = config.defaultAgent;
|
|
15
25
|
}
|
|
16
|
-
async *
|
|
26
|
+
async *run(_input, context) {
|
|
17
27
|
const systemPrompt = this.buildRoutingPrompt(context);
|
|
18
28
|
const handoffTool = this.createHandoffTool();
|
|
19
29
|
const result = streamText({
|
|
20
|
-
model: this.
|
|
30
|
+
model: this.model,
|
|
21
31
|
system: systemPrompt,
|
|
22
32
|
messages: context.messages,
|
|
23
33
|
abortSignal: context.abortSignal,
|
|
24
34
|
tools: {
|
|
25
35
|
handoff_to_agent: handoffTool,
|
|
26
|
-
...this.
|
|
36
|
+
...this.triageConfig.tools,
|
|
27
37
|
},
|
|
28
38
|
});
|
|
29
39
|
yield* processAIStream(result.fullStream);
|
|
@@ -36,18 +46,41 @@ export class TriageAgent extends Agent {
|
|
|
36
46
|
const defaultNote = this.defaultAgent
|
|
37
47
|
? `\n- Use "${this.defaultAgent}" when no specialist applies.`
|
|
38
48
|
: '';
|
|
39
|
-
|
|
49
|
+
const basePrompt = this.buildSystemPromptWithMemory(context);
|
|
50
|
+
return `${basePrompt}
|
|
40
51
|
|
|
41
52
|
## Available Specialists
|
|
42
53
|
${routeDescriptions}
|
|
43
54
|
|
|
44
55
|
## Instructions
|
|
45
56
|
- Follow the system prompt above.
|
|
46
|
-
- Use the handoff_to_agent tool when a specialist is needed.
|
|
57
|
+
- Use the handoff_to_agent tool when a specialist is needed.
|
|
47
58
|
- You MAY provide a very brief, natural transition (e.g., "I'll check that for you...") or remain silent. Do not state "I am handing you off".
|
|
48
59
|
- Keep the transition content separate from the specialist's likely greeting.
|
|
49
60
|
- Always provide a reason for the handoff via the tool${defaultNote}`;
|
|
50
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Builds the system prompt with working memory appended.
|
|
64
|
+
* Mirrors the old BaseAgent.buildSystemPrompt() behavior.
|
|
65
|
+
*/
|
|
66
|
+
buildSystemPromptWithMemory(context) {
|
|
67
|
+
let prompt = '';
|
|
68
|
+
if (typeof this.prompt === 'string') {
|
|
69
|
+
prompt = this.prompt;
|
|
70
|
+
}
|
|
71
|
+
else if (this.prompt && 'render' in this.prompt && typeof this.prompt.render === 'function') {
|
|
72
|
+
// Synchronous fallback for routing prompt building
|
|
73
|
+
prompt = String(this.prompt);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
prompt = String(this.prompt);
|
|
77
|
+
}
|
|
78
|
+
const memory = context.workingMemory.toJSON();
|
|
79
|
+
if (Object.keys(memory).length > 0) {
|
|
80
|
+
prompt += `\n\n## Known Information\n${JSON.stringify(memory, null, 2)}`;
|
|
81
|
+
}
|
|
82
|
+
return prompt;
|
|
83
|
+
}
|
|
51
84
|
createHandoffTool() {
|
|
52
85
|
const agentIds = this.routes.map(route => route.agentId);
|
|
53
86
|
return tool({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TriageAgent.js","sourceRoot":"","sources":["../../src/agents/TriageAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AACt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dist/agents/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Agent } from './Agent.js';
|
|
2
|
-
export {
|
|
2
|
+
export type { AgentConstructorConfig, GenerateOptions, GenerateResult, AgentStreamPart as StandaloneStreamPart, AsToolConfig, } from './Agent.js';
|
|
3
3
|
export { FlowAgent } from './FlowAgent.js';
|
|
4
4
|
export { TriageAgent } from './TriageAgent.js';
|
|
5
5
|
export { CompositeAgent } from './CompositeAgent.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EACV,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,eAAe,IAAI,oBAAoB,EACvC,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/agents/index.js
CHANGED
package/dist/agents/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAQnC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Capability, ToolDeclaration, PromptSection, CapabilityAction } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Simplified retrieval interface for the capability layer.
|
|
4
|
+
* Decoupled from AutoRetrieveProvider's RunContext requirement — the
|
|
5
|
+
* capability system is backend-agnostic and has no RunContext at tool time.
|
|
6
|
+
*/
|
|
7
|
+
export interface RetrieveProvider {
|
|
8
|
+
run: (opts: {
|
|
9
|
+
input: string;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
text: string;
|
|
12
|
+
} | null>;
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AutoRetrieveCapabilityConfig {
|
|
16
|
+
provider: RetrieveProvider;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts auto-retrieve from a pipeline stage to an on-demand
|
|
20
|
+
* `search_knowledge_base` tool. The LLM decides when to call it;
|
|
21
|
+
* the result flows back as a tool result for the LLM to use.
|
|
22
|
+
*/
|
|
23
|
+
export declare class AutoRetrieveCapability implements Capability {
|
|
24
|
+
private provider;
|
|
25
|
+
constructor(config: AutoRetrieveCapabilityConfig);
|
|
26
|
+
getTools(): ToolDeclaration[];
|
|
27
|
+
getPromptSections(): PromptSection[];
|
|
28
|
+
processToolResult(_toolName: string, _args: unknown, _result: unknown): CapabilityAction | null;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=AutoRetrieveCapability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoRetrieveCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/AutoRetrieveCapability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAI/F;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAID;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,UAAU;IACvD,OAAO,CAAC,QAAQ,CAAmB;gBAEvB,MAAM,EAAE,4BAA4B;IAIhD,QAAQ,IAAI,eAAe,EAAE;IAkB7B,iBAAiB,IAAI,aAAa,EAAE;IAIpC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI;CAGhG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// ─── AutoRetrieveCapability ──────────────────────────────────────────────────
|
|
3
|
+
/**
|
|
4
|
+
* Converts auto-retrieve from a pipeline stage to an on-demand
|
|
5
|
+
* `search_knowledge_base` tool. The LLM decides when to call it;
|
|
6
|
+
* the result flows back as a tool result for the LLM to use.
|
|
7
|
+
*/
|
|
8
|
+
export class AutoRetrieveCapability {
|
|
9
|
+
provider;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.provider = config.provider;
|
|
12
|
+
}
|
|
13
|
+
getTools() {
|
|
14
|
+
const label = this.provider.label ?? 'knowledge base';
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: 'search_knowledge_base',
|
|
18
|
+
description: `Search the ${label} for relevant information to answer the user's question.`,
|
|
19
|
+
parameters: z.object({
|
|
20
|
+
query: z.string().describe('The search query'),
|
|
21
|
+
}),
|
|
22
|
+
execute: async (args) => {
|
|
23
|
+
const result = await this.provider.run({ input: args.query });
|
|
24
|
+
return result ?? { text: 'No relevant information found.' };
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
getPromptSections() {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
processToolResult(_toolName, _args, _result) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=AutoRetrieveCapability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoRetrieveCapability.js","sourceRoot":"","sources":["../../src/capabilities/AutoRetrieveCapability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IACzB,QAAQ,CAAmB;IAEnC,YAAY,MAAoC;QAC9C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,QAAQ;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,gBAAgB,CAAC;QAEtD,OAAO;YACL;gBACE,IAAI,EAAE,uBAAuB;gBAC7B,WAAW,EAAE,cAAc,KAAK,0DAA0D;gBAC1F,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;oBACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;iBAC/C,CAAC;gBACF,OAAO,EAAE,KAAK,EAAE,IAAuB,EAAE,EAAE;oBACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;oBAC9D,OAAO,MAAM,IAAI,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAAC;gBAC9D,CAAC;aACF;SACF,CAAC;IACJ,CAAC;IAED,iBAAiB;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,iBAAiB,CAAC,SAAiB,EAAE,KAAc,EAAE,OAAgB;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ZodTypeAny } from 'zod';
|
|
2
|
+
import type { Capability, ToolDeclaration, PromptSection, CapabilityAction } from './index.js';
|
|
3
|
+
export interface ExtractionCapabilityConfig {
|
|
4
|
+
schema: ZodTypeAny;
|
|
5
|
+
/** Fields that must be present to consider extraction complete. */
|
|
6
|
+
requiredFields?: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Agent-level extraction: collects structured data across turns using a
|
|
10
|
+
* single `submit_extracted_data` tool. Distinct from FlowCapability's
|
|
11
|
+
* per-node extraction — this is for standalone agents, not flow nodes.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ExtractionCapability implements Capability {
|
|
14
|
+
private schema;
|
|
15
|
+
private requiredFields;
|
|
16
|
+
private collectedData;
|
|
17
|
+
constructor(config: ExtractionCapabilityConfig);
|
|
18
|
+
getTools(): ToolDeclaration[];
|
|
19
|
+
getPromptSections(): PromptSection[];
|
|
20
|
+
processToolResult(toolName: string, args: unknown, result: unknown): CapabilityAction | null;
|
|
21
|
+
/** Read the data collected so far. */
|
|
22
|
+
get data(): Record<string, unknown>;
|
|
23
|
+
private getMissingFields;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ExtractionCapability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtractionCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/ExtractionCapability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK/F,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,UAAU,CAAC;IACnB,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAID;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,UAAU;IACrD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,cAAc,CAAW;IACjC,OAAO,CAAC,aAAa,CAA+B;gBAExC,MAAM,EAAE,0BAA0B;IAK9C,QAAQ,IAAI,eAAe,EAAE;IAqB7B,iBAAiB,IAAI,aAAa,EAAE;IAYpC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI;IAe5F,sCAAsC;IACtC,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElC;IAID,OAAO,CAAC,gBAAgB;CAazB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { mergeExtractionData, computeMissingFields, toExtractionSubmissionSchema } from '../flows/extraction.js';
|
|
2
|
+
// ─── ExtractionCapability ────────────────────────────────────────────────────
|
|
3
|
+
/**
|
|
4
|
+
* Agent-level extraction: collects structured data across turns using a
|
|
5
|
+
* single `submit_extracted_data` tool. Distinct from FlowCapability's
|
|
6
|
+
* per-node extraction — this is for standalone agents, not flow nodes.
|
|
7
|
+
*/
|
|
8
|
+
export class ExtractionCapability {
|
|
9
|
+
schema;
|
|
10
|
+
requiredFields;
|
|
11
|
+
collectedData = {};
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.schema = config.schema;
|
|
14
|
+
this.requiredFields = config.requiredFields ?? [];
|
|
15
|
+
}
|
|
16
|
+
getTools() {
|
|
17
|
+
const missing = this.getMissingFields();
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
name: 'submit_extracted_data',
|
|
21
|
+
description: [
|
|
22
|
+
'Submit information extracted from the conversation.',
|
|
23
|
+
missing.length > 0
|
|
24
|
+
? `Still needed: ${missing.join(', ')}.`
|
|
25
|
+
: 'All required fields collected.',
|
|
26
|
+
'Only submit values explicitly provided by the user.',
|
|
27
|
+
'Omit fields or use null when the value is still unknown.',
|
|
28
|
+
'Call this tool every time you learn new field values.',
|
|
29
|
+
].join(' '),
|
|
30
|
+
parameters: toExtractionSubmissionSchema(this.schema),
|
|
31
|
+
execute: async (args) => args,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
getPromptSections() {
|
|
36
|
+
const missing = this.getMissingFields();
|
|
37
|
+
if (missing.length === 0)
|
|
38
|
+
return [];
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
role: 'extraction',
|
|
42
|
+
content: `You still need to collect: ${missing.join(', ')}. Ask for these naturally.`,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
processToolResult(toolName, args, result) {
|
|
47
|
+
if (toolName !== 'submit_extracted_data')
|
|
48
|
+
return null;
|
|
49
|
+
this.collectedData = mergeExtractionData(this.collectedData, args);
|
|
50
|
+
const missing = this.getMissingFields();
|
|
51
|
+
if (missing.length === 0) {
|
|
52
|
+
return { type: 'extraction-complete', data: this.collectedData };
|
|
53
|
+
}
|
|
54
|
+
return { type: 'continue' };
|
|
55
|
+
}
|
|
56
|
+
/** Read the data collected so far. */
|
|
57
|
+
get data() {
|
|
58
|
+
return this.collectedData;
|
|
59
|
+
}
|
|
60
|
+
// ─── Private ───────────────────────────────────────────────────────────────
|
|
61
|
+
getMissingFields() {
|
|
62
|
+
if (this.requiredFields.length > 0) {
|
|
63
|
+
return computeMissingFields(this.collectedData, this.requiredFields);
|
|
64
|
+
}
|
|
65
|
+
// Fall back to Zod schema parse to infer missing fields
|
|
66
|
+
const parsed = this.schema.safeParse(this.collectedData);
|
|
67
|
+
if (parsed.success)
|
|
68
|
+
return [];
|
|
69
|
+
return [...new Set((parsed.error.issues ?? [])
|
|
70
|
+
.map((issue) => issue.path.join('.'))
|
|
71
|
+
.filter(Boolean))];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=ExtractionCapability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtractionCapability.js","sourceRoot":"","sources":["../../src/capabilities/ExtractionCapability.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAUjH,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACvB,MAAM,CAAa;IACnB,cAAc,CAAW;IACzB,aAAa,GAA4B,EAAE,CAAC;IAEpD,YAAY,MAAkC;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC;IACpD,CAAC;IAED,QAAQ;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAExC,OAAO;YACL;gBACE,IAAI,EAAE,uBAAuB;gBAC7B,WAAW,EAAE;oBACX,qDAAqD;oBACrD,OAAO,CAAC,MAAM,GAAG,CAAC;wBAChB,CAAC,CAAC,iBAAiB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;wBACxC,CAAC,CAAC,gCAAgC;oBACpC,qDAAqD;oBACrD,0DAA0D;oBAC1D,uDAAuD;iBACxD,CAAC,IAAI,CAAC,GAAG,CAAC;gBACX,UAAU,EAAE,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC;gBACrD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE,CAAC,IAAI;aACvC;SACF,CAAC;IACJ,CAAC;IAED,iBAAiB;QACf,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,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AAC,CAAC;iBACnE,MAAM,CAAC,OAAO,CAAC,CACnB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Capability, ToolDeclaration, PromptSection, CapabilityAction } from './index.js';
|
|
2
|
+
import type { FlowConfig, FlowContext, ExtractionNodeConfig } from '../types/index.js';
|
|
3
|
+
export interface FlowCapabilityConfig {
|
|
4
|
+
flow: FlowConfig;
|
|
5
|
+
initialNode: string;
|
|
6
|
+
state?: FlowCapabilityState;
|
|
7
|
+
defaultRolePrompt?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface FlowCapabilityState {
|
|
10
|
+
context: FlowContext;
|
|
11
|
+
initialized: boolean;
|
|
12
|
+
flowEnded: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Headless flow state machine that exposes flow behavior as tools.
|
|
16
|
+
*
|
|
17
|
+
* Owns: node graph, transitions, current node, collectedData,
|
|
18
|
+
* oscillation tracking, extraction node handling, contract validation.
|
|
19
|
+
*
|
|
20
|
+
* Does NOT own: LLM calls, streaming, AI SDK imports. The host
|
|
21
|
+
* (Gemini Live, AI SDK, LiveKit) handles inference.
|
|
22
|
+
*/
|
|
23
|
+
export declare class FlowCapability implements Capability {
|
|
24
|
+
private nodes;
|
|
25
|
+
private transitions;
|
|
26
|
+
private context;
|
|
27
|
+
private currentNodeConfig;
|
|
28
|
+
private initialized;
|
|
29
|
+
private flowEnded;
|
|
30
|
+
private _justTransitioned;
|
|
31
|
+
private maxOscillations;
|
|
32
|
+
private defaultRolePrompt?;
|
|
33
|
+
/** Tracks transition edges within a single process() call for oscillation detection. */
|
|
34
|
+
private turnTransitionCounts;
|
|
35
|
+
/** Events emitted during transitions (node-enter, node-exit, flow-transition, etc.). */
|
|
36
|
+
private pendingEvents;
|
|
37
|
+
constructor(config: FlowCapabilityConfig);
|
|
38
|
+
getTools(): ToolDeclaration[];
|
|
39
|
+
getPromptSections(): PromptSection[];
|
|
40
|
+
processToolResult(toolName: string, args: unknown, result: unknown): CapabilityAction | null;
|
|
41
|
+
/** Initialize the flow (transition to initial node). */
|
|
42
|
+
initialize(): FlowEvent[];
|
|
43
|
+
/** Call at the start of each user turn to reset oscillation tracking. */
|
|
44
|
+
resetTurnTracking(): void;
|
|
45
|
+
/** Record a user message in the flow context. */
|
|
46
|
+
appendUserMessage(content: string): void;
|
|
47
|
+
/** Record an assistant message in the flow context. */
|
|
48
|
+
appendAssistantMessage(content: string): void;
|
|
49
|
+
get currentNode(): string | undefined;
|
|
50
|
+
currentNodeIsExtractionNode(): boolean;
|
|
51
|
+
currentExtractionNode(): ExtractionNodeConfig | null;
|
|
52
|
+
get collectedData(): Record<string, unknown>;
|
|
53
|
+
updateCollectedData(verified: Record<string, unknown>): boolean;
|
|
54
|
+
get hasEnded(): boolean;
|
|
55
|
+
get isInitialized(): boolean;
|
|
56
|
+
getState(): FlowCapabilityState;
|
|
57
|
+
/** Drain accumulated flow events (node-enter, node-exit, etc.). */
|
|
58
|
+
drainEvents(): FlowEvent[];
|
|
59
|
+
private executeTransition;
|
|
60
|
+
private mergeExtractedData;
|
|
61
|
+
private checkExtractionComplete;
|
|
62
|
+
private getMissingExtractionFields;
|
|
63
|
+
private applyContextStrategy;
|
|
64
|
+
private getRelevantCollectedData;
|
|
65
|
+
private buildExtractionContinueEnvelope;
|
|
66
|
+
}
|
|
67
|
+
export type FlowEvent = {
|
|
68
|
+
type: 'node-enter';
|
|
69
|
+
nodeName: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'node-exit';
|
|
72
|
+
nodeName: string;
|
|
73
|
+
} | {
|
|
74
|
+
type: 'flow-transition';
|
|
75
|
+
from: string;
|
|
76
|
+
to: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: 'flow-end';
|
|
79
|
+
reason: string;
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=FlowCapability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fl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