@memberjunction/ai-agent-manager 4.0.0 → 4.2.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.
@@ -1,6 +1,4 @@
1
-
2
- â ™
3
- > @memberjunction/ai-agent-manager@4.0.0 build
4
- > tsc && tsc-alias -f
5
-
6
- ⠙⠙
1
+
2
+ > @memberjunction/ai-agent-manager@4.2.0 build
3
+ > tsc && tsc-alias -f
4
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @memberjunction/ai-agent-manager
2
2
 
3
+ ## 4.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @memberjunction/ai-agents@4.2.0
8
+ - @memberjunction/ai-engine-base@4.2.0
9
+ - @memberjunction/ai-core-plus@4.2.0
10
+ - @memberjunction/aiengine@4.2.0
11
+ - @memberjunction/core@4.2.0
12
+ - @memberjunction/core-entities@4.2.0
13
+ - @memberjunction/global@4.2.0
14
+ - @memberjunction/templates@4.2.0
15
+
16
+ ## 4.1.0
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [77839a9]
21
+ - Updated dependencies [9fab8ca]
22
+ - Updated dependencies [2ea241f]
23
+ - Updated dependencies [5af036f]
24
+ - @memberjunction/core@4.1.0
25
+ - @memberjunction/templates@4.1.0
26
+ - @memberjunction/core-entities@4.1.0
27
+ - @memberjunction/ai-agents@4.1.0
28
+ - @memberjunction/ai-engine-base@4.1.0
29
+ - @memberjunction/ai-core-plus@4.1.0
30
+ - @memberjunction/aiengine@4.1.0
31
+ - @memberjunction/global@4.1.0
32
+
3
33
  ## 4.0.0
4
34
 
5
35
  ### Major Changes
