@memberjunction/aiengine 2.50.0 → 2.51.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 +54 -1
- package/dist/agent-types.d.ts +126 -0
- package/dist/agent-types.d.ts.map +1 -0
- package/dist/agent-types.js +3 -0
- package/dist/agent-types.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -9,9 +9,21 @@ The MemberJunction AI Engine package provides a comprehensive framework for AI-p
|
|
|
9
9
|
- **📊 Performance Monitoring**: Basic tracking and analytics for AI operations
|
|
10
10
|
- **🔗 Entity Integration**: Seamless integration with MemberJunction entity system
|
|
11
11
|
- **⚡ Simple Prompt Execution**: Basic prompt execution for quick AI tasks
|
|
12
|
+
- **🏗️ Agent Type System**: Defines agent types and their behavioral characteristics
|
|
12
13
|
|
|
13
14
|
> **📝 Advanced Prompt Management**: For sophisticated stored prompt management, template rendering, and parallel execution capabilities, see the [@memberjunction/ai-prompts](../Prompts/README.md) package.
|
|
14
15
|
|
|
16
|
+
### Type Organization Update (2025)
|
|
17
|
+
|
|
18
|
+
As part of improving code organization:
|
|
19
|
+
- **This package** now contains:
|
|
20
|
+
- Extended entity classes for AI operations
|
|
21
|
+
- Agent type definitions and factory interfaces
|
|
22
|
+
- The new `agent-types.ts` file with agent type classes
|
|
23
|
+
- **Base AI types** are imported from `@memberjunction/ai` (Core)
|
|
24
|
+
- **Agent execution types** are imported from `@memberjunction/ai-agents`
|
|
25
|
+
- **Prompt types** are imported from `@memberjunction/ai-prompts`
|
|
26
|
+
|
|
15
27
|
## Installation
|
|
16
28
|
|
|
17
29
|
```bash
|
|
@@ -22,6 +34,7 @@ npm install @memberjunction/aiengine
|
|
|
22
34
|
|
|
23
35
|
- Node.js 16+
|
|
24
36
|
- MemberJunction Core libraries
|
|
37
|
+
- [@memberjunction/ai](../Core/README.md) for base AI types
|
|
25
38
|
- At least one AI model provider (e.g., `@memberjunction/ai-openai`)
|
|
26
39
|
|
|
27
40
|
## Core Architecture
|
|
@@ -190,6 +203,23 @@ class AIPromptCategoryEntityExtended extends AIPromptCategoryEntity {
|
|
|
190
203
|
|
|
191
204
|
The AI Engine automatically extends AI Model entities with additional capabilities from the AI provider system. These extended models include all driver-specific functionality and API integration.
|
|
192
205
|
|
|
206
|
+
### Agent Type System
|
|
207
|
+
|
|
208
|
+
The Engine now includes specialized agent type classes in `agent-types.ts`:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// Base agent type - foundation for all agent types
|
|
212
|
+
import { BaseAgentType } from '@memberjunction/aiengine';
|
|
213
|
+
|
|
214
|
+
// Specialized agent types
|
|
215
|
+
import { LoopAgentType } from '@memberjunction/aiengine';
|
|
216
|
+
|
|
217
|
+
// Agent types define behavioral characteristics:
|
|
218
|
+
// - System prompts for consistent behavior
|
|
219
|
+
// - Decision-making patterns
|
|
220
|
+
// - Execution flow control
|
|
221
|
+
```
|
|
222
|
+
|
|
193
223
|
|
|
194
224
|
## Advanced Features
|
|
195
225
|
|
|
@@ -267,12 +297,35 @@ const response = await AIEngine.Instance.SimpleLLMCompletion(
|
|
|
267
297
|
|
|
268
298
|
For sophisticated parallel execution, template rendering, and stored prompt management, see the [@memberjunction/ai-prompts](../Prompts/README.md) package.
|
|
269
299
|
|
|
300
|
+
## Import Examples
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
// Import main AI Engine class
|
|
304
|
+
import { AIEngine } from '@memberjunction/aiengine';
|
|
305
|
+
|
|
306
|
+
// Import extended entity types
|
|
307
|
+
import {
|
|
308
|
+
AIAgentEntityExtended,
|
|
309
|
+
AIPromptCategoryEntityExtended,
|
|
310
|
+
AIModelEntityExtended
|
|
311
|
+
} from '@memberjunction/aiengine';
|
|
312
|
+
|
|
313
|
+
// Import agent type classes
|
|
314
|
+
import { BaseAgentType, LoopAgentType } from '@memberjunction/aiengine';
|
|
315
|
+
|
|
316
|
+
// Import base AI types from Core
|
|
317
|
+
import { BaseLLM, ChatParams, ChatResult } from '@memberjunction/ai';
|
|
318
|
+
|
|
319
|
+
// When working with agents, import execution types
|
|
320
|
+
import { AgentExecutionParams, AgentExecutionResult } from '@memberjunction/ai-agents';
|
|
321
|
+
```
|
|
322
|
+
|
|
270
323
|
## Dependencies
|
|
271
324
|
|
|
272
325
|
- `@memberjunction/core`: MemberJunction core library
|
|
273
326
|
- `@memberjunction/global`: MemberJunction global utilities
|
|
274
327
|
- `@memberjunction/core-entities`: MemberJunction entity definitions
|
|
275
|
-
- `@memberjunction/ai`: AI
|
|
328
|
+
- `@memberjunction/ai`: Base AI types and interfaces (imported for core types)
|
|
276
329
|
- `@memberjunction/templates`: Template engine integration
|
|
277
330
|
- `@memberjunction/templates-base-types`: Template base type definitions
|
|
278
331
|
- `rxjs`: Reactive programming support
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { AIPromptRunResult } from '@memberjunction/ai';
|
|
2
|
+
import { AIAgentRunEntity, AIAgentRunStepEntity } from '@memberjunction/core-entities';
|
|
3
|
+
import { ActionResult, ActionResultSimple } from '@memberjunction/actions-base';
|
|
4
|
+
export type AgentAction = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
params: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export type AgentSubAgentRequest = {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
message: string;
|
|
13
|
+
terminateAfter: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type BaseAgentNextStep = {
|
|
16
|
+
step: 'success' | 'failed' | 'retry' | 'sub-agent' | 'actions' | 'chat';
|
|
17
|
+
returnValue?: any;
|
|
18
|
+
errorMessage?: string;
|
|
19
|
+
retryReason?: string;
|
|
20
|
+
retryInstructions?: string;
|
|
21
|
+
subAgent?: AgentSubAgentRequest;
|
|
22
|
+
actions?: AgentAction[];
|
|
23
|
+
userMessage?: string;
|
|
24
|
+
};
|
|
25
|
+
export type ExecuteAgentResult = {
|
|
26
|
+
success: boolean;
|
|
27
|
+
finalStep: BaseAgentNextStep['step'];
|
|
28
|
+
returnValue?: any;
|
|
29
|
+
errorMessage?: string;
|
|
30
|
+
cancelled?: boolean;
|
|
31
|
+
cancellationReason?: 'user_requested' | 'timeout' | 'system';
|
|
32
|
+
agentRun: AIAgentRunEntity;
|
|
33
|
+
executionTree: ExecutionNode[];
|
|
34
|
+
};
|
|
35
|
+
export type ExecutionChainStep = {
|
|
36
|
+
stepEntity: AIAgentRunStepEntity;
|
|
37
|
+
executionType: 'prompt' | 'action' | 'sub-agent' | 'decision' | 'chat' | 'validation';
|
|
38
|
+
executionResult: StepExecutionResult;
|
|
39
|
+
nextStepDecision: NextStepDecision;
|
|
40
|
+
startTime: Date;
|
|
41
|
+
endTime?: Date;
|
|
42
|
+
durationMs?: number;
|
|
43
|
+
};
|
|
44
|
+
export type StepExecutionResult = PromptExecutionResult | ActionExecutionResult | SubAgentExecutionResult | DecisionExecutionResult | ChatExecutionResult | ValidationExecutionResult;
|
|
45
|
+
export type ExecutionNode = {
|
|
46
|
+
step: AIAgentRunStepEntity;
|
|
47
|
+
inputData: any;
|
|
48
|
+
outputData: any;
|
|
49
|
+
executionType: 'prompt' | 'action' | 'sub-agent' | 'decision' | 'chat' | 'validation';
|
|
50
|
+
startTime: Date;
|
|
51
|
+
endTime?: Date;
|
|
52
|
+
durationMs?: number;
|
|
53
|
+
nextStepDecision?: NextStepDecision;
|
|
54
|
+
children?: ExecutionNode[];
|
|
55
|
+
depth: number;
|
|
56
|
+
parentStepId?: string;
|
|
57
|
+
agentHierarchy: string[];
|
|
58
|
+
};
|
|
59
|
+
export type PromptExecutionResult = {
|
|
60
|
+
type: 'prompt';
|
|
61
|
+
promptId: string;
|
|
62
|
+
promptName: string;
|
|
63
|
+
result: AIPromptRunResult;
|
|
64
|
+
};
|
|
65
|
+
export type ActionExecutionResult = {
|
|
66
|
+
type: 'action';
|
|
67
|
+
actionId: string;
|
|
68
|
+
actionName: string;
|
|
69
|
+
result: ActionResult | ActionResultSimple;
|
|
70
|
+
};
|
|
71
|
+
export type SubAgentExecutionResult = {
|
|
72
|
+
type: 'sub-agent';
|
|
73
|
+
subAgentId: string;
|
|
74
|
+
subAgentName: string;
|
|
75
|
+
result: ExecuteAgentResult;
|
|
76
|
+
};
|
|
77
|
+
export type DecisionExecutionResult = {
|
|
78
|
+
type: 'decision';
|
|
79
|
+
decisionLogic: string;
|
|
80
|
+
inputContext: any;
|
|
81
|
+
result: BaseAgentNextStep;
|
|
82
|
+
};
|
|
83
|
+
export type ChatExecutionResult = {
|
|
84
|
+
type: 'chat';
|
|
85
|
+
userMessage: string;
|
|
86
|
+
userResponse?: string;
|
|
87
|
+
result: {
|
|
88
|
+
success: boolean;
|
|
89
|
+
continueExecution: boolean;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export type ValidationExecutionResult = {
|
|
93
|
+
type: 'validation';
|
|
94
|
+
validationTarget: string;
|
|
95
|
+
result: {
|
|
96
|
+
valid: boolean;
|
|
97
|
+
errors?: string[];
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export type NextStepDecision = {
|
|
101
|
+
decision: BaseAgentNextStep['step'];
|
|
102
|
+
reasoning?: string;
|
|
103
|
+
nextStepDetails?: NextStepDetails;
|
|
104
|
+
};
|
|
105
|
+
export type NextStepDetails = {
|
|
106
|
+
type: 'prompt';
|
|
107
|
+
promptId: string;
|
|
108
|
+
promptName: string;
|
|
109
|
+
} | {
|
|
110
|
+
type: 'action';
|
|
111
|
+
actions: AgentAction[];
|
|
112
|
+
} | {
|
|
113
|
+
type: 'sub-agent';
|
|
114
|
+
subAgent: AgentSubAgentRequest;
|
|
115
|
+
} | {
|
|
116
|
+
type: 'retry';
|
|
117
|
+
retryReason: string;
|
|
118
|
+
retryInstructions: string;
|
|
119
|
+
} | {
|
|
120
|
+
type: 'chat';
|
|
121
|
+
message: string;
|
|
122
|
+
} | {
|
|
123
|
+
type: 'complete';
|
|
124
|
+
returnValue?: any;
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=agent-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-types.d.ts","sourceRoot":"","sources":["../src/agent-types.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAUhF,MAAM,MAAM,WAAW,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAA;AAWD,MAAM,MAAM,oBAAoB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;CAC3B,CAAA;AA4BD,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;IACxE,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAA;AAoBD,MAAM,MAAM,kBAAkB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS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AAiB,CAAC,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,eAAe,CAAC;CACrC,CAAA;AAQD,MAAM,MAAM,eAAe,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,oBAAoB,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-types.js","sourceRoot":"","sources":["../src/agent-types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AIEngine"), exports);
|
|
18
|
+
__exportStar(require("./agent-types"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,gDAA8B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/aiengine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.51.0",
|
|
4
4
|
"description": "MemberJunction: AI Engine Package - handles automatic execution of Entity AI Actions using AI Models",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"author": "MemberJunction.com",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@memberjunction/core": "2.
|
|
19
|
-
"@memberjunction/global": "2.
|
|
20
|
-
"@memberjunction/core-entities": "2.
|
|
21
|
-
"@memberjunction/ai": "2.
|
|
22
|
-
"@memberjunction/ai-engine-base": "2.
|
|
18
|
+
"@memberjunction/core": "2.51.0",
|
|
19
|
+
"@memberjunction/global": "2.51.0",
|
|
20
|
+
"@memberjunction/core-entities": "2.51.0",
|
|
21
|
+
"@memberjunction/ai": "2.51.0",
|
|
22
|
+
"@memberjunction/ai-engine-base": "2.51.0",
|
|
23
23
|
"dotenv": "^16.4.1",
|
|
24
24
|
"rxjs": "^7.8.1"
|
|
25
25
|
},
|