@memberjunction/ai-agents 3.4.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentDataPreloader.d.ts +117 -1
- package/dist/AgentDataPreloader.d.ts.map +1 -1
- package/dist/AgentDataPreloader.js +156 -58
- package/dist/AgentDataPreloader.js.map +1 -1
- package/dist/AgentRunner.d.ts +212 -0
- package/dist/AgentRunner.d.ts.map +1 -1
- package/dist/AgentRunner.js +354 -103
- package/dist/AgentRunner.js.map +1 -1
- package/dist/PayloadChangeAnalyzer.d.ts +68 -0
- package/dist/PayloadChangeAnalyzer.d.ts.map +1 -1
- package/dist/PayloadChangeAnalyzer.js +68 -32
- package/dist/PayloadChangeAnalyzer.js.map +1 -1
- package/dist/PayloadFeedbackManager.d.ts +57 -1
- package/dist/PayloadFeedbackManager.d.ts.map +1 -1
- package/dist/PayloadFeedbackManager.js +66 -21
- package/dist/PayloadFeedbackManager.js.map +1 -1
- package/dist/PayloadManager.d.ts +286 -1
- package/dist/PayloadManager.d.ts.map +1 -1
- package/dist/PayloadManager.js +423 -50
- package/dist/PayloadManager.js.map +1 -1
- package/dist/__tests__/action-changes.test.d.ts +13 -0
- package/dist/__tests__/action-changes.test.d.ts.map +1 -1
- package/dist/__tests__/action-changes.test.js +57 -4
- package/dist/__tests__/action-changes.test.js.map +1 -1
- package/dist/__tests__/agent-memory-features.test.d.ts +52 -0
- package/dist/__tests__/agent-memory-features.test.d.ts.map +1 -1
- package/dist/__tests__/agent-memory-features.test.js +96 -13
- package/dist/__tests__/agent-memory-features.test.js.map +1 -1
- package/dist/__tests__/agent-type-prompt-params.test.d.ts +12 -0
- package/dist/__tests__/agent-type-prompt-params.test.d.ts.map +1 -1
- package/dist/__tests__/agent-type-prompt-params.test.js +112 -20
- package/dist/__tests__/agent-type-prompt-params.test.js.map +1 -1
- package/dist/__tests__/chat-handling-option.test.d.ts +26 -0
- package/dist/__tests__/chat-handling-option.test.d.ts.map +1 -1
- package/dist/__tests__/chat-handling-option.test.js +41 -2
- package/dist/__tests__/chat-handling-option.test.js.map +1 -1
- package/dist/agent-context-injector.d.ts +114 -0
- package/dist/agent-context-injector.d.ts.map +1 -1
- package/dist/agent-context-injector.js +138 -19
- package/dist/agent-context-injector.js.map +1 -1
- package/dist/agent-types/base-agent-type.d.ts +354 -0
- package/dist/agent-types/base-agent-type.d.ts.map +1 -1
- package/dist/agent-types/base-agent-type.js +288 -17
- package/dist/agent-types/base-agent-type.js.map +1 -1
- package/dist/agent-types/flow-agent-type.d.ts +328 -2
- package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
- package/dist/agent-types/flow-agent-type.js +503 -63
- package/dist/agent-types/flow-agent-type.js.map +1 -1
- package/dist/agent-types/index.d.ts +14 -3
- package/dist/agent-types/index.d.ts.map +1 -1
- package/dist/agent-types/index.js +14 -23
- package/dist/agent-types/index.js.map +1 -1
- package/dist/agent-types/loop-agent-prompt-params.d.ts +190 -0
- package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-prompt-params.js +23 -6
- package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
- package/dist/agent-types/loop-agent-response-type.d.ts +62 -0
- package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-response-type.js +3 -2
- package/dist/agent-types/loop-agent-response-type.js.map +1 -1
- package/dist/agent-types/loop-agent-type.d.ts +139 -2
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-type.js +207 -35
- package/dist/agent-types/loop-agent-type.js.map +1 -1
- package/dist/base-agent.d.ts +1344 -1
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +2282 -211
- package/dist/base-agent.js.map +1 -1
- package/dist/index.d.ts +24 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -35
- package/dist/index.js.map +1 -1
- package/dist/memory-cleanup-agent.d.ts +53 -1
- package/dist/memory-cleanup-agent.d.ts.map +1 -1
- package/dist/memory-cleanup-agent.js +89 -21
- package/dist/memory-cleanup-agent.js.map +1 -1
- package/dist/memory-manager-agent.d.ts +61 -1
- package/dist/memory-manager-agent.d.ts.map +1 -1
- package/dist/memory-manager-agent.js +260 -116
- package/dist/memory-manager-agent.js.map +1 -1
- package/dist/services/AgentEmbeddingService.d.ts +16 -0
- package/dist/services/AgentEmbeddingService.d.ts.map +1 -0
- package/dist/services/AgentEmbeddingService.js +158 -0
- package/dist/services/AgentEmbeddingService.js.map +1 -0
- package/dist/types/AgentMatchResult.d.ts +18 -0
- package/dist/types/AgentMatchResult.d.ts.map +1 -0
- package/dist/types/AgentMatchResult.js +3 -0
- package/dist/types/AgentMatchResult.js.map +1 -0
- package/dist/types/payload-operations.d.ts +51 -0
- package/dist/types/payload-operations.d.ts.map +1 -1
- package/dist/types/payload-operations.js +54 -15
- package/dist/types/payload-operations.js.map +1 -1
- package/dist/utils/ConversationMessageResolver.d.ts +79 -1
- package/dist/utils/ConversationMessageResolver.d.ts.map +1 -1
- package/dist/utils/ConversationMessageResolver.js +99 -9
- package/dist/utils/ConversationMessageResolver.js.map +1 -1
- package/package.json +20 -19
|
@@ -1,14 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Implementation of the Flow Agent Type for deterministic workflow execution.
|
|
3
|
+
*
|
|
4
|
+
* The FlowAgentType enables agents to execute predefined workflows using a directed graph
|
|
5
|
+
* of steps and conditional paths. Unlike LoopAgentType which makes decisions based on
|
|
6
|
+
* LLM output, FlowAgentType follows a deterministic execution path based on boolean
|
|
7
|
+
* expressions evaluated against the current payload and step results.
|
|
8
|
+
*
|
|
9
|
+
* @module @memberjunction/ai-agents
|
|
10
|
+
* @author MemberJunction.com
|
|
11
|
+
* @since 2.76.0
|
|
12
|
+
*/
|
|
13
|
+
import { BaseAgentType } from './base-agent-type.js';
|
|
2
14
|
import { AIPromptRunResult, BaseAgentNextStep, AIPromptParams, AgentPayloadChangeRequest, AgentAction, ExecuteAgentParams, AgentConfiguration } from '@memberjunction/ai-core-plus';
|
|
3
15
|
import { AIAgentStepEntity } from '@memberjunction/core-entities';
|
|
4
16
|
import { AIPromptEntityExtended } from "@memberjunction/ai-core-plus";
|
|
5
17
|
import { ActionResult } from '@memberjunction/actions-base';
|
|
18
|
+
/**
|
|
19
|
+
* Flow execution state that tracks the progress through the workflow.
|
|
20
|
+
* This is maintained by the Flow Agent Type during execution.
|
|
21
|
+
*
|
|
22
|
+
* Note: Loop iteration tracking is now handled by BaseAgent._iterationContext.
|
|
23
|
+
* FlowExecutionState only tracks flow-specific navigation state.
|
|
24
|
+
*/
|
|
6
25
|
export declare class FlowExecutionState {
|
|
26
|
+
/** The agent ID for this flow execution */
|
|
7
27
|
agentId: string;
|
|
28
|
+
/** The current step being executed */
|
|
8
29
|
currentStepId?: string;
|
|
30
|
+
/** Set of completed step IDs */
|
|
9
31
|
completedStepIds: Set<string>;
|
|
32
|
+
/** Map of step results by step ID */
|
|
10
33
|
stepResults: Map<string, unknown>;
|
|
34
|
+
/** Ordered list of step IDs in execution order */
|
|
11
35
|
executionPath: string[];
|
|
36
|
+
/** Special fields from action output mappings (message, reasoning, confidence) */
|
|
12
37
|
specialFields?: {
|
|
13
38
|
message?: string;
|
|
14
39
|
reasoning?: string;
|
|
@@ -16,43 +41,345 @@ export declare class FlowExecutionState {
|
|
|
16
41
|
};
|
|
17
42
|
constructor(agentId: string);
|
|
18
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Flow Agent-specific execution parameters.
|
|
46
|
+
*
|
|
47
|
+
* These parameters allow callers to customize how a Flow Agent executes,
|
|
48
|
+
* including starting at a specific step or skipping certain steps.
|
|
49
|
+
* Use with ExecuteAgentParams.agentTypeParams for type-safe configuration.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import { FlowAgentExecuteParams } from '@memberjunction/ai-agents';
|
|
54
|
+
*
|
|
55
|
+
* // Get the step to start at
|
|
56
|
+
* const approvalStep = AIEngine.Instance.GetAgentSteps(agentId)
|
|
57
|
+
* .find(s => s.Name === 'Approval Review');
|
|
58
|
+
*
|
|
59
|
+
* const params: ExecuteAgentParams<any, any, FlowAgentExecuteParams> = {
|
|
60
|
+
* agent: myFlowAgent,
|
|
61
|
+
* conversationMessages: messages,
|
|
62
|
+
* agentTypeParams: {
|
|
63
|
+
* startAtStep: approvalStep, // Skip initial steps, start here
|
|
64
|
+
* }
|
|
65
|
+
* };
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @since 2.127.0
|
|
69
|
+
*/
|
|
19
70
|
export interface FlowAgentExecuteParams {
|
|
71
|
+
/**
|
|
72
|
+
* Start execution at a specific step instead of the flow's entry point.
|
|
73
|
+
*
|
|
74
|
+
* When provided, the flow agent will begin execution at this step,
|
|
75
|
+
* skipping all steps that would normally precede it. This is useful for:
|
|
76
|
+
* - Resuming a flow from a specific point
|
|
77
|
+
* - Testing specific branches of a flow
|
|
78
|
+
* - Re-running a portion of a flow after a failure
|
|
79
|
+
*
|
|
80
|
+
* The step must belong to the agent being executed.
|
|
81
|
+
* Use AIEngine.Instance.GetAgentSteps(agentId) to retrieve available steps.
|
|
82
|
+
*/
|
|
20
83
|
startAtStep?: AIAgentStepEntity;
|
|
84
|
+
/**
|
|
85
|
+
* Steps to skip during execution.
|
|
86
|
+
*
|
|
87
|
+
* When the flow would normally execute one of these steps, it will instead
|
|
88
|
+
* immediately evaluate the step's outgoing paths and continue to the next
|
|
89
|
+
* valid step. This is useful for:
|
|
90
|
+
* - Bypassing steps that have already been completed externally
|
|
91
|
+
* - Testing flows without certain side effects
|
|
92
|
+
* - Conditional step execution based on runtime state
|
|
93
|
+
*
|
|
94
|
+
* Skipped steps are still recorded in the execution path but marked as skipped.
|
|
95
|
+
* The step's output mapping is not applied when skipped.
|
|
96
|
+
*/
|
|
21
97
|
skipSteps?: AIAgentStepEntity[];
|
|
22
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Implementation of the Flow Agent Type pattern.
|
|
101
|
+
*
|
|
102
|
+
* This agent type enables deterministic workflow execution where agents follow
|
|
103
|
+
* predefined paths through a graph of steps. Key features:
|
|
104
|
+
* - Graph-based workflow definition
|
|
105
|
+
* - Conditional path evaluation using safe boolean expressions
|
|
106
|
+
* - Support for Actions, Sub-Agents, and Prompts as step types
|
|
107
|
+
* - Deterministic execution with optional AI-driven decision points
|
|
108
|
+
*
|
|
109
|
+
* @class FlowAgentType
|
|
110
|
+
* @extends BaseAgentType
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // Flow agents execute steps based on graph structure
|
|
115
|
+
* const flowAgent = new FlowAgentType();
|
|
116
|
+
* const nextStep = await flowAgent.DetermineNextStep(promptResult, payload);
|
|
117
|
+
*
|
|
118
|
+
* // Steps are determined by evaluating path conditions
|
|
119
|
+
* // Path: "payload.status == 'approved' && payload.amount < 1000"
|
|
120
|
+
* // Leads to: "Auto-Approve" step
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
23
123
|
export declare class FlowAgentType extends BaseAgentType {
|
|
24
124
|
private _evaluator;
|
|
25
125
|
private _payloadManager;
|
|
126
|
+
/**
|
|
127
|
+
* Handles the initialization of the flow agent state that is specialized, additional state information
|
|
128
|
+
* specific to the Flow Agent Type
|
|
129
|
+
* @param params
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
26
132
|
InitializeAgentTypeState<ATS = any, P = any>(params: ExecuteAgentParams<any, P>): Promise<ATS>;
|
|
133
|
+
/**
|
|
134
|
+
* Determines the next step based on the flow graph structure.
|
|
135
|
+
*
|
|
136
|
+
* For Flow agents, the next step is determined by:
|
|
137
|
+
* 1. Finding the current position in the graph
|
|
138
|
+
* 2. Evaluating conditions on outgoing paths
|
|
139
|
+
* 3. Following the highest priority valid path
|
|
140
|
+
* 4. Using prompt results only when current step type is 'Prompt'
|
|
141
|
+
*
|
|
142
|
+
* @param {AIPromptRunResult | null} promptResult - Result from prompt execution (null for non-prompt steps)
|
|
143
|
+
* @param {ExecuteAgentParams} params - The full execution parameters
|
|
144
|
+
*
|
|
145
|
+
* @returns {Promise<BaseAgentNextStep<P>>} The next step to execute
|
|
146
|
+
*/
|
|
27
147
|
DetermineNextStep<P = any, ATS = any>(promptResult: AIPromptRunResult | null, params: ExecuteAgentParams<any, P>, payload: P, agentTypeState: ATS): Promise<BaseAgentNextStep<P>>;
|
|
148
|
+
/**
|
|
149
|
+
* Injects flow-specific context into the prompt parameters.
|
|
150
|
+
*
|
|
151
|
+
* @param {P} payload - The payload to inject
|
|
152
|
+
* @param {AIPromptParams} prompt - The prompt parameters to update
|
|
153
|
+
* @param {object} agentInfo - Agent identification info
|
|
154
|
+
*/
|
|
28
155
|
InjectPayload<P = any, ATS = any>(payload: P, agentState: ATS, prompt: AIPromptParams, agentInfo: {
|
|
29
156
|
agentId: string;
|
|
30
157
|
agentRunId?: string;
|
|
31
158
|
}): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Gets all starting steps for an agent
|
|
161
|
+
*
|
|
162
|
+
* @private
|
|
163
|
+
*/
|
|
32
164
|
private getStartingSteps;
|
|
165
|
+
/**
|
|
166
|
+
* Gets a step by ID
|
|
167
|
+
*
|
|
168
|
+
* @private
|
|
169
|
+
*/
|
|
33
170
|
private getStepById;
|
|
171
|
+
/**
|
|
172
|
+
* Gets a step by name within an agent
|
|
173
|
+
*
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
34
176
|
private getStepByName;
|
|
177
|
+
/**
|
|
178
|
+
* Gets all paths from a step and evaluates their conditions.
|
|
179
|
+
*
|
|
180
|
+
* The evaluation context includes:
|
|
181
|
+
* - payload: The current agent payload (persistent state)
|
|
182
|
+
* - stepResult: Result from the last executed step
|
|
183
|
+
* - flowContext: Flow execution metadata (current step, completed steps, path)
|
|
184
|
+
* - data: Transient template data from ExecuteAgentParams (NEW in Phase 1)
|
|
185
|
+
* - context: Runtime context from ExecuteAgentParams (NEW in Phase 1)
|
|
186
|
+
*
|
|
187
|
+
* This allows path conditions to access runtime parameters like:
|
|
188
|
+
* - `data.userApproval === true`
|
|
189
|
+
* - `context.environment === 'production'`
|
|
190
|
+
* - `data.retryCount < 3 && payload.status === 'pending'`
|
|
191
|
+
*
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
35
194
|
private getValidPaths;
|
|
195
|
+
/**
|
|
196
|
+
* Gets the last step result from the flow context
|
|
197
|
+
*
|
|
198
|
+
* @private
|
|
199
|
+
*/
|
|
36
200
|
private getLastStepResult;
|
|
201
|
+
/**
|
|
202
|
+
* Helper to set a value on a target object, supporting array append syntax.
|
|
203
|
+
* If key ends with '[]', the value is pushed to an array (auto-initialized if needed).
|
|
204
|
+
*
|
|
205
|
+
* @private
|
|
206
|
+
*/
|
|
37
207
|
private setMappedValue;
|
|
208
|
+
/**
|
|
209
|
+
* Applies action output mapping to update the payload and extract special fields.
|
|
210
|
+
*
|
|
211
|
+
* Special fields ($message, $reasoning, $confidence) are prefixed with $ and are not
|
|
212
|
+
* added to the payload. Instead, they are stored separately in FlowExecutionState
|
|
213
|
+
* for use in the final response.
|
|
214
|
+
*
|
|
215
|
+
* @private
|
|
216
|
+
* @returns Object with payloadChange and specialFields
|
|
217
|
+
*/
|
|
38
218
|
private applyActionOutputMapping;
|
|
219
|
+
/**
|
|
220
|
+
* Creates a BaseAgentNextStep for a flow node.
|
|
221
|
+
*
|
|
222
|
+
* If the node is in agentTypeParams.skipSteps, the step is marked as skipped
|
|
223
|
+
* and we immediately evaluate paths to find the next step.
|
|
224
|
+
*
|
|
225
|
+
* @private
|
|
226
|
+
*/
|
|
39
227
|
private createStepForFlowNode;
|
|
228
|
+
/**
|
|
229
|
+
* Gets action name by ID
|
|
230
|
+
*
|
|
231
|
+
* @private
|
|
232
|
+
*/
|
|
40
233
|
private getActionName;
|
|
234
|
+
/**
|
|
235
|
+
* Gets agent name by ID
|
|
236
|
+
*
|
|
237
|
+
* @private
|
|
238
|
+
*/
|
|
41
239
|
private getAgentName;
|
|
240
|
+
/**
|
|
241
|
+
* Processes action results and applies output mapping if configured
|
|
242
|
+
* This should be called by BaseAgent after action execution
|
|
243
|
+
*
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
42
246
|
processActionResult<P>(actionResult: Record<string, unknown>, _stepId: string, outputMapping?: string, currentPayload?: P): AgentPayloadChangeRequest<P> | null;
|
|
247
|
+
/**
|
|
248
|
+
* Override of BaseAgentType's PreProcessActionStep to handle Flow-specific input mapping.
|
|
249
|
+
*
|
|
250
|
+
* This method checks if the current step has action input mapping configured
|
|
251
|
+
* and applies it to map payload values or static values to action input parameters.
|
|
252
|
+
*
|
|
253
|
+
* @override
|
|
254
|
+
* @param {AgentAction[]} actions - The actions that will be executed (modified in place)
|
|
255
|
+
* @param {P} currentPayload - The current payload
|
|
256
|
+
* @param {BaseAgentNextStep<P>} currentStep - The current step being executed
|
|
257
|
+
*
|
|
258
|
+
* @returns {Promise<void>} Actions are modified in place
|
|
259
|
+
*
|
|
260
|
+
* @since 2.76.0
|
|
261
|
+
*/
|
|
43
262
|
PreProcessActionStep<P = any, ATS = any>(actions: AgentAction[], currentPayload: P, agentTypeState: ATS, currentStep: BaseAgentNextStep<P>, params?: ExecuteAgentParams<P>): Promise<void>;
|
|
263
|
+
/**
|
|
264
|
+
* Helper method to get a value from a nested object path
|
|
265
|
+
* Supports both dot notation (obj.prop) and array indexing (arr[0])
|
|
266
|
+
*
|
|
267
|
+
* @private
|
|
268
|
+
*/
|
|
44
269
|
private getValueFromPath;
|
|
270
|
+
/**
|
|
271
|
+
* Recursively resolves payload, static, data, context, and conversation references in nested objects.
|
|
272
|
+
*
|
|
273
|
+
* Supported prefixes:
|
|
274
|
+
* - `payload.path.to.value` - reads from persistent payload
|
|
275
|
+
* - `static:value` - literal static value
|
|
276
|
+
* - `data.path.to.value` - reads from params.data (template data)
|
|
277
|
+
* - `context.path.to.value` - reads from params.context (runtime context, e.g., API keys, environment)
|
|
278
|
+
* - `conversation[N].content` - reads from conversation messages
|
|
279
|
+
*
|
|
280
|
+
* @private
|
|
281
|
+
*/
|
|
45
282
|
private resolveNestedValue;
|
|
283
|
+
/**
|
|
284
|
+
* Override of BaseAgentType's PostProcessActionStep to handle Flow-specific logic.
|
|
285
|
+
*
|
|
286
|
+
* This method checks if the current step has action output mapping configured
|
|
287
|
+
* and applies it to update the payload accordingly.
|
|
288
|
+
*
|
|
289
|
+
* @override
|
|
290
|
+
* @param {ActionResult[]} actionResults - The results from action execution
|
|
291
|
+
* @param {AgentAction[]} actions - The actions that were executed
|
|
292
|
+
* @param {P} currentPayload - The current payload
|
|
293
|
+
* @param {BaseAgentNextStep<P>} currentStep - The current step being executed
|
|
294
|
+
*
|
|
295
|
+
* @returns {Promise<AgentPayloadChangeRequest<P> | null>} Payload changes from output mapping
|
|
296
|
+
*/
|
|
46
297
|
PostProcessActionStep<P = any, ATS = any>(actionResults: ActionResult[], actions: AgentAction[], currentPayload: P, agentTypeState: ATS, currentStep: BaseAgentNextStep<P>): Promise<AgentPayloadChangeRequest<P> | null>;
|
|
298
|
+
/**
|
|
299
|
+
* Determines the initial step for flow agent types.
|
|
300
|
+
*
|
|
301
|
+
* Flow agents look up their configured starting step instead of executing a prompt.
|
|
302
|
+
* If agentTypeParams.startAtStep is provided, the flow will begin at that step
|
|
303
|
+
* instead of the configured entry point.
|
|
304
|
+
*
|
|
305
|
+
* @param {ExecuteAgentParams} params - The full execution parameters
|
|
306
|
+
* @returns {Promise<BaseAgentNextStep<P> | null>} The initial step to execute, or null if flow context not ready
|
|
307
|
+
*
|
|
308
|
+
* @override
|
|
309
|
+
* @since 2.76.0
|
|
310
|
+
*/
|
|
47
311
|
DetermineInitialStep<P = any, ATS = any>(params: ExecuteAgentParams<P>, payload: P, agentTypeState: ATS): Promise<BaseAgentNextStep<P> | null>;
|
|
312
|
+
/**
|
|
313
|
+
* Pre-processes steps for flow agent types.
|
|
314
|
+
*
|
|
315
|
+
* For Flow agents, 'Retry' after actions means evaluate paths from the current step
|
|
316
|
+
* and continue the flow based on the updated payload. The only exception is when
|
|
317
|
+
* executing a Prompt step within the flow, which should execute normally.
|
|
318
|
+
*
|
|
319
|
+
* Also, 'Success' steps after sub-agents need to be evaluated in the same way as Retry after actions
|
|
320
|
+
*
|
|
321
|
+
* @param {ExecuteAgentParams} params - The full execution parameters
|
|
322
|
+
* @param {BaseAgentNextStep} step - The retry step that was returned
|
|
323
|
+
* @param {P} payload - The current payload
|
|
324
|
+
* @param {ATS} agentTypeState - The current agent type state
|
|
325
|
+
* @returns {Promise<BaseAgentNextStep<P> | null>} The next flow step, or null for prompt execution
|
|
326
|
+
*
|
|
327
|
+
* @override
|
|
328
|
+
* @since 2.76.0
|
|
329
|
+
*/
|
|
48
330
|
PreProcessNextStep<P = any, ATS = any>(params: ExecuteAgentParams<P>, step: BaseAgentNextStep<P>, payload: P, agentTypeState: ATS): Promise<BaseAgentNextStep<P> | null>;
|
|
331
|
+
/**
|
|
332
|
+
* Gets the prompt to use for a specific step.
|
|
333
|
+
* Flow agents may use different prompts for different steps in the flow.
|
|
334
|
+
*
|
|
335
|
+
* @param {ExecuteAgentParams} params - The execution parameters
|
|
336
|
+
* @param {AgentConfiguration} config - The loaded agent configuration
|
|
337
|
+
* @param {BaseAgentNextStep | null} previousDecision - The previous step decision that may contain flow prompt info
|
|
338
|
+
* @returns {Promise<AIPromptEntityExtended | null>} Custom prompt for flow steps, or default config.childPrompt
|
|
339
|
+
*
|
|
340
|
+
* @override
|
|
341
|
+
* @since 2.76.0
|
|
342
|
+
*/
|
|
49
343
|
GetPromptForStep<P = any, ATS = any>(params: ExecuteAgentParams, config: AgentConfiguration, payload: P, agentTypeState: ATS, previousDecision?: BaseAgentNextStep<P> | null): Promise<AIPromptEntityExtended | null>;
|
|
344
|
+
/**
|
|
345
|
+
* Converts a Flow Agent ForEach step into universal ForEachOperation format
|
|
346
|
+
* that BaseAgent can execute
|
|
347
|
+
*/
|
|
50
348
|
private convertForEachStepToOperation;
|
|
349
|
+
/**
|
|
350
|
+
* Converts a Flow Agent While step into universal WhileOperation format
|
|
351
|
+
* that BaseAgent can execute
|
|
352
|
+
*/
|
|
51
353
|
private convertWhileStepToOperation;
|
|
354
|
+
/**
|
|
355
|
+
* Flow agents don't need loop results injected as messages - they navigate paths
|
|
356
|
+
* @override
|
|
357
|
+
*/
|
|
52
358
|
get InjectLoopResultsAsMessage(): boolean;
|
|
359
|
+
/**
|
|
360
|
+
* Flow agents don't require agent-level prompts - they use step-level prompts exclusively
|
|
361
|
+
* @override
|
|
362
|
+
*/
|
|
53
363
|
get RequiresAgentLevelPrompts(): boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Provides Flow-specific guidance for prompt configuration
|
|
366
|
+
* @override
|
|
367
|
+
*/
|
|
54
368
|
GetPromptConfigurationGuidance(): string;
|
|
369
|
+
/**
|
|
370
|
+
* Flow agents should NEVER fall back to prompt execution for Success/Failed steps.
|
|
371
|
+
* Flow agents are deterministic and driven by their graph structure (steps and paths).
|
|
372
|
+
* When a step completes (Success or Failed), the agent should terminate rather than
|
|
373
|
+
* retry with prompts.
|
|
374
|
+
*
|
|
375
|
+
* @override
|
|
376
|
+
* @since 2.113.0
|
|
377
|
+
*/
|
|
55
378
|
HandleStepFallback<P = any, ATS = any>(step: BaseAgentNextStep<P>, config: AgentConfiguration, params: ExecuteAgentParams<P>, payload: P, agentTypeState: ATS): Promise<BaseAgentNextStep<P> | null>;
|
|
379
|
+
/**
|
|
380
|
+
* Flow agents apply ActionOutputMapping after each iteration
|
|
381
|
+
* @override
|
|
382
|
+
*/
|
|
56
383
|
AfterLoopIteration<P>(iterationResult: {
|
|
57
384
|
actionResults?: ActionResult[];
|
|
58
385
|
subAgentResult?: any;
|
|
@@ -63,5 +390,4 @@ export declare class FlowAgentType extends BaseAgentType {
|
|
|
63
390
|
loopContext: any;
|
|
64
391
|
}): P | null;
|
|
65
392
|
}
|
|
66
|
-
export declare function LoadFlowAgentType(): void;
|
|
67
393
|
//# sourceMappingURL=flow-agent-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/flow-agent-type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flow-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/flow-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,yBAAyB,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAoC,MAAM,8BAA8B,CAAC;AAEtN,OAAO,EAAE,iBAAiB,EAAyB,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAc5D;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAC3B,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAEhB,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,gCAAgC;IAChC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAE1C,qCAAqC;IACrC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAa;IAE9C,kDAAkD;IAClD,aAAa,EAAE,MAAM,EAAE,CAAM;IAE7B,kFAAkF;IAClF,aAAa,CAAC,EAAE;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;gBAEU,OAAO,EAAE,MAAM;CAG9B;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,sBAA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