package/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # @memberjunction/ai-agent-manager-core
2
+
3
+ Core package for the MemberJunction Agent Manager system -- a multi-agent pipeline that designs, validates, and persists new AI agents from natural language descriptions. This package contains three specialized agents and the AgentSpecSync utility for database persistence.
4
+
5
+ ## Architecture
6
+
7
+ ```mermaid
8
+ graph TD
9
+ A["PlanningDesignerAgent<br/>(Research + Design)"] -->|produces design| B["ArchitectAgent<br/>(Validate + Build Spec)"]
10
+ B -->|produces AgentSpec| C["BuilderAgent<br/>(Persist to DB)"]
11
+ C -->|uses| D["AgentSpecSync<br/>(Database Sync)"]
12
+ D -->|creates/updates| E["AI Agents + Prompts<br/>+ Actions + Steps<br/>+ Relationships"]
13
+
14
+ A -->|extends| F["BaseAgent<br/>(@memberjunction/ai-agents)"]
15
+ B -->|extends| F
16
+ C -->|extends| F
17
+
18
+ style A fill:#7c5295,stroke:#563a6b,color:#fff
19
+ style B fill:#7c5295,stroke:#563a6b,color:#fff
20
+ style C fill:#7c5295,stroke:#563a6b,color:#fff
21
+ style D fill:#2d8659,stroke:#1a5c3a,color:#fff
22
+ style E fill:#b8762f,stroke:#8a5722,color:#fff
23
+ style F fill:#2d6a9f,stroke:#1a4971,color:#fff
24
+ ```
25
+
26
+ ## Agent Pipeline
27
+
28
+ ```mermaid
29
+ sequenceDiagram
30
+ participant User as User Request
31
+ participant PD as PlanningDesigner
32
+ participant AR as Architect
33
+ participant BU as Builder
34
+ participant DB as Database
35
+
36
+ User->>PD: "Create an agent that..."
37
+ PD->>PD: Research existing agents
38
+ PD->>PD: Research available actions
39
+ PD->>PD: Research database schema
40
+ PD->>PD: Produce TechnicalDesign
41
+ PD-->>AR: TechnicalDesign payload
42
+ AR->>AR: Transform to AgentSpec JSON
43
+ AR->>AR: Validate fields + references
44
+ AR->>AR: Auto-correct minor issues
45
+ AR-->>BU: Validated AgentSpec
46
+ BU->>BU: Create AgentSpecSync
47
+ BU->>DB: SaveToDatabase()
48
+ DB-->>BU: AgentSpecSyncResult
49
+ BU-->>User: Created agent ID + mutations
50
+ ```
51
+
52
+ ## Components
53
+
54
+ ### PlanningDesignerAgent
55
+
56
+ Designs agent architectures by researching existing capabilities before producing a design. Overrides `validateSuccessNextStep` to enforce that required research actions are called before finalizing designs.
57
+
58
+ Key responsibilities:
59
+ - Force discovery of existing agents before selecting actions
60
+ - Force discovery of available actions before designing
61
+ - Force database schema research for CRUD operations
62
+ - Prevent hallucination of non-existent entities or actions
63
+ - Ensure designs are research-backed, not assumption-based
64
+
65
+ ### ArchitectAgent
66
+
67
+ Transforms technical designs into validated AgentSpec JSON objects. Validates all references and auto-corrects minor issues before passing to the Builder.
68
+
69
+ Key responsibilities:
70
+ - Validate required fields (Name, TypeID, etc.)
71
+ - Verify action IDs exist in the database
72
+ - Verify prompt IDs exist if specified
73
+ - Validate SubAgent structure
74
+ - Auto-correct casing and missing optional fields
75
+ - Force retry with detailed errors if validation fails
76
+
77
+ ### BuilderAgent
78
+
79
+ A code-based agent (overrides `executeAgentInternal` to bypass chat loop) that persists validated AgentSpecs to the database. Runs once and returns success or failure.
80
+
81
+ Key responsibilities:
82
+ - Receive validated AgentSpec from payload
83
+ - Create AgentSpecSync instance
84
+ - Persist all related records to database
85
+ - Track mutations in AI Agent Run Steps
86
+ - Return created agent ID or detailed error
87
+
88
+ ### AgentSpecSync
89
+
90
+ Utility class for synchronizing AgentSpec objects with the database. Handles creation, updates, and deletion of all related records with diff-based orphan cleanup.
91
+
92
+ Key capabilities:
93
+ - Creates/updates AI Agent records
94
+ - Manages prompts and agent-prompt associations
95
+ - Manages action associations
96
+ - Manages sub-agent relationships via AI Agent Relationships
97
+ - Manages agent steps and step paths
98
+ - Performs topological sorting for dependency ordering
99
+ - Returns detailed mutation log (`AgentSpecSyncMutation[]`)
100
+
101
+ ## Installation
102
+
103
+ ```bash
104
+ npm install @memberjunction/ai-agent-manager-core
105
+ ```
106
+
107
+ ## Usage
108
+
109
+ ### Using AgentSpecSync Directly
110
+
111
+ ```typescript
112
+ import { AgentSpecSync } from '@memberjunction/ai-agent-manager-core';
113
+ import { AgentSpec } from '@memberjunction/ai-core-plus';
114
+
115
+ const spec: AgentSpec = {
116
+ Name: 'My Custom Agent',
117
+ TypeID: 'type-uuid-here',
118
+ Description: 'An agent that processes customer feedback',
119
+ Actions: [
120
+ { ActionID: 'action-uuid-1' },
121
+ { ActionID: 'action-uuid-2' }
122
+ ],
123
+ SubAgents: []
124
+ };
125
+
126
+ const sync = new AgentSpecSync(spec, contextUser);
127
+ sync.markDirty();
128
+
129
+ const result = await sync.SaveToDatabase();
130
+
131
+ if (result.success) {
132
+ console.log('Agent created with ID:', result.agentId);
133
+ for (const mutation of result.mutations) {
134
+ console.log(`${mutation.Operation} ${mutation.Entity}: ${mutation.Description}`);
135
+ }
136
+ }
137
+ ```
138
+
139
+ ## Key Types
140
+
141
+ | Type | Description |
142
+ |------|-------------|
143
+ | `AgentSpecSyncMutation` | Single database operation record (Entity, Operation, ID, Description) |
144
+ | `AgentSpecSyncResult` | Result with agentId, success flag, and mutations array |
145
+
146
+ ## Class Registration
147
+
148
+ | Agent | Registration Key |
149
+ |-------|-----------------|
150
+ | PlanningDesignerAgent | `@RegisterClass(BaseAgent, 'AgentPlanningDesigner')` |
151
+ | AgentArchitectAgent | `@RegisterClass(BaseAgent, 'AgentArchitectAgent')` |
152
+ | AgentBuilderAgent | `@RegisterClass(BaseAgent, 'AgentBuilderAgent')` |
153
+
154
+ ## Dependencies
155
+
156
+ - `@memberjunction/ai-agents` - BaseAgent, PayloadManager
157
+ - `@memberjunction/ai-core-plus` - AgentSpec, ExecuteAgentParams, extended entity types
158
+ - `@memberjunction/aiengine` - AIEngine for model resolution
159
+ - `@memberjunction/core` - Metadata, RunView, entity operations
160
+ - `@memberjunction/core-entities` - AI Agent, Step, Action, Relationship entities
161
+ - `@memberjunction/global` - Class registration via @RegisterClass
162
+ - `@memberjunction/templates` - TemplateEngineServer for prompt rendering
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/ai-agent-manager",
3
3
  "type": "module",
