@memberjunction/ai-agent-manager-actions
Version:
Agent Management actions for creating and managing AI agents in MemberJunction
67 lines • 3.23 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoadCreateSubAgentAction = exports.CreateSubAgentAction = void 0;
const global_1 = require("@memberjunction/global");
const create_agent_action_1 = require("./create-agent.action");
const actions_1 = require("@memberjunction/actions");
/**
* Creates a new agent as a child of another agent.
* This action is restricted to the Agent Manager agent only.
* Extends CreateAgentAction but makes ParentID required.
*
* @example
* ```typescript
* const result = await runAction({
* ActionName: 'Create Sub Agent',
* Params: [
* { Name: 'ParentAgentID', Value: 'parent-agent-id' }, // Required
* { Name: 'Name', Value: 'Data Collector Agent' },
* { Name: 'Description', Value: 'Collects data from various sources' },
* { Name: 'Type', Value: 'Loop' }, // Optional, use Type OR TypeID
* { Name: 'TypeID', Value: 'loop-agent-type-id' }, // Optional, use Type OR TypeID
* { Name: 'PromptText', Value: 'You are a data collector...' } // Optional
* ]
* });
* // Returns AgentID and optionally PromptID in output params
* ```
*/
let CreateSubAgentAction = class CreateSubAgentAction extends create_agent_action_1.CreateAgentAction {
async InternalRunAction(params) {
// First check for ParentAgentID parameter (required for sub-agents)
const parentAgentIDParam = params.Params.find(p => p.Name === 'ParentAgentID');
if (!parentAgentIDParam || !parentAgentIDParam.Value) {
return {
Success: false,
ResultCode: 'MISSING_PARAMETER',
Message: 'ParentAgentID parameter is required for creating sub-agents'
};
}
// Map ParentAgentID to ParentID for the base class
const mappedParams = {
...params,
Params: params.Params.map(p => {
if (p.Name === 'ParentAgentID') {
return { ...p, Name: 'ParentID' };
}
return p;
})
};
// Call the parent class implementation with mapped parameters
return super.InternalRunAction(mappedParams);
}
};
exports.CreateSubAgentAction = CreateSubAgentAction;
exports.CreateSubAgentAction = CreateSubAgentAction = __decorate([
(0, global_1.RegisterClass)(actions_1.BaseAction, "Create Sub Agent")
], CreateSubAgentAction);
function LoadCreateSubAgentAction() {
// This function exists to prevent tree shaking from removing the action class
}
exports.LoadCreateSubAgentAction = LoadCreateSubAgentAction;
//# sourceMappingURL=create-sub-agent.action.js.map