@memberjunction/core-actions 2.111.1 → 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,53 @@
1
+ import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
+ import { BaseAction } from "@memberjunction/actions";
3
+ /**
4
+ * Action that finds the best-matching actions for a given task using embedding-based semantic search.
5
+ *
6
+ * This action uses local embeddings to perform fast similarity search across all available actions,
7
+ * returning the most relevant actions based on their descriptions and capabilities.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Find actions for a web search task
12
+ * await runAction({
13
+ * ActionName: 'Find Best Action',
14
+ * Params: [{
15
+ * Name: 'TaskDescription',
16
+ * Value: 'Search the internet for information on a topic'
17
+ * }, {
18
+ * Name: 'MaxResults',
19
+ * Value: 5
20
+ * }, {
21
+ * Name: 'MinimumSimilarityScore',
22
+ * Value: 0.6
23
+ * }]
24
+ * });
25
+ * ```
26
+ */
27
+ export declare class FindBestActionAction extends BaseAction {
28
+ /**
29
+ * Executes the Find Best Action action.
30
+ *
31
+ * @param params - The action parameters containing:
32
+ * - TaskDescription: Description of the task to find actions for (required)
33
+ * - MaxResults: Maximum number of actions to return (optional, default: 10)
34
+ * - MinimumSimilarityScore: Minimum similarity score 0-1 (optional, default: 0.5)
35
+ * - ExcludeAgentManagement: Exclude Agent Management actions (optional, default: true)
36
+ *
37
+ * @returns Action result with matched actions
38
+ */
39
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
40
+ /**
41
+ * Get boolean parameter with default
42
+ */
43
+ private getBooleanParam;
44
+ /**
45
+ * Get parameter value by name (case-insensitive)
46
+ */
47
+ private getParamValue;
48
+ }
49
+ /**
50
+ * Loader function to ensure the FindBestActionAction class is included in the bundle
51
+ */
52
+ export declare function LoadFindBestActionAction(): void;
53
+ //# sourceMappingURL=find-best-action.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-best-action.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/find-best-action.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,oBAAqB,SAAQ,UAAU;IAChD;;;;;;;;;;OAUG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsJvF;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACH,OAAO,CAAC,aAAa;CAIxB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,SAEvC"}
@@ -0,0 +1,211 @@
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.LoadFindBestActionAction = exports.FindBestActionAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const actions_1 = require("@memberjunction/actions");
12
+ const aiengine_1 = require("@memberjunction/aiengine");
13
+ const core_1 = require("@memberjunction/core");
14
+ /**
15
+ * Action that finds the best-matching actions for a given task using embedding-based semantic search.
16
+ *
17
+ * This action uses local embeddings to perform fast similarity search across all available actions,
18
+ * returning the most relevant actions based on their descriptions and capabilities.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Find actions for a web search task
23
+ * await runAction({
24
+ * ActionName: 'Find Best Action',
25
+ * Params: [{
26
+ * Name: 'TaskDescription',
27
+ * Value: 'Search the internet for information on a topic'
28
+ * }, {
29
+ * Name: 'MaxResults',
30
+ * Value: 5
31
+ * }, {
32
+ * Name: 'MinimumSimilarityScore',
33
+ * Value: 0.6
34
+ * }]
35
+ * });
36
+ * ```
37
+ */
38
+ let FindBestActionAction = class FindBestActionAction extends actions_1.BaseAction {
39
+ /**
40
+ * Executes the Find Best Action action.
41
+ *
42
+ * @param params - The action parameters containing:
43
+ * - TaskDescription: Description of the task to find actions for (required)
44
+ * - MaxResults: Maximum number of actions to return (optional, default: 10)
45
+ * - MinimumSimilarityScore: Minimum similarity score 0-1 (optional, default: 0.5)
46
+ * - ExcludeAgentManagement: Exclude Agent Management actions (optional, default: true)
47
+ *
48
+ * @returns Action result with matched actions
49
+ */
50
+ async InternalRunAction(params) {
51
+ try {
52
+ // Extract and validate input parameters
53
+ const taskDescription = this.getParamValue(params, 'taskdescription');
54
+ const maxResults = parseInt(this.getParamValue(params, 'maxresults') || '10');
55
+ const minimumSimilarityScore = parseFloat(this.getParamValue(params, 'minimumsimilarityscore') || '0.5');
56
+ const excludeAgentManagement = this.getBooleanParam(params, 'excludeagentmanagement', true);
57
+ // Validate required input
58
+ if (!taskDescription || taskDescription.trim().length === 0) {
59
+ return {
60
+ Success: false,
61
+ ResultCode: 'INVALID_INPUT',
62
+ Message: 'TaskDescription parameter is required and cannot be empty'
63
+ };
64
+ }
65
+ // Validate numeric ranges
66
+ if (maxResults < 1 || maxResults > 50) {
67
+ return {
68
+ Success: false,
69
+ ResultCode: 'INVALID_INPUT',
70
+ Message: 'MaxResults must be between 1 and 50'
71
+ };
72
+ }
73
+ if (minimumSimilarityScore < 0 || minimumSimilarityScore > 1) {
74
+ return {
75
+ Success: false,
76
+ ResultCode: 'INVALID_INPUT',
77
+ Message: 'MinimumSimilarityScore must be between 0 and 1'
78
+ };
79
+ }
80
+ // Validate contextUser is provided
81
+ if (!params.ContextUser) {
82
+ return {
83
+ Success: false,
84
+ ResultCode: 'MISSING_USER_CONTEXT',
85
+ Message: 'User context required'
86
+ };
87
+ }
88
+ // Ensure AIEngine is loaded (embeddings computed during initialization)
89
+ await aiengine_1.AIEngine.Instance.Config(false, params.ContextUser);
90
+ // Find similar actions using AIEngine's built-in method - no database round trip!
91
+ const matchedActions = await aiengine_1.AIEngine.Instance.FindSimilarActions(taskDescription, maxResults * 2, // Get 2x results to account for filtering
92
+ minimumSimilarityScore);
93
+ // Filter out Agent Management actions if requested
94
+ let filteredActions = matchedActions;
95
+ if (excludeAgentManagement) {
96
+ filteredActions = matchedActions.filter(a => a.categoryName !== 'Agent Management');
97
+ }
98
+ // Limit to maxResults after filtering
99
+ filteredActions = filteredActions.slice(0, maxResults);
100
+ if (filteredActions.length === 0) {
101
+ return {
102
+ Success: false,
103
+ ResultCode: 'NO_ACTIONS_FOUND',
104
+ Message: `No actions found matching the criteria (minimum similarity: ${minimumSimilarityScore}).`
105
+ };
106
+ }
107
+ // Load action parameters for all matched actions
108
+ const actionIds = filteredActions.map(a => a.actionId);
109
+ const rv = new core_1.RunView();
110
+ const paramsResult = await rv.RunView({
111
+ EntityName: 'Action Params',
112
+ ExtraFilter: `ActionID IN ('${actionIds.join("','")}')`,
113
+ OrderBy: 'ActionID, Name',
114
+ ResultType: 'entity_object'
115
+ }, params.ContextUser);
116
+ // Group parameters by action ID
117
+ const paramsByActionId = new Map();
118
+ if (paramsResult.Success && paramsResult.Results) {
119
+ for (const param of paramsResult.Results) {
120
+ const actionId = param.ActionID;
121
+ if (!paramsByActionId.has(actionId)) {
122
+ paramsByActionId.set(actionId, []);
123
+ }
124
+ paramsByActionId.get(actionId).push(param);
125
+ }
126
+ }
127
+ // Build response with parameters included
128
+ const actionsWithParams = filteredActions.map(a => ({
129
+ actionId: a.actionId,
130
+ actionName: a.actionName,
131
+ similarityScore: Math.round(a.similarityScore * 100) / 100,
132
+ description: a.description,
133
+ categoryName: a.categoryName,
134
+ status: a.status,
135
+ driverClass: a.driverClass,
136
+ parameters: (paramsByActionId.get(a.actionId) || []).map(p => ({
137
+ name: p.Name,
138
+ type: p.Type, // Input/Output
139
+ valueType: p.ValueType,
140
+ isArray: p.IsArray,
141
+ description: p.Description,
142
+ isRequired: p.IsRequired,
143
+ defaultValue: p.DefaultValue
144
+ }))
145
+ }));
146
+ // Add output parameters
147
+ params.Params.push({
148
+ Name: 'MatchedActions',
149
+ Type: 'Output',
150
+ Value: actionsWithParams
151
+ });
152
+ params.Params.push({
153
+ Name: 'MatchCount',
154
+ Type: 'Output',
155
+ Value: filteredActions.length
156
+ });
157
+ // Build response message with full descriptions and parameters
158
+ const responseData = {
159
+ message: `Found ${filteredActions.length} relevant action(s)`,
160
+ taskDescription: taskDescription,
161
+ matchCount: filteredActions.length,
162
+ allMatches: actionsWithParams
163
+ };
164
+ return {
165
+ Success: true,
166
+ ResultCode: 'SUCCESS',
167
+ Message: JSON.stringify(responseData, null, 2)
168
+ };
169
+ }
170
+ catch (error) {
171
+ return {
172
+ Success: false,
173
+ ResultCode: 'EXECUTION_ERROR',
174
+ Message: `Failed to find best action: ${error instanceof Error ? error.message : String(error)}`
175
+ };
176
+ }
177
+ }
178
+ /**
179
+ * Get boolean parameter with default
180
+ */
181
+ getBooleanParam(params, name, defaultValue) {
182
+ const value = this.getParamValue(params, name);
183
+ if (value === undefined || value === null)
184
+ return defaultValue;
185
+ if (typeof value === 'boolean')
186
+ return value;
187
+ if (typeof value === 'string') {
188
+ return value.toLowerCase() === 'true';
189
+ }
190
+ return defaultValue;
191
+ }
192
+ /**
193
+ * Get parameter value by name (case-insensitive)
194
+ */
195
+ getParamValue(params, name) {
196
+ const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
197
+ return param?.Value;
198
+ }
199
+ };
200
+ exports.FindBestActionAction = FindBestActionAction;
201
+ exports.FindBestActionAction = FindBestActionAction = __decorate([
202
+ (0, global_1.RegisterClass)(actions_1.BaseAction, "Find Best Action")
203
+ ], FindBestActionAction);
204
+ /**
205
+ * Loader function to ensure the FindBestActionAction class is included in the bundle
206
+ */
207
+ function LoadFindBestActionAction() {
208
+ // Stub function to prevent tree shaking
209
+ }
210
+ exports.LoadFindBestActionAction = LoadFindBestActionAction;
211
+ //# sourceMappingURL=find-best-action.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-best-action.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-best-action.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,uDAAoD;AACpD,+CAA+C;AAG/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,oBAAU;IAChD;;;;;;;;;;OAUG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,wCAAwC;YACxC,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;YACtE,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,IAAI,IAAI,CAAC,CAAC;YAC9E,MAAM,sBAAsB,GAAG,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,wBAAwB,CAAC,IAAI,KAAK,CAAC,CAAC;YACzG,MAAM,sBAAsB,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,wBAAwB,EAAE,IAAI,CAAC,CAAC;YAE5F,0BAA0B;YAC1B,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1D,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,eAAe;oBAC3B,OAAO,EAAE,2DAA2D;iBACvE,CAAC;YACN,CAAC;YAED,0BAA0B;YAC1B,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,EAAE,EAAE,CAAC;gBAC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EAAE,CAAC;YACb,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,iBAAiB;gBAC7B,OAAO,EAAE,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACnG,CAAC;QACN,CAAC;IACL,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,MAAuB,EAAE,IAAY,EAAE,YAAqB;QAChF,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,YAAY,CAAC;QAC/D,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;QAC1C,CAAC;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAuB,EAAE,IAAY;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACnF,OAAO,KAAK,EAAE,KAAK,CAAC;IACxB,CAAC;CACJ,CAAA;AAtLY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,sBAAa,EAAC,oBAAU,EAAE,kBAAkB,CAAC;GACjC,oBAAoB,CAsLhC;AAED;;GAEG;AACH,SAAgB,wBAAwB;IACpC,wCAAwC;AAC5C,CAAC;AAFD,4DAEC"}
@@ -0,0 +1,53 @@
1
+ import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
+ import { BaseAction } from "@memberjunction/actions";
3
+ /**
4
+ * Action that finds the best-matching AI agents for a given task using embedding-based semantic search.
5
+ *
6
+ * This action uses local embeddings to perform fast similarity search across all available agents,
7
+ * returning the most relevant agents based on their descriptions and capabilities.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Find agents for a research task
12
+ * await runAction({
13
+ * ActionName: 'Find Best Agent',
14
+ * Params: [{
15
+ * Name: 'TaskDescription',
16
+ * Value: 'Research market trends and compile a comprehensive report'
17
+ * }, {
18
+ * Name: 'MaxResults',
19
+ * Value: 5
20
+ * }, {
21
+ * Name: 'MinimumSimilarityScore',
22
+ * Value: 0.7
23
+ * }]
24
+ * });
25
+ * ```
26
+ */
27
+ export declare class FindBestAgentAction extends BaseAction {
28
+ /**
29
+ * Executes the Find Best Agent action.
30
+ *
31
+ * @param params - The action parameters containing:
32
+ * - TaskDescription: Description of the task to find agents for (required)
33
+ * - MaxResults: Maximum number of agents to return (optional, default: 5)
34
+ * - MinimumSimilarityScore: Minimum similarity score 0-1 (optional, default: 0.5)
35
+ * - IncludeInactive: Include inactive agents (optional, default: false)
36
+ *
37
+ * @returns Action result with matched agents
38
+ */
39
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
40
+ /**
41
+ * Get boolean parameter with default
42
+ */
43
+ private getBooleanParam;
44
+ /**
45
+ * Get parameter value by name (case-insensitive)
46
+ */
47
+ private getParamValue;
48
+ }
49
+ /**
50
+ * Loader function to ensure the FindBestAgentAction class is included in the bundle
51
+ */
52
+ export declare function LoadFindBestAgentAction(): void;
53
+ //# sourceMappingURL=find-best-agent.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-best-agent.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/find-best-agent.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,mBAAoB,SAAQ,UAAU;IAG/C;;;;;;;;;;OAUG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAyIvF;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACH,OAAO,CAAC,aAAa;CAIxB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,SAEtC"}
@@ -0,0 +1,195 @@
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.LoadFindBestAgentAction = exports.FindBestAgentAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const actions_1 = require("@memberjunction/actions");
12
+ const aiengine_1 = require("@memberjunction/aiengine");
13
+ const ai_engine_base_1 = require("@memberjunction/ai-engine-base");
14
+ /**
15
+ * Action that finds the best-matching AI agents for a given task using embedding-based semantic search.
16
+ *
17
+ * This action uses local embeddings to perform fast similarity search across all available agents,
18
+ * returning the most relevant agents based on their descriptions and capabilities.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Find agents for a research task
23
+ * await runAction({
24
+ * ActionName: 'Find Best Agent',
25
+ * Params: [{
26
+ * Name: 'TaskDescription',
27
+ * Value: 'Research market trends and compile a comprehensive report'
28
+ * }, {
29
+ * Name: 'MaxResults',
30
+ * Value: 5
31
+ * }, {
32
+ * Name: 'MinimumSimilarityScore',
33
+ * Value: 0.7
34
+ * }]
35
+ * });
36
+ * ```
37
+ */
38
+ let FindBestAgentAction = class FindBestAgentAction extends actions_1.BaseAction {
39
+ // Singleton initialization removed - AIEngine handles embedding lifecycle
40
+ /**
41
+ * Executes the Find Best Agent action.
42
+ *
43
+ * @param params - The action parameters containing:
44
+ * - TaskDescription: Description of the task to find agents for (required)
45
+ * - MaxResults: Maximum number of agents to return (optional, default: 5)
46
+ * - MinimumSimilarityScore: Minimum similarity score 0-1 (optional, default: 0.5)
47
+ * - IncludeInactive: Include inactive agents (optional, default: false)
48
+ *
49
+ * @returns Action result with matched agents
50
+ */
51
+ async InternalRunAction(params) {
52
+ try {
53
+ // Extract and validate input parameters
54
+ const taskDescription = this.getParamValue(params, 'taskdescription');
55
+ const maxResults = parseInt(this.getParamValue(params, 'maxresults') || '5');
56
+ const minimumSimilarityScore = parseFloat(this.getParamValue(params, 'minimumsimilarityscore') || '0.5');
57
+ const includeInactive = this.getBooleanParam(params, 'includeinactive', false);
58
+ // Validate required input
59
+ if (!taskDescription || taskDescription.trim().length === 0) {
60
+ return {
61
+ Success: false,
62
+ ResultCode: 'INVALID_INPUT',
63
+ Message: 'TaskDescription parameter is required and cannot be empty'
64
+ };
65
+ }
66
+ // Validate numeric ranges
67
+ if (maxResults < 1 || maxResults > 20) {
68
+ return {
69
+ Success: false,
70
+ ResultCode: 'INVALID_INPUT',
71
+ Message: 'MaxResults must be between 1 and 20'
72
+ };
73
+ }
74
+ if (minimumSimilarityScore < 0 || minimumSimilarityScore > 1) {
75
+ return {
76
+ Success: false,
77
+ ResultCode: 'INVALID_INPUT',
78
+ Message: 'MinimumSimilarityScore must be between 0 and 1'
79
+ };
80
+ }
81
+ // Validate contextUser is provided for permission filtering
82
+ if (!params.ContextUser) {
83
+ return {
84
+ Success: false,
85
+ ResultCode: 'MISSING_USER_CONTEXT',
86
+ Message: 'User context required for permission filtering'
87
+ };
88
+ }
89
+ // Ensure AIEngine is loaded (embeddings computed during initialization)
90
+ await aiengine_1.AIEngine.Instance.Config(false, params.ContextUser);
91
+ // Find similar agents using AIEngine's built-in method - no database round trip!
92
+ const matchedAgents = await aiengine_1.AIEngine.Instance.FindSimilarAgents(taskDescription, maxResults * 3, // Get 3x results to account for filtering
93
+ minimumSimilarityScore);
94
+ // Filter by user permissions - user must have 'run' permission
95
+ const accessibleAgents = await ai_engine_base_1.AIAgentPermissionHelper.GetAccessibleAgents(params.ContextUser, 'run');
96
+ const accessibleAgentIds = new Set(accessibleAgents.map(a => a.ID));
97
+ // Filter matched agents by permissions
98
+ let permissionFilteredAgents = matchedAgents.filter(a => accessibleAgentIds.has(a.agentId));
99
+ // Filter by status if not including inactive
100
+ if (!includeInactive) {
101
+ permissionFilteredAgents = permissionFilteredAgents.filter(a => a.status === 'Active');
102
+ }
103
+ // Filter by invocation mode - exclude Sub-Agent agents (only show Any or Top-Level)
104
+ // Sub-Agents are meant to be called by other agents, not discovered by users/tools
105
+ const invocationFilteredAgents = permissionFilteredAgents.filter(a => a.invocationMode !== 'Sub-Agent');
106
+ // Limit to maxResults after all filtering
107
+ const filteredAgents = invocationFilteredAgents.slice(0, maxResults);
108
+ if (filteredAgents.length === 0) {
109
+ return {
110
+ Success: false,
111
+ ResultCode: 'NO_AGENTS_FOUND',
112
+ Message: `No accessible agents found matching the criteria (minimum similarity: ${minimumSimilarityScore}). You may not have permission to run the matching agents.`
113
+ };
114
+ }
115
+ // AIEngine already loaded above - use it to get agent actions
116
+ // Create map of agentId -> action names
117
+ const agentActionsMap = new Map();
118
+ for (const agent of filteredAgents) {
119
+ const agentActions = aiengine_1.AIEngine.Instance.AgentActions
120
+ .filter(aa => aa.AgentID === agent.agentId && aa.Status === 'Active')
121
+ .map(aa => aa.Action); // Get action name
122
+ agentActionsMap.set(agent.agentId, agentActions);
123
+ }
124
+ // Add output parameters
125
+ params.Params.push({
126
+ Name: 'MatchedAgents',
127
+ Type: 'Output',
128
+ Value: filteredAgents
129
+ });
130
+ params.Params.push({
131
+ Name: 'MatchCount',
132
+ Type: 'Output',
133
+ Value: filteredAgents.length
134
+ });
135
+ // Build response message with full descriptions and actions
136
+ const responseData = {
137
+ message: `Found ${filteredAgents.length} accessible agent(s)`,
138
+ taskDescription: taskDescription,
139
+ matchCount: filteredAgents.length,
140
+ allMatches: filteredAgents.map(a => ({
141
+ agentId: a.agentId, // Include agent ID for direct use with Load Agent Spec
142
+ agentName: a.agentName,
143
+ similarityScore: Math.round(a.similarityScore * 100) / 100, // Round to 2 decimal places
144
+ description: a.description, // Full description, no truncation
145
+ actions: agentActionsMap.get(a.agentId) || []
146
+ }))
147
+ };
148
+ return {
149
+ Success: true,
150
+ ResultCode: 'SUCCESS',
151
+ Message: JSON.stringify(responseData, null, 2)
152
+ };
153
+ }
154
+ catch (error) {
155
+ return {
156
+ Success: false,
157
+ ResultCode: 'EXECUTION_ERROR',
158
+ Message: `Failed to find best agent: ${error instanceof Error ? error.message : String(error)}`
159
+ };
160
+ }
161
+ }
162
+ /**
163
+ * Get boolean parameter with default
164
+ */
165
+ getBooleanParam(params, name, defaultValue) {
166
+ const value = this.getParamValue(params, name);
167
+ if (value === undefined || value === null)
168
+ return defaultValue;
169
+ if (typeof value === 'boolean')
170
+ return value;
171
+ if (typeof value === 'string') {
172
+ return value.toLowerCase() === 'true';
173
+ }
174
+ return defaultValue;
175
+ }
176
+ /**
177
+ * Get parameter value by name (case-insensitive)
178
+ */
179
+ getParamValue(params, name) {
180
+ const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
181
+ return param?.Value;
182
+ }
183
+ };
184
+ exports.FindBestAgentAction = FindBestAgentAction;
185
+ exports.FindBestAgentAction = FindBestAgentAction = __decorate([
186
+ (0, global_1.RegisterClass)(actions_1.BaseAction, "Find Best Agent")
187
+ ], FindBestAgentAction);
188
+ /**
189
+ * Loader function to ensure the FindBestAgentAction class is included in the bundle
190
+ */
191
+ function LoadFindBestAgentAction() {
192
+ // Stub function to prevent tree shaking
193
+ }
194
+ exports.LoadFindBestAgentAction = LoadFindBestAgentAction;
195
+ //# sourceMappingURL=find-best-agent.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-best-agent.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-best-agent.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,uDAAoD;AACpD,mEAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,oBAAU;IAC/C,0EAA0E;IAE1E;;;;;;;;;;OAUG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,wCAAwC;YACxC,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;YACtE,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,IAAI,GAAG,CAAC,CAAC;YAC7E,MAAM,sBAAsB,GAAG,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,wBAAwB,CAAC,IAAI,KAAK,CAAC,CAAC;YACzG,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,CAAC;YAE/E,0BAA0B;YAC1B,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1D,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,eAAe;oBAC3B,OAAO,EAAE,2DAA2D;iBACvE,CAAC;YACN,CAAC;YAED,0BAA0B;YAC1B,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,EAAE,EAAE,CAAC;gBACpC,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,eAAe;oBAC3B,OAAO,EAAE,qCAAqC;iBACjD,CAAC;YACN,CAAC;YAED,IAAI,sBAAsB,GAAG,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AC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;QAC1C,CAAC;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAuB,EAAE,IAAY;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACnF,OAAO,KAAK,EAAE,KAAK,CAAC;IACxB,CAAC;CACJ,CAAA;AA3KY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,sBAAa,EAAC,oBAAU,EAAE,iBAAiB,CAAC;GAChC,mBAAmB,CA2K/B;AAED;;GAEG;AACH,SAAgB,uBAAuB;IACnC,wCAAwC;AAC5C,CAAC;AAFD,0DAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"send-single-message.action.d.ts","sourceRoot":"","sources":["../../../src/custom/communication/send-single-message.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;;;GAWG;AACH,qBACa,uBAAwB,SAAQ,UAAU;cACnC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAkC1F;AAED,wBAAgB,2BAA2B,SAE1C"}
1
+ {"version":3,"file":"send-single-message.action.d.ts","sourceRoot":"","sources":["../../../src/custom/communication/send-single-message.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;;;GAWG;AACH,qBACa,uBAAwB,SAAQ,UAAU;cACnC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAiD1F;AAED,wBAAgB,2BAA2B,SAE1C"}
@@ -24,30 +24,41 @@ const communication_engine_1 = require("@memberjunction/communication-engine");
24
24
  */
25
25
  let SendSingleMessageAction = class SendSingleMessageAction extends actions_1.BaseAction {
26
26
  async InternalRunAction(params) {
27
+ // Extract all parameters first
27
28
  const subject = params.Params.find(p => p.Name.trim().toLowerCase() === 'subject');
28
29
  const body = params.Params.find(p => p.Name.trim().toLowerCase() === 'body');
29
30
  const to = params.Params.find(p => p.Name.trim().toLowerCase() === 'to');
30
31
  const from = params.Params.find(p => p.Name.trim().toLowerCase() === 'from');
31
32
  const provider = params.Params.find(p => p.Name.trim().toLowerCase() === 'provider');
33
+ const messageType = params.Params.find(p => p.Name.trim().toLowerCase() === 'messagetype');
34
+ // Validate ALL required parameters exist BEFORE using their values
35
+ if (!provider || !provider.Value)
36
+ throw new Error('Provider parameter is required');
37
+ if (!messageType || !messageType.Value)
38
+ throw new Error('MessageType parameter is required');
39
+ if (!from || !from.Value)
40
+ throw new Error('From parameter is required');
41
+ if (!to || !to.Value)
42
+ throw new Error('To parameter is required');
43
+ // Initialize Communication Engine
32
44
  await communication_engine_1.CommunicationEngine.Instance.Config(false, params.ContextUser);
45
+ // Lookup provider and validate it exists BEFORE accessing properties
33
46
  const p = communication_engine_1.CommunicationEngine.Instance.Providers.find(p => p.Name === provider.Value);
34
- const messageType = params.Params.find(p => p.Name.trim().toLowerCase() === 'messagetype');
35
- const mt = p.MessageTypes.find(mt => mt.Name === messageType.Value);
36
47
  if (!p)
37
- throw new Error(`Provider ${provider.Value} not found.`);
48
+ throw new Error(`Provider '${provider.Value}' not found. Available providers: ${communication_engine_1.CommunicationEngine.Instance.Providers.map(p => p.Name).join(', ')}`);
49
+ // NOW safe to access p.MessageTypes
50
+ const mt = p.MessageTypes.find(mt => mt.Name === messageType.Value);
38
51
  if (!mt)
39
- throw new Error(`Provider Message Type ${messageType.Value} not found.`);
40
- if (!from)
41
- throw new Error(`From is required.`);
42
- if (!to)
43
- throw new Error(`To is required.`);
52
+ throw new Error(`Provider Message Type '${messageType.Value}' not found for provider '${provider.Value}'. Available message types: ${p.MessageTypes.map(mt => mt.Name).join(', ')}`);
53
+ // Build message object
44
54
  const m = {
45
55
  MessageType: mt,
46
56
  From: from.Value,
47
57
  To: to.Value,
48
- Subject: subject.Value,
49
- Body: body.Value,
58
+ Subject: subject?.Value,
59
+ Body: body?.Value,
50
60
  };
61
+ // Send message
51
62
  const result = await communication_engine_1.CommunicationEngine.Instance.SendSingleMessage(provider.Value, messageType.Value, m);
52
63
  return {
53
64
  Success: result.Success,
@@ -1 +1 @@
1
- {"version":3,"file":"send-single-message.action.js","sourceRoot":"","sources":["../../../src/custom/communication/send-single-message.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,qDAAqD;AACrD,mDAAuD;AACvD,+EAA2E;AAG3E;;;;;;;;;;;GAWG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,oBAAU;IACzC,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,CAAC;QACnF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC;QAC7E,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,CAAC;QACzE,M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C,GAAY;YACf,WAAW,EAAE,EAAE;YACf,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,EAAE,EAAE,EAAE,CAAC,KAAK;YACZ,OAAO,EAAE,OAAO,CAAC,KAAK;YACtB,IAAI,EAAE,IAAI,CAAC,KAAK;SACnB,CAAA;QACD,MAAM,MAAM,GAAG,MAAM,0CAAmB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC1G,OAAO;YACH,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,KAAK;YACrB,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;SACpD,CAAC;IACN,CAAC;CACJ,CAAA;AAnCY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAa,EAAC,oBAAU,EAAE,qBAAqB,CAAC;GACpC,uBAAuB,CAmCnC;AAED,SAAgB,2BAA2B;IACvC,uIAAuI;AAC3I,CAAC;AAFD,kEAEC"}
1
+ {"version":3,"file":"send-single-message.action.js","sourceRoot":"","sources":["../../../src/custom/communication/send-single-message.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,qDAAqD;AACrD,mDAAuD;AACvD,+EAA2E;AAG3E;;;;;;;;;;;GAWG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,oBAAU;IACzC,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,+BAA+B;QAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,CAAC;QACnF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAA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O,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,KAAK;YACrB,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;SACpD,CAAC;IACN,CAAC;CACJ,CAAA;AAlDY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAa,EAAC,oBAAU,EAAE,qBAAqB,CAAC;GACpC,uBAAuB,CAkDnC;AAED,SAAgB,2BAA2B;IACvC,uIAAuI;AAC3I,CAAC;AAFD,kEAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/core-actions",
3
- "version": "2.111.1",
3
+ "version": "2.113.0",
4
4
  "description": "Library of generated and custom actions for the core MemberJunction framework. This library is maintained by MemberJunction and includes actions for use within the framework itself.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,22 +19,22 @@
19
19
  "typescript": "^5.4.5"
20
20
  },
21
21
  "dependencies": {
22
- "@memberjunction/global": "2.111.1",
23
- "@memberjunction/core": "2.111.1",
24
- "@memberjunction/core-entities": "2.111.1",
25
- "@memberjunction/core-entities-server": "2.111.1",
26
- "@memberjunction/ai-core-plus": "2.111.1",
27
- "@memberjunction/ai-agents": "2.111.1",
28
- "@memberjunction/ai-engine-base": "2.111.1",
29
- "@memberjunction/aiengine": "2.111.1",
30
- "@memberjunction/actions": "2.111.1",
31
- "@memberjunction/code-execution": "2.111.1",
32
- "@memberjunction/communication-engine": "2.111.1",
33
- "@memberjunction/external-change-detection": "2.111.1",
34
- "@memberjunction/ai-vector-sync": "2.111.1",
35
- "@memberjunction/content-autotagging": "2.111.1",
36
- "@memberjunction/storage": "2.111.1",
37
- "@memberjunction/sqlserver-dataprovider": "2.111.1",
22
+ "@memberjunction/global": "2.113.0",
23
+ "@memberjunction/core": "2.113.0",
24
+ "@memberjunction/core-entities": "2.113.0",
25
+ "@memberjunction/core-entities-server": "2.113.0",
26
+ "@memberjunction/ai-core-plus": "2.113.0",
27
+ "@memberjunction/ai-agents": "2.113.0",
28
+ "@memberjunction/ai-engine-base": "2.113.0",
29
+ "@memberjunction/aiengine": "2.113.0",
30
+ "@memberjunction/actions": "2.113.0",
31
+ "@memberjunction/code-execution": "2.113.0",
32
+ "@memberjunction/communication-engine": "2.113.0",
33
+ "@memberjunction/external-change-detection": "2.113.0",
34
+ "@memberjunction/ai-vector-sync": "2.113.0",
35
+ "@memberjunction/content-autotagging": "2.113.0",
36
+ "@memberjunction/storage": "2.113.0",
37
+ "@memberjunction/sqlserver-dataprovider": "2.113.0",
38
38
  "axios": "^1.6.8",
39
39
  "rxjs": "^7.8.1",
40
40
  "nunjucks": "^3.2.4",