@memberjunction/ai-agent-manager 2.112.0 → 2.113.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.
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.PlanningDesignerAgent = void 0;
10
+ const ai_agents_1 = require("@memberjunction/ai-agents");
11
+ const global_1 = require("@memberjunction/global");
12
+ /**
13
+ * Planning Designer Agent - Designs agent architectures by researching existing capabilities
14
+ *
15
+ * This agent creates TechnicalDesign or modificationPlan by researching available
16
+ * actions, agents, and database entities. It overrides validateSuccessNextStep to
17
+ * enforce that required research actions are called before finalizing designs.
18
+ *
19
+ * Key responsibilities:
20
+ * - Force discovery of existing agents before selecting actions
21
+ * - Force discovery of available actions before designing
22
+ * - Force database schema research for CRUD operations
23
+ * - Prevent hallucination of non-existent entities/actions
24
+ * - Ensure designs are research-backed, not assumption-based
25
+ */
26
+ let PlanningDesignerAgent = class PlanningDesignerAgent extends ai_agents_1.BaseAgent {
27
+ async validateSuccessNextStep(params, nextStep, currentPayload, agentRun, currentStep) {
28
+ // 1. Call base validation first (checks MinExecutionsPerRun, FinalPayloadValidation)
29
+ const baseValidation = await super.validateSuccessNextStep(params, nextStep, currentPayload, agentRun, currentStep);
30
+ if (baseValidation.step === 'Retry') {
31
+ return baseValidation;
32
+ }
33
+ // 2. Check if required research actions were called
34
+ const researchViolations = await this.checkResearchRequirements(params.agent, agentRun, currentPayload);
35
+ if (researchViolations.length > 0) {
36
+ console.log('🚫 Planning Designer: Research requirements not met:', researchViolations);
37
+ return {
38
+ ...nextStep,
39
+ step: 'Retry',
40
+ retryInstructions: this.formatResearchViolations(researchViolations)
41
+ };
42
+ }
43
+ console.log('✅ Planning Designer: All research requirements met');
44
+ return nextStep;
45
+ }
46
+ /**
47
+ * Checks if Planning Designer called required research actions/agents
48
+ */
49
+ async checkResearchRequirements(agent, agentRun, currentPayload) {
50
+ const violations = [];
51
+ // Hardcoded IDs for required research capabilities (from metadata)
52
+ const FIND_CANDIDATE_AGENTS_ACTION_ID = 'EF610103-E48D-4D9C-8DA2-1CF5B05F8AB6';
53
+ const FIND_CANDIDATE_ACTIONS_ACTION_ID = 'FD932133-CB1D-4C96-8EFC-14F0C8CE045B';
54
+ const DATABASE_RESEARCH_AGENT_ID = '746CD1E8-CB8D-49A4-BE69-D0F208A0B462';
55
+ // Get execution counts using hardcoded IDs
56
+ const findAgentsCount = await this.getActionExecutionCount(agentRun.ID, FIND_CANDIDATE_AGENTS_ACTION_ID);
57
+ const findActionsCount = await this.getActionExecutionCount(agentRun.ID, FIND_CANDIDATE_ACTIONS_ACTION_ID);
58
+ const dbResearchCount = await this.getSubAgentExecutionCount(agentRun.ID, DATABASE_RESEARCH_AGENT_ID);
59
+ // Find Candidate Agents is MANDATORY (at least once)
60
+ if (findAgentsCount === 0) {
61
+ violations.push(`❌ MISSING: "Find Candidate Agents" action has NOT been called
62
+
63
+ **Purpose**: Discovers existing agents that can handle your subtasks as related subagents
64
+ **What it returns**: Agent IDs, names, descriptions, existing actions, and existing subAgents
65
+ **Why critical**: Existing specialized agents eliminate the need for multiple actions - one capable agent can replace several actions. You must search BEFORE selecting actions to avoid duplication.
66
+ **What to do**: Call "Find Candidate Agents" multiple times with different TaskDescriptions for each major subtask. Set ExcludeSubAgents=false to see ALL available agents. Review their actions and subAgents arrays to understand full capabilities.`);
67
+ }
68
+ // Find Candidate Actions is MANDATORY (at least once)
69
+ if (findActionsCount === 0) {
70
+ violations.push(`❌ MISSING: "Find Candidate Actions" action has NOT been called
71
+
72
+ **Purpose**: Discovers existing actions that can handle specific tasks (only use for tasks NOT covered by existing agents)
73
+ **What it returns**: Action IDs, names, parameters (inputs/outputs), and descriptions
74
+ **Why critical**: You cannot guess or make up action IDs - they must come from actual search results. Actions have specific parameter structures you need to understand.
75
+ **What to do**: Call "Find Candidate Actions" for each task that existing agents cannot handle. Use the exact action IDs and names from results in your design.`);
76
+ }
77
+ // Database Research Agent is REQUIRED if design mentions CRUD/database operations
78
+ const designText = this.getDesignText(currentPayload);
79
+ if (this.mentionsDatabaseOperations(designText)) {
80
+ if (dbResearchCount === 0) {
81
+ violations.push(`❌ MISSING: "Database Research Agent" sub-agent has NOT been called (but your design mentions database/CRUD operations)
82
+
83
+ **Purpose**: Provides actual entity names, field names, primary keys, data types, and relationships from the database schema
84
+ **What it returns**: Complete entity schema information written to payload.TechnicalDesign.databaseSchema
85
+ **Why critical**: NEVER guess entity or field names - they must come from Database Research Agent. CRUD actions require exact entity names and field names to work correctly.
86
+ **What to do**: Call Database Research Agent with specific questions like "Is there an entity called [NAME] or related to [CONCEPT]? Give me all fields." Review the results and use ONLY those exact entity/field names in your CRUD action designs.`);
87
+ }
88
+ }
89
+ return violations;
90
+ }
91
+ /**
92
+ * Extracts design text from payload (FunctionalRequirements, TechnicalDesign, or modificationPlan)
93
+ */
94
+ getDesignText(payload) {
95
+ if (!payload) {
96
+ return '';
97
+ }
98
+ // Check all possible fields that might mention database operations:
99
+ // - FunctionalRequirements (from Requirements Analyst - may mention data storage needs)
100
+ // - TechnicalDesign (creation mode - the design document)
101
+ // - modificationPlan (modification mode - the change plan)
102
+ const functionalRequirements = payload.FunctionalRequirements || '';
103
+ const technicalDesign = payload.TechnicalDesign || '';
104
+ const modificationPlan = payload.modificationPlan || '';
105
+ return (functionalRequirements + ' ' + technicalDesign + ' ' + modificationPlan).toLowerCase();
106
+ }
107
+ /**
108
+ * Checks if text mentions database operations that require entity knowledge
109
+ */
110
+ mentionsDatabaseOperations(text) {
111
+ const keywords = [
112
+ 'create record',
113
+ 'update record',
114
+ 'delete record',
115
+ 'crud',
116
+ 'database',
117
+ 'entity',
118
+ 'save to',
119
+ 'store in',
120
+ 'persist',
121
+ 'write to database',
122
+ 'update priority',
123
+ 'create new record',
124
+ 'insert into',
125
+ 'entityname'
126
+ ];
127
+ return keywords.some(keyword => text.includes(keyword));
128
+ }
129
+ /**
130
+ * Formats research violations into clear, actionable retry instructions
131
+ */
132
+ formatResearchViolations(violations) {
133
+ const header = '## Research Requirements Not Met\n\nYou must conduct thorough research before finalizing your design:\n\n';
134
+ const violationList = violations.map((v, idx) => `${idx + 1}. ${v}`).join('\n\n');
135
+ const footer = `\n\n---
136
+
137
+ **Next Steps - Complete Research Process**:
138
+
139
+ 1. **Call each missing research action/agent listed above** (in order shown)
140
+
141
+ 2. **Review research results carefully**:
142
+ - "Find Candidate Agents": Check each agent's actions and subAgents arrays - if an agent can handle multiple subtasks, use it instead of individual actions
143
+ - "Find Candidate Actions": Note the exact action IDs and parameter structures - you'll need these exact IDs in your design
144
+ - "Database Research Agent": Copy the exact entity names and field names - use ONLY these in your CRUD action instructions
145
+
146
+ 3. **Update your design based on actual research findings**:
147
+ - Replace any guessed/assumed names with actual IDs and names from research
148
+ - Remove redundant actions if subagents already provide those capabilities
149
+ - Maximize reuse of existing agents to simplify your design
150
+ - For CRUD actions: Include exact entity names and field names in the agent prompt
151
+
152
+ 4. **Try again** - Your next response must include research-backed design (no assumptions!)`;
153
+ return header + violationList + footer;
154
+ }
155
+ };
156
+ exports.PlanningDesignerAgent = PlanningDesignerAgent;
157
+ exports.PlanningDesignerAgent = PlanningDesignerAgent = __decorate([
158
+ (0, global_1.RegisterClass)(ai_agents_1.BaseAgent, 'AgentPlanningDesigner')
159
+ ], PlanningDesignerAgent);
160
+ //# sourceMappingURL=planning-designer-agent.js.map
@@ -0,0 +1 @@
1
+ {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AC,gBAAgB,IAAI,EAAE,CAAC;QAExD,OAAO,CAAC,sBAAsB,GAAG,GAAG,GAAG,eAAe,GAAG,GAAG,GAAG,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;IACnG,CAAC;IAED;;OAEG;IACO,0BAA0B,CAAC,IAAY;QAC7C,MAAM,QAAQ,GAAG;YACb,eAAe;YACf,eAAe;YACf,eAAe;YACf,MAAM;YACN,UAAU;YACV,QAAQ;YACR,SAAS;YACT,UAAU;YACV,SAAS;YACT,mBAAmB;YACnB,iBAAiB;YACjB,mBAAmB;YACnB,aAAa;YACb,YAAY;SACf,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACO,wBAAwB,CAAC,UAAoB;QACnD,MAAM,MAAM,GAAG,2GAA2G,CAAC;QAC3H,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClF,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;4FAiBqE,CAAC;QAErF,OAAO,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;IAC3C,CAAC;CACJ,CAAA;AA7JY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAa,EAAC,qBAAS,EAAE,uBAAuB,CAAC;GACrC,qBAAqB,CA6JjC"}
package/dist/index.d.ts CHANGED
@@ -7,12 +7,14 @@ export * from './old/agent-definition.interface';
7
7
  export * from './agent-spec-sync';
8
8
  export * from './agents/architect-agent';
9
9
  export * from './agents/builder-agent';
10
+ export * from './agents/planning-designer-agent';
10
11
  /**
11
12
  * Loads the Agent Manager Core module and ensures all agent classes are registered.
12
13
  * This function prevents tree shaking from removing the agent class registrations.
13
14
  *
14
15
  * The function itself doesn't need to do anything - importing the module is enough
15
- * to trigger the @RegisterClass decorators on AgentArchitectAgent and AgentBuilderAgent.
16
+ * to trigger the @RegisterClass decorators on AgentArchitectAgent, AgentBuilderAgent,
17
+ * and PlanningDesignerAgent.
16
18
  */
17
19
  export declare function LoadAgentManagerCore(): void;
18
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,kCAAkC,CAAC;AAEjD,cAAc,mBAAmB,CAAC;AAGlC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AAEvC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,SAGnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,kCAAkC,CAAC;AAEjD,cAAc,mBAAmB,CAAC;AAGlC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,SAGnC"}
package/dist/index.js CHANGED
@@ -26,12 +26,14 @@ __exportStar(require("./agent-spec-sync"), exports);
26
26
  // Export agent implementations
27
27
  __exportStar(require("./agents/architect-agent"), exports);
28
28
  __exportStar(require("./agents/builder-agent"), exports);
29
+ __exportStar(require("./agents/planning-designer-agent"), exports);
29
30
  /**
30
31
  * Loads the Agent Manager Core module and ensures all agent classes are registered.
31
32
  * This function prevents tree shaking from removing the agent class registrations.
32
33
  *
33
34
  * The function itself doesn't need to do anything - importing the module is enough
34
- * to trigger the @RegisterClass decorators on AgentArchitectAgent and AgentBuilderAgent.
35
+ * to trigger the @RegisterClass decorators on AgentArchitectAgent, AgentBuilderAgent,
36
+ * and PlanningDesignerAgent.
35
37
  */
36
38
  function LoadAgentManagerCore() {
37
39
  // Forces module to load and decorators to execute
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,wBAAwB;AACxB,mEAAiD;AAEjD,oDAAkC;AAElC,+BAA+B;AAC/B,2DAAyC;AACzC,yDAAuC;AAEvC;;;;;;GAMG;AACH,SAAgB,oBAAoB;IAChC,kDAAkD;IAClD,4DAA4D;AAChE,CAAC;AAHD,oDAGC;AAED,mDAAmD;AACnD,oBAAoB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,wBAAwB;AACxB,mEAAiD;AAEjD,oDAAkC;AAElC,+BAA+B;AAC/B,2DAAyC;AACzC,yDAAuC;AACvC,mEAAiD;AAEjD;;;;;;;GAOG;AACH,SAAgB,oBAAoB;IAChC,kDAAkD;IAClD,4DAA4D;AAChE,CAAC;AAHD,oDAGC;AAED,mDAAmD;AACnD,oBAAoB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ai-agent-manager",
3
- "version": "2.112.0",
3
+ "version": "2.113.0",
4
4
  "description": "Core interfaces and types for the MemberJunction Agent Manager system",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,10 +19,11 @@
19
19
  "author": "MemberJunction",
20
20
  "license": "ISC",
21
21
  "dependencies": {
22
- "@memberjunction/core-entities": "2.112.0",
23
- "@memberjunction/global": "2.112.0",
24
- "@memberjunction/ai-core-plus": "2.112.0",
25
- "@memberjunction/ai-agents": "2.112.0"
22
+ "@memberjunction/core": "2.113.0",
23
+ "@memberjunction/core-entities": "2.113.0",
24
+ "@memberjunction/global": "2.113.0",
25
+ "@memberjunction/ai-core-plus": "2.113.0",
26
+ "@memberjunction/ai-agents": "2.113.0"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/node": "^18.11.0",