4
- "version": "4.0.0",
4
+ "version": "4.2.0",
5
5
  "description": "Core interfaces and types for the MemberJunction Agent Manager system",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -20,14 +20,14 @@
20
20
  "author": "MemberJunction",
21
21
  "license": "ISC",
22
22
  "dependencies": {
23
- "@memberjunction/ai-agents": "4.0.0",
24
- "@memberjunction/ai-core-plus": "4.0.0",
25
- "@memberjunction/ai-engine-base": "4.0.0",
26
- "@memberjunction/aiengine": "4.0.0",
27
- "@memberjunction/core": "4.0.0",
28
- "@memberjunction/core-entities": "4.0.0",
29
- "@memberjunction/global": "4.0.0",
30
- "@memberjunction/templates": "4.0.0"
23
+ "@memberjunction/ai-agents": "4.2.0",
24
+ "@memberjunction/ai-core-plus": "4.2.0",
25
+ "@memberjunction/ai-engine-base": "4.2.0",
26
+ "@memberjunction/aiengine": "4.2.0",
27
+ "@memberjunction/core": "4.2.0",
28
+ "@memberjunction/core-entities": "4.2.0",
29
+ "@memberjunction/global": "4.2.0",
30
+ "@memberjunction/templates": "4.2.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^24.10.11",
@@ -1,158 +0,0 @@
1
- /**
2
- * Agent Definition Interface for MemberJunction Agent Manager
3
- *
4
- * This interface defines the complete structure for AI agents at any level
5
- * of hierarchy. All text fields support markdown formatting for rich documentation.
6
- *
7
- * @module @memberjunction/agent-manager-core
8
- */
9
- /**
10
- * Complete agent definition that supports n-levels of sub-agent hierarchy
11
- * All text fields support markdown formatting for rich documentation
12
- */
13
- export interface AIAgentDefinition {
14
- name: string;
15
- description: string;
16
- readonly type: 'Loop';
17
- purpose: string;
18
- actions: {
19
- /** Action ID from the system action library */
20
- id: string;
21
- /** Human-readable name of the action */
22
- name: string;
23
- /** Justification for why this action is needed */
24
- reason: string;
25
- }[];
26
- prompt: {
27
- /** System prompt for this agent */
28
- systemPrompt?: string;
29
- /** Template variables documentation */
30
- templateVariables?: string;
31
- /** Prompt analysis and notes */
32
- promptNotes?: string;
33
- };
34
- payloadDownstreamPaths?: string[];
35
- payloadUpstreamPaths?: string[];
36
- subAgents?: AIAgentDefinition[];
37
- executionOrder?: number;
38
- exposeAsAction?: boolean;
39
- iconClass?: string;
40
- finalPayloadValidation?: string;
41
- finalPayloadValidationMode?: 'Retry' | 'Fail' | 'Warn';
42
- finalPayloadValidationMaxRetries?: number;
43
- }
44
- /**
45
- * Root context for the Agent Manager that tracks the entire creation process
46
- */
47
- export interface AIAgentManagerContext {
48
- agent: AIAgentDefinition;
49
- processStage: 'requirements' | 'design' | 'prompting' | 'implementation' | 'validation' | 'complete';
50
- session: {
51
- id: string;
52
- startedAt: string;
53
- userId: string;
54
- userName: string;
55
- purpose: string;
56
- notes: string;
57
- };
58
- validation?: {
59
- isValid: boolean;
60
- report: string;
61
- };
62
- }
63
- /**
64
- * Agent Manager Payload Definition
65
- * This type defines the structure for data passed between Agent Manager sub-agents
66
- */
67
- export interface AgentManagerPayload {
68
- /**
69
- * Metadata about the agent creation process
70
- */
71
- metadata: {
72
- /** Unique identifier for this agent creation session */
73
- sessionId: string;
74
- /** Current status of the agent creation process */
75
- status: 'requirements' | 'design' | 'prompting' | 'implementation' | 'validation' | 'complete';
76
- /** Original user request for agent creation */
77
- originalRequest: string;
78
- /** The agent who last modified the payload */
79
- lastModifiedBy: string;
80
- };
81
- /**
82
- * Requirements Analyst agent section
83
- */
84
- requirements?: {
85
- /** High-level business objective this agent will serve */
86
- businessGoal: string;
87
- /** Specific functional capabilities the agent must have */
88
- functionalRequirements: string;
89
- /** Technical constraints and requirements */
90
- technicalRequirements: string;
91
- /** Data sources and data handling requirements */
92
- dataRequirements: string;
93
- /** System integration requirements */
94
- integrationRequirements: string;
95
- /** Key assumptions made during requirements gathering */
96
- assumptions: string;
97
- /** Identified risks and mitigation strategies */
98
- risks: string;
99
- /** Explicitly defined scope boundaries */
100
- outOfScope: string;
101
- /** Measurable criteria for success */
102
- successCriteria: string;
103
- };
104
- /**
105
- * Planning Designer agent section
106
- */
107
- design?: {
108
- /** Complete agent hierarchy structure */
109
- agentHierarchy: AIAgentDefinition;
110
- /** Architecture documentation */
111
- architecture: {
112
- /** How agents will execute in sequence/parallel */
113
- executionFlow: string;
114
- /** How data flows between agents */
115
- dataFlow: string;
116
- /** Error handling and recovery strategies */
117
- errorHandling: string;
118
- };
119
- };
120
- /**
121
- * Prompt Designer agent section
122
- */
123
- prompts?: {
124
- /** Map of agent names to their prompt configurations */
125
- [agentName: string]: {
126
- /** Complete system prompt for the agent */
127
- systemPrompt: string;
128
- /** Documentation of template variables used */
129
- templateVariables: string;
130
- /** Analysis and optimization notes */
131
- promptNotes: string;
132
- };
133
- };
134
- /**
135
- * Agent Manager implementation section
136
- */
137
- implementation?: {
138
- /** Agents that have been created in the system */
139
- createdAgents: {
140
- /** Database ID of the created agent */
141
- id: string;
142
- /** Name of the agent */
143
- name: string;
144
- /** Current status of the agent */
145
- status: 'created' | 'configured' | 'validated' | 'active';
146
- }[];
147
- /** Validation results for the created agent system */
148
- validationResults: {
149
- /** ID of the agent that was validated */
150
- agentId: string;
151
- /** Whether the agent passed validation */
152
- isValid: boolean;
153
- /** Any issues found during validation */
154
- issues: string[];
155
- }[];
156
- };
157
- }
158
- //# sourceMappingURL=agent-definition.interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-definition.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/agent-definition.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAEhC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAGhB,OAAO,EAAE;QACP,+CAA+C;QAC/C,EAAE,EAAE,MAAM,CAAC;QACX,wCAAwC;QACxC,IAAI,EAAE,MAAM,CAAC;QACb,kDAAkD;QAClD,MAAM,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;IAGJ,MAAM,EAAE;QACN,mCAAmC;QACnC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,uCAAuC;QACvC,iBAAiB,CAAC,EAAE,MAAM,C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G,QAAQ,CAAC;SAC3D,EAAE,CAAC;QACJ,sDAAsD;QACtD,iBAAiB,EAAE;YACjB,yCAAyC;YACzC,OAAO,EAAE,MAAM,CAAC;YAChB,0CAA0C;YAC1C,OAAO,EAAE,OAAO,CAAC;YACjB,yCAAyC;YACzC,MAAM,EAAE,MAAM,EAAE,CAAC;SAClB,EAAE,CAAC;KACL,CAAC;CACH"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- /**
3
- * Agent Definition Interface for MemberJunction Agent Manager
4
- *
5
- * This interface defines the complete structure for AI agents at any level
6
- * of hierarchy. All text fields support markdown formatting for rich documentation.
7
- *
8
- * @module @memberjunction/agent-manager-core
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- //# sourceMappingURL=agent-definition.interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-definition.interface.js","sourceRoot":"","sources":["../../src/interfaces/agent-definition.interface.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG"}