@memberjunction/ai-agents 2.74.0 → 2.76.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 +146 -0
- package/dist/agent-types/base-agent-type.d.ts +19 -3
- package/dist/agent-types/base-agent-type.d.ts.map +1 -1
- package/dist/agent-types/base-agent-type.js +55 -0
- package/dist/agent-types/base-agent-type.js.map +1 -1
- package/dist/agent-types/flow-agent-type.d.ts +38 -0
- package/dist/agent-types/flow-agent-type.d.ts.map +1 -0
- package/dist/agent-types/flow-agent-type.js +462 -0
- package/dist/agent-types/flow-agent-type.js.map +1 -0
- package/dist/agent-types/index.d.ts +1 -0
- package/dist/agent-types/index.d.ts.map +1 -1
- package/dist/agent-types/index.js +3 -0
- package/dist/agent-types/index.js.map +1 -1
- package/dist/agent-types/loop-agent-type.d.ts +8 -5
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-type.js +22 -54
- package/dist/agent-types/loop-agent-type.js.map +1 -1
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +114 -36
- package/dist/base-agent.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -35,6 +35,14 @@ Concrete implementation of BaseAgentType that:
|
|
|
35
35
|
- Parses structured JSON responses from prompts
|
|
36
36
|
- Supports actions, sub-agents, and conditional termination
|
|
37
37
|
|
|
38
|
+
### FlowAgentType
|
|
39
|
+
Deterministic workflow agent type that:
|
|
40
|
+
- Executes predefined workflows using directed graphs
|
|
41
|
+
- Evaluates boolean conditions to determine paths
|
|
42
|
+
- Supports parallel starting steps (Sequence=0)
|
|
43
|
+
- Provides action output mapping to payload
|
|
44
|
+
- Enables hybrid AI/deterministic workflows
|
|
45
|
+
|
|
38
46
|
### AgentRunner
|
|
39
47
|
Simple orchestrator that:
|
|
40
48
|
- Loads agent metadata from database
|
|
@@ -109,6 +117,16 @@ Agents are configured through MemberJunction entities:
|
|
|
109
117
|
- `ExecutionOrder`: Determines prompt execution sequence
|
|
110
118
|
- Links agents to their specific prompts
|
|
111
119
|
|
|
120
|
+
5. **AIAgentStep**: Defines workflow steps for Flow agents
|
|
121
|
+
- `StepType`: Action, Sub-Agent, or Prompt
|
|
122
|
+
- `StartingStep`: Boolean flag for initial steps
|
|
123
|
+
- `TimeoutSeconds`: Step execution timeout
|
|
124
|
+
- `ActionOutputMapping`: JSON mapping for action results
|
|
125
|
+
|
|
126
|
+
6. **AIAgentStepPath**: Connects workflow steps
|
|
127
|
+
- `Condition`: Boolean expression for path evaluation
|
|
128
|
+
- `Priority`: Determines path selection order
|
|
129
|
+
|
|
112
130
|
## Creating Custom Agent Types
|
|
113
131
|
|
|
114
132
|
```typescript
|
|
@@ -631,6 +649,134 @@ export class DecisionTreeAgent extends BaseAgentType {
|
|
|
631
649
|
}
|
|
632
650
|
```
|
|
633
651
|
|
|
652
|
+
### Flow Agent Configuration
|
|
653
|
+
|
|
654
|
+
Flow agents enable deterministic workflow execution through graph-based step definitions:
|
|
655
|
+
|
|
656
|
+
```typescript
|
|
657
|
+
// Database configuration for a Flow agent workflow
|
|
658
|
+
// AIAgentStep records define the workflow nodes
|
|
659
|
+
const approvalWorkflowSteps = [
|
|
660
|
+
{
|
|
661
|
+
Name: 'CheckAmount',
|
|
662
|
+
StepType: 'Action',
|
|
663
|
+
ActionID: checkAmountActionId,
|
|
664
|
+
StartingStep: true,
|
|
665
|
+
Sequence: 0
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
Name: 'AutoApprove',
|
|
669
|
+
StepType: 'Action',
|
|
670
|
+
ActionID: approveActionId,
|
|
671
|
+
ActionOutputMapping: JSON.stringify({
|
|
672
|
+
'approvalId': 'payload.approval.id',
|
|
673
|
+
'timestamp': 'payload.approval.approvedAt'
|
|
674
|
+
})
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
Name: 'ManagerReview',
|
|
678
|
+
StepType: 'Prompt',
|
|
679
|
+
PromptID: managerReviewPromptId,
|
|
680
|
+
Description: 'Get manager approval decision'
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
Name: 'NotifyRejection',
|
|
684
|
+
StepType: 'Action',
|
|
685
|
+
ActionID: sendNotificationActionId
|
|
686
|
+
}
|
|
687
|
+
];
|
|
688
|
+
|
|
689
|
+
// AIAgentStepPath records define the workflow edges
|
|
690
|
+
const approvalWorkflowPaths = [
|
|
691
|
+
{
|
|
692
|
+
OriginStepID: checkAmountStep.ID,
|
|
693
|
+
DestinationStepID: autoApproveStep.ID,
|
|
694
|
+
Condition: 'payload.amount <= 1000',
|
|
695
|
+
Priority: 10
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
OriginStepID: checkAmountStep.ID,
|
|
699
|
+
DestinationStepID: managerReviewStep.ID,
|
|
700
|
+
Condition: 'payload.amount > 1000',
|
|
701
|
+
Priority: 10
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
OriginStepID: managerReviewStep.ID,
|
|
705
|
+
DestinationStepID: autoApproveStep.ID,
|
|
706
|
+
Condition: 'stepResult.approved === true',
|
|
707
|
+
Priority: 10
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
OriginStepID: managerReviewStep.ID,
|
|
711
|
+
DestinationStepID: notifyRejectionStep.ID,
|
|
712
|
+
Condition: 'stepResult.approved === false',
|
|
713
|
+
Priority: 10
|
|
714
|
+
}
|
|
715
|
+
];
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
### Flow Agent Features
|
|
719
|
+
|
|
720
|
+
#### Safe Expression Evaluation
|
|
721
|
+
Flow agents use the SafeExpressionEvaluator to securely evaluate path conditions without arbitrary code execution:
|
|
722
|
+
|
|
723
|
+
```typescript
|
|
724
|
+
// Supported operations in conditions:
|
|
725
|
+
// - Comparisons: ==, ===, !=, !==, <, >, <=, >=
|
|
726
|
+
// - Logical: &&, ||, !
|
|
727
|
+
// - Property access: payload.user.role, stepResult.score
|
|
728
|
+
// - Safe methods: .includes(), .length, .some(), .every()
|
|
729
|
+
// - Type checking: typeof
|
|
730
|
+
|
|
731
|
+
// Example conditions:
|
|
732
|
+
"payload.status == 'approved' && payload.priority > 5"
|
|
733
|
+
"stepResult.items.some(item => item.price > 100)"
|
|
734
|
+
"payload.user.roles.includes('admin') || payload.override === true"
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
#### Action Output Mapping
|
|
738
|
+
Automatically map action results to the payload:
|
|
739
|
+
|
|
740
|
+
```typescript
|
|
741
|
+
// In AIAgentStep.ActionOutputMapping
|
|
742
|
+
{
|
|
743
|
+
"userId": "payload.customer.id", // Map specific output
|
|
744
|
+
"orderTotal": "payload.order.total", // Nested path mapping
|
|
745
|
+
"*": "payload.actionResults.lastResult" // Wildcard for entire result
|
|
746
|
+
}
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
#### Flow Context Tracking
|
|
750
|
+
The framework maintains flow execution state in `__flowContext`:
|
|
751
|
+
|
|
752
|
+
```typescript
|
|
753
|
+
// Automatically tracked in payload.__flowContext
|
|
754
|
+
{
|
|
755
|
+
agentId: "flow-agent-id",
|
|
756
|
+
currentStepId: "current-step-id",
|
|
757
|
+
completedStepIds: ["step1", "step2"],
|
|
758
|
+
stepResults: {
|
|
759
|
+
"step1": { success: true, data: {...} },
|
|
760
|
+
"step2": { approved: false }
|
|
761
|
+
},
|
|
762
|
+
executionPath: ["step1", "step2", "step3"]
|
|
763
|
+
}
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
#### Prompt Steps for AI Decisions
|
|
767
|
+
Flow agents can incorporate AI decision points:
|
|
768
|
+
|
|
769
|
+
```typescript
|
|
770
|
+
// Prompt step expects response format:
|
|
771
|
+
{
|
|
772
|
+
"nextStepName?": "StepToExecute",
|
|
773
|
+
"reasoning?": "Why this decision was made",
|
|
774
|
+
"confidence?": 0.95,
|
|
775
|
+
"terminate?": false,
|
|
776
|
+
"message?": "Decision explanation"
|
|
777
|
+
}
|
|
778
|
+
```
|
|
779
|
+
|
|
634
780
|
## Architecture Documentation
|
|
635
781
|
|
|
636
782
|
For detailed architecture information, see [agent-architecture.md](./agent-architecture.md).
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import { AIPromptParams, AIPromptRunResult, BaseAgentNextStep } from '@memberjunction/ai-core-plus';
|
|
1
|
+
import { AIPromptParams, AIPromptRunResult, BaseAgentNextStep, AgentPayloadChangeRequest, AgentAction, AgentSubAgentRequest, ExecuteAgentParams } from '@memberjunction/ai-core-plus';
|
|
2
2
|
import { AIAgentTypeEntity } from '@memberjunction/core-entities';
|
|
3
|
+
import { JSONValidator } from '@memberjunction/global';
|
|
4
|
+
import { ActionResult } from '@memberjunction/actions-base';
|
|
3
5
|
export declare abstract class BaseAgentType {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
protected _jsonValidator: JSONValidator;
|
|
7
|
+
static readonly CURRENT_PAYLOAD_PLACEHOLDER = "_CURRENT_PAYLOAD";
|
|
8
|
+
abstract DetermineNextStep<P = any>(promptResult: AIPromptRunResult | null, params: ExecuteAgentParams<any, P>): Promise<BaseAgentNextStep<P>>;
|
|
9
|
+
abstract DetermineInitialStep<P = any>(params: ExecuteAgentParams<P>): Promise<BaseAgentNextStep<P> | null>;
|
|
10
|
+
abstract PreProcessRetryStep<P = any>(params: ExecuteAgentParams<P>, retryStep: BaseAgentNextStep<P>): Promise<BaseAgentNextStep<P> | null>;
|
|
11
|
+
abstract InjectPayload<P = any>(payload: P, prompt: AIPromptParams, agentInfo: {
|
|
12
|
+
agentId: string;
|
|
13
|
+
agentRunId?: string;
|
|
14
|
+
}): Promise<void>;
|
|
6
15
|
static GetAgentTypeInstance(agentType: AIAgentTypeEntity): Promise<BaseAgentType>;
|
|
7
16
|
protected static getAgentTypeInstance(agentType: AIAgentTypeEntity): Promise<BaseAgentType | null>;
|
|
8
17
|
protected static getAgentInstanceWithDriverClass(driverClass: string): Promise<BaseAgentType | null>;
|
|
18
|
+
protected parseJSONResponse<T>(promptResult: AIPromptRunResult): T | null;
|
|
19
|
+
protected createNextStep<P>(step: BaseAgentNextStep['step'], options?: Partial<BaseAgentNextStep<P>>): BaseAgentNextStep<P>;
|
|
20
|
+
protected createRetryStep<P>(errorMessage: string, options?: Partial<BaseAgentNextStep<P>>): BaseAgentNextStep<P>;
|
|
21
|
+
protected createSuccessStep<P>(options?: Partial<BaseAgentNextStep<P>>): BaseAgentNextStep<P>;
|
|
22
|
+
PreProcessActionStep<P>(actions: AgentAction[], currentPayload: P, currentStep: BaseAgentNextStep<P>): Promise<void>;
|
|
23
|
+
PostProcessActionStep<P>(actionResults: ActionResult[], actions: AgentAction[], currentPayload: P, currentStep: BaseAgentNextStep<P>): Promise<AgentPayloadChangeRequest<P> | null>;
|
|
24
|
+
PostProcessSubAgentStep<P>(subAgentResult: any, subAgentRequest: AgentSubAgentRequest, currentPayload: P, currentStep: BaseAgentNextStep<P>): Promise<AgentPayloadChangeRequest<P> | null>;
|
|
9
25
|
}
|
|
10
26
|
//# sourceMappingURL=base-agent-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"base-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,WAAW,EAAE,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AACrL,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAY,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAoC5D,8BAAs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C,EAC/B,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAM,GAC5C,iBAAiB,CAAC,CAAC,CAAC;IAmBvB,SAAS,CAAC,eAAe,CAAC,CAAC,EACvB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAM,GAC5C,iBAAiB,CAAC,CAAC,CAAC;IAkBvB,SAAS,CAAC,iBAAiB,CAAC,CAAC,EACzB,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAM,GAC5C,iBAAiB,CAAC,CAAC,CAAC;IAsBV,oBAAoB,CAAC,CAAC,EAC/B,OAAO,EAAE,WAAW,EAAE,EACtB,cAAc,EAAE,CAAC,EACjB,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC;IAqBH,qBAAqB,CAAC,CAAC,EAChC,aAAa,EAAE,YAAY,EAAE,EAC7B,OAAO,EAAE,WAAW,EAAE,EACtB,cAAc,EAAE,CAAC,EACjB,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAClC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAsBlC,uBAAuB,CAAC,CAAC,EAClC,cAAc,EAAE,GAAG,EACnB,eAAe,EAAE,oBAAoB,EACrC,cAAc,EAAE,CAAC,EACjB,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAClC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAKlD"}
|
|
@@ -4,6 +4,9 @@ exports.BaseAgentType = void 0;
|
|
|
4
4
|
const global_1 = require("@memberjunction/global");
|
|
5
5
|
const core_1 = require("@memberjunction/core");
|
|
6
6
|
class BaseAgentType {
|
|
7
|
+
constructor() {
|
|
8
|
+
this._jsonValidator = new global_1.JSONValidator();
|
|
9
|
+
}
|
|
7
10
|
static async GetAgentTypeInstance(agentType) {
|
|
8
11
|
try {
|
|
9
12
|
const agentTypeInstance = await this.getAgentTypeInstance(agentType);
|
|
@@ -30,6 +33,58 @@ class BaseAgentType {
|
|
|
30
33
|
}
|
|
31
34
|
return instance;
|
|
32
35
|
}
|
|
36
|
+
parseJSONResponse(promptResult) {
|
|
37
|
+
if (!promptResult.success || !promptResult.result) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
let response;
|
|
42
|
+
if (typeof promptResult.result === 'string') {
|
|
43
|
+
response = JSON.parse(promptResult.result);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
response = promptResult.result;
|
|
47
|
+
}
|
|
48
|
+
response = this._jsonValidator.cleanValidationSyntax(response);
|
|
49
|
+
if ((0, core_1.IsVerboseLoggingEnabled)()) {
|
|
50
|
+
console.log(`${this.constructor.name}: Cleaned response from validation syntax`, response);
|
|
51
|
+
}
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
(0, core_1.LogError)(`Failed to parse JSON response in ${this.constructor.name}: ${error.message}`);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
createNextStep(step, options = {}) {
|
|
60
|
+
return {
|
|
61
|
+
step,
|
|
62
|
+
terminate: false,
|
|
63
|
+
...options
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
createRetryStep(errorMessage, options = {}) {
|
|
67
|
+
return this.createNextStep('Retry', {
|
|
68
|
+
errorMessage,
|
|
69
|
+
terminate: false,
|
|
70
|
+
...options
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
createSuccessStep(options = {}) {
|
|
74
|
+
return this.createNextStep('Success', {
|
|
75
|
+
terminate: true,
|
|
76
|
+
...options
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async PreProcessActionStep(actions, currentPayload, currentStep) {
|
|
80
|
+
}
|
|
81
|
+
async PostProcessActionStep(actionResults, actions, currentPayload, currentStep) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
async PostProcessSubAgentStep(subAgentResult, subAgentRequest, currentPayload, currentStep) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
33
87
|
}
|
|
34
88
|
exports.BaseAgentType = BaseAgentType;
|
|
89
|
+
BaseAgentType.CURRENT_PAYLOAD_PLACEHOLDER = '_CURRENT_PAYLOAD';
|
|
35
90
|
//# sourceMappingURL=base-agent-type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-agent-type.js","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":";;;AAeA,
|
|
1
|
+
{"version":3,"file":"base-agent-type.js","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":";;;AAeA,mDAAiE;AACjE,+CAAyE;AAqCzE,MAAsB,aAAa;IAAnC;QAKc,mBAAc,GAAkB,IAAI,sBAAa,EAAE,CAAC;IAwWlE,CAAC;IAlPU,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,SAA4B;QACjE,IAAI,CAAC;YACD,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;YACrE,OAAO,iBAAiB,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAA,eAAQ,EAAC,KAAK,CAAC,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,yCAAyC,SAAS,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjG,CAAC;IACL,CAAC;IAoBS,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,SAA4B;QAEpE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,eAAe,SAAS,CAAC,IAAI,+FAA+F,CAAC,CAAC;QAClJ,CAAC;QAGD,OAAO,IAAI,CAAC,+BAA+B,C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AAI,CAAC,WAAW,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACxF,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAaS,cAAc,CACpB,IAA+B,EAC/B,UAAyC,EAAE;QAE3C,OAAO;YACH,IAAI;YACJ,SAAS,EAAE,KAAK;YAChB,GAAG,OAAO;SACW,CAAC;IAC9B,CAAC;IAaS,eAAe,CACrB,YAAoB,EACpB,UAAyC,EAAE;QAE3C,OAAO,IAAI,CAAC,cAAc,CAAI,OAAO,EAAE;YACnC,YAAY;YACZ,SAAS,EAAE,KAAK;YAChB,GAAG,OAAO;SACb,CAAC,CAAC;IACP,CAAC;IAYS,iBAAiB,CACvB,UAAyC,EAAE;QAE3C,OAAO,IAAI,CAAC,cAAc,CAAI,SAAS,EAAE;YACrC,SAAS,EAAE,IAAI;YACf,GAAG,OAAO;SACb,CAAC,CAAC;IACP,CAAC;IAiBM,KAAK,CAAC,oBAAoB,CAC7B,OAAsB,EACtB,cAAiB,EACjB,WAAiC;IAIrC,CAAC;IAkBM,KAAK,CAAC,qBAAqB,CAC9B,aAA6B,EAC7B,OAAsB,EACtB,cAAiB,EACjB,WAAiC;QAIjC,OAAO,IAAI,CAAC;IAChB,CAAC;IAkBM,KAAK,CAAC,uBAAuB,CAChC,cAAmB,EACnB,eAAqC,EACrC,cAAiB,EACjB,WAAiC;QAIjC,OAAO,IAAI,CAAC;IAChB,CAAC;;AA5WL,sCA6WC;AAlW0B,yCAA2B,GAAG,kBAAkB,AAArB,CAAsB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BaseAgentType } from './base-agent-type';
|
|
2
|
+
import { AIPromptRunResult, BaseAgentNextStep, AIPromptParams, AgentPayloadChangeRequest, AgentAction, ExecuteAgentParams } from '@memberjunction/ai-core-plus';
|
|
3
|
+
import { ActionResult } from '@memberjunction/actions-base';
|
|
4
|
+
export declare class FlowExecutionState {
|
|
5
|
+
agentId: string;
|
|
6
|
+
currentStepId?: string;
|
|
7
|
+
completedStepIds: Set<string>;
|
|
8
|
+
stepResults: Map<string, unknown>;
|
|
9
|
+
executionPath: string[];
|
|
10
|
+
constructor(agentId: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class FlowAgentType extends BaseAgentType {
|
|
13
|
+
private _evaluator;
|
|
14
|
+
private static _flowStates;
|
|
15
|
+
private getOrCreateFlowState;
|
|
16
|
+
DetermineNextStep<P>(promptResult: AIPromptRunResult | null, params: ExecuteAgentParams<any, P>): Promise<BaseAgentNextStep<P>>;
|
|
17
|
+
InjectPayload<P = any>(payload: P, prompt: AIPromptParams, agentInfo: {
|
|
18
|
+
agentId: string;
|
|
19
|
+
agentRunId?: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
private getStartingSteps;
|
|
22
|
+
private getStepById;
|
|
23
|
+
private getStepByName;
|
|
24
|
+
private getValidPaths;
|
|
25
|
+
private getLastStepResult;
|
|
26
|
+
private applyActionOutputMapping;
|
|
27
|
+
private createStepForFlowNode;
|
|
28
|
+
private getActionName;
|
|
29
|
+
private getAgentName;
|
|
30
|
+
processActionResult<P>(actionResult: Record<string, unknown>, _stepId: string, outputMapping?: string, currentPayload?: P): AgentPayloadChangeRequest<P> | null;
|
|
31
|
+
PreProcessActionStep<P>(actions: AgentAction[], currentPayload: P, currentStep: BaseAgentNextStep<P>): Promise<void>;
|
|
32
|
+
private getValueFromPath;
|
|
33
|
+
PostProcessActionStep<P>(actionResults: ActionResult[], _actions: AgentAction[], currentPayload: P, currentStep: BaseAgentNextStep<P>): Promise<AgentPayloadChangeRequest<P> | null>;
|
|
34
|
+
DetermineInitialStep<P = any>(params: ExecuteAgentParams<P>): Promise<BaseAgentNextStep<P> | null>;
|
|
35
|
+
PreProcessRetryStep<P = any>(params: ExecuteAgentParams<P>, retryStep: BaseAgentNextStep<P>): Promise<BaseAgentNextStep<P> | null>;
|
|
36
|
+
}
|
|
37
|
+
export declare function LoadFlowAgentType(): void;
|
|
38
|
+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