@memberjunction/core-actions 5.51.0 → 6.1.0-edge.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/LICENSE +7 -0
- package/dist/custom/ai/base-find-actions.action.d.ts +22 -0
- package/dist/custom/ai/base-find-actions.action.d.ts.map +1 -0
- package/dist/custom/ai/base-find-actions.action.js +118 -0
- package/dist/custom/ai/base-find-actions.action.js.map +1 -0
- package/dist/custom/ai/base-find-agents.action.d.ts +40 -0
- package/dist/custom/ai/base-find-agents.action.d.ts.map +1 -0
- package/dist/custom/ai/base-find-agents.action.js +139 -0
- package/dist/custom/ai/base-find-agents.action.js.map +1 -0
- package/dist/custom/ai/find-best-action.action.d.ts +12 -37
- package/dist/custom/ai/find-best-action.action.d.ts.map +1 -1
- package/dist/custom/ai/find-best-action.action.js +12 -177
- package/dist/custom/ai/find-best-action.action.js.map +1 -1
- package/dist/custom/ai/find-best-agent.action.d.ts +13 -37
- package/dist/custom/ai/find-best-agent.action.d.ts.map +1 -1
- package/dist/custom/ai/find-best-agent.action.js +14 -162
- package/dist/custom/ai/find-best-agent.action.js.map +1 -1
- package/dist/custom/ai/find-candidate-actions.action.d.ts +11 -37
- package/dist/custom/ai/find-candidate-actions.action.d.ts.map +1 -1
- package/dist/custom/ai/find-candidate-actions.action.js +11 -177
- package/dist/custom/ai/find-candidate-actions.action.js.map +1 -1
- package/dist/custom/ai/find-candidate-agents.action.d.ts +17 -38
- package/dist/custom/ai/find-candidate-agents.action.d.ts.map +1 -1
- package/dist/custom/ai/find-candidate-agents.action.js +22 -190
- package/dist/custom/ai/find-candidate-agents.action.js.map +1 -1
- package/dist/custom/ai/semantic-entity-search.helper.d.ts +48 -0
- package/dist/custom/ai/semantic-entity-search.helper.d.ts.map +1 -0
- package/dist/custom/ai/semantic-entity-search.helper.js +60 -0
- package/dist/custom/ai/semantic-entity-search.helper.js.map +1 -0
- package/dist/custom/data/search-query-catalog.action.d.ts +6 -3
- package/dist/custom/data/search-query-catalog.action.d.ts.map +1 -1
- package/dist/custom/data/search-query-catalog.action.js +45 -35
- package/dist/custom/data/search-query-catalog.action.js.map +1 -1
- package/dist/custom/search/scoped-search.action.js +2 -2
- package/dist/custom/search/scoped-search.action.js.map +1 -1
- package/package.json +46 -46
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-best-action.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-best-action.action.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"find-best-action.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-best-action.action.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;;;;;;;;;;GAkBG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,qBAAqB;IAC3D,IAAc,WAAW,KAAa,OAAO,kBAAkB,CAAC,CAAC,CAAC;CACrE,CAAA;AAFY,oBAAoB;IADhC,aAAa,CAAC,UAAU,EAAE,kBAAkB,CAAC;GACjC,oBAAoB,CAEhC"}
|
|
@@ -1,49 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseAction } from "@memberjunction/actions";
|
|
1
|
+
import { BaseFindAgentsAction } from "./base-find-agents.action.js";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Finds the best-matching AI agents for a given task using semantic search.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* @deprecated Prefer the generic **Search Entity** action
|
|
6
|
+
* (`SearchEntity({ entityName: 'MJ: AI Agents', searchText, options })`). This action
|
|
7
|
+
* is retained as a thin, backward-compatible wrapper around `Provider.SearchEntity`
|
|
8
|
+
* (semantic mode, backed by the daily-synced "AI Agents Search" EntityDocument),
|
|
9
|
+
* with run-permission filtering and Sub-Agent exclusion preserved.
|
|
10
|
+
*
|
|
11
|
+
* Inputs: `TaskDescription` (required), `MaxResults` (default 5), `MinimumSimilarityScore`
|
|
12
|
+
* (cosine 0-1, default 0.5), `IncludeInactive` (default false).
|
|
8
13
|
*
|
|
9
14
|
* @example
|
|
10
15
|
* ```typescript
|
|
11
|
-
* // Find agents for a research task
|
|
12
16
|
* await runAction({
|
|
13
17
|
* 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
|
-
* }]
|
|
18
|
+
* Params: [{ Name: 'TaskDescription', Value: 'Research market trends' }]
|
|
24
19
|
* });
|
|
25
20
|
* ```
|
|
26
21
|
*/
|
|
27
|
-
export declare class FindBestAgentAction extends
|
|
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;
|
|
22
|
+
export declare class FindBestAgentAction extends BaseFindAgentsAction {
|
|
23
|
+
protected get actionLabel(): string;
|
|
48
24
|
}
|
|
49
25
|
//# sourceMappingURL=find-best-agent.action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-best-agent.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/find-best-agent.action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find-best-agent.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/find-best-agent.action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,mBAAoB,SAAQ,oBAAoB;IACzD,SAAS,KAAK,WAAW,IAAI,MAAM,CAA8B;CACpE"}
|
|
@@ -4,179 +4,31 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
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;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { RegisterClass
|
|
7
|
+
import { RegisterClass } from "@memberjunction/global";
|
|
8
8
|
import { BaseAction } from "@memberjunction/actions";
|
|
9
|
-
import {
|
|
10
|
-
import { AIAgentPermissionHelper } from "@memberjunction/ai-engine-base";
|
|
9
|
+
import { BaseFindAgentsAction } from "./base-find-agents.action.js";
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* Finds the best-matching AI agents for a given task using semantic search.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* @deprecated Prefer the generic **Search Entity** action
|
|
14
|
+
* (`SearchEntity({ entityName: 'MJ: AI Agents', searchText, options })`). This action
|
|
15
|
+
* is retained as a thin, backward-compatible wrapper around `Provider.SearchEntity`
|
|
16
|
+
* (semantic mode, backed by the daily-synced "AI Agents Search" EntityDocument),
|
|
17
|
+
* with run-permission filtering and Sub-Agent exclusion preserved.
|
|
18
|
+
*
|
|
19
|
+
* Inputs: `TaskDescription` (required), `MaxResults` (default 5), `MinimumSimilarityScore`
|
|
20
|
+
* (cosine 0-1, default 0.5), `IncludeInactive` (default false).
|
|
16
21
|
*
|
|
17
22
|
* @example
|
|
18
23
|
* ```typescript
|
|
19
|
-
* // Find agents for a research task
|
|
20
24
|
* await runAction({
|
|
21
25
|
* ActionName: 'Find Best Agent',
|
|
22
|
-
* Params: [{
|
|
23
|
-
* Name: 'TaskDescription',
|
|
24
|
-
* Value: 'Research market trends and compile a comprehensive report'
|
|
25
|
-
* }, {
|
|
26
|
-
* Name: 'MaxResults',
|
|
27
|
-
* Value: 5
|
|
28
|
-
* }, {
|
|
29
|
-
* Name: 'MinimumSimilarityScore',
|
|
30
|
-
* Value: 0.7
|
|
31
|
-
* }]
|
|
26
|
+
* Params: [{ Name: 'TaskDescription', Value: 'Research market trends' }]
|
|
32
27
|
* });
|
|
33
28
|
* ```
|
|
34
29
|
*/
|
|
35
|
-
let FindBestAgentAction = class FindBestAgentAction extends
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Executes the Find Best Agent action.
|
|
39
|
-
*
|
|
40
|
-
* @param params - The action parameters containing:
|
|
41
|
-
* - TaskDescription: Description of the task to find agents for (required)
|
|
42
|
-
* - MaxResults: Maximum number of agents to return (optional, default: 5)
|
|
43
|
-
* - MinimumSimilarityScore: Minimum similarity score 0-1 (optional, default: 0.5)
|
|
44
|
-
* - IncludeInactive: Include inactive agents (optional, default: false)
|
|
45
|
-
*
|
|
46
|
-
* @returns Action result with matched agents
|
|
47
|
-
*/
|
|
48
|
-
async InternalRunAction(params) {
|
|
49
|
-
try {
|
|
50
|
-
// Extract and validate input parameters
|
|
51
|
-
const taskDescription = this.getParamValue(params, 'taskdescription');
|
|
52
|
-
const maxResults = parseInt(this.getParamValue(params, 'maxresults') || '5');
|
|
53
|
-
const minimumSimilarityScore = parseFloat(this.getParamValue(params, 'minimumsimilarityscore') || '0.5');
|
|
54
|
-
const includeInactive = this.getBooleanParam(params, 'includeinactive', false);
|
|
55
|
-
// Validate required input
|
|
56
|
-
if (!taskDescription || taskDescription.trim().length === 0) {
|
|
57
|
-
return {
|
|
58
|
-
Success: false,
|
|
59
|
-
ResultCode: 'INVALID_INPUT',
|
|
60
|
-
Message: 'TaskDescription parameter is required and cannot be empty'
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
// Validate numeric ranges
|
|
64
|
-
if (maxResults < 1 || maxResults > 20) {
|
|
65
|
-
return {
|
|
66
|
-
Success: false,
|
|
67
|
-
ResultCode: 'INVALID_INPUT',
|
|
68
|
-
Message: 'MaxResults must be between 1 and 20'
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
if (minimumSimilarityScore < 0 || minimumSimilarityScore > 1) {
|
|
72
|
-
return {
|
|
73
|
-
Success: false,
|
|
74
|
-
ResultCode: 'INVALID_INPUT',
|
|
75
|
-
Message: 'MinimumSimilarityScore must be between 0 and 1'
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
// Validate contextUser is provided for permission filtering
|
|
79
|
-
if (!params.ContextUser) {
|
|
80
|
-
return {
|
|
81
|
-
Success: false,
|
|
82
|
-
ResultCode: 'MISSING_USER_CONTEXT',
|
|
83
|
-
Message: 'User context required for permission filtering'
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
// Ensure AIEngine is loaded (embeddings computed during initialization)
|
|
87
|
-
await AIEngine.Instance.Config(false, params.ContextUser);
|
|
88
|
-
// Find similar agents using AIEngine's built-in method - no database round trip!
|
|
89
|
-
const matchedAgents = await AIEngine.Instance.FindSimilarAgents(taskDescription, maxResults * 3, // Get 3x results to account for filtering
|
|
90
|
-
minimumSimilarityScore);
|
|
91
|
-
// Filter by user permissions - user must have 'run' permission
|
|
92
|
-
const accessibleAgents = await AIAgentPermissionHelper.GetAccessibleAgents(params.ContextUser, 'run');
|
|
93
|
-
const accessibleAgentIds = new Set(accessibleAgents.map(a => NormalizeUUID(a.ID)));
|
|
94
|
-
// Filter matched agents by permissions
|
|
95
|
-
let permissionFilteredAgents = matchedAgents.filter(a => accessibleAgentIds.has(NormalizeUUID(a.agentId)));
|
|
96
|
-
// Filter by status if not including inactive
|
|
97
|
-
if (!includeInactive) {
|
|
98
|
-
permissionFilteredAgents = permissionFilteredAgents.filter(a => a.status === 'Active');
|
|
99
|
-
}
|
|
100
|
-
// Filter by invocation mode - exclude Sub-Agent agents (only show Any or Top-Level)
|
|
101
|
-
// Sub-Agents are meant to be called by other agents, not discovered by users/tools
|
|
102
|
-
const invocationFilteredAgents = permissionFilteredAgents.filter(a => a.invocationMode !== 'Sub-Agent');
|
|
103
|
-
// Limit to maxResults after all filtering
|
|
104
|
-
const filteredAgents = invocationFilteredAgents.slice(0, maxResults);
|
|
105
|
-
if (filteredAgents.length === 0) {
|
|
106
|
-
return {
|
|
107
|
-
Success: false,
|
|
108
|
-
ResultCode: 'NO_AGENTS_FOUND',
|
|
109
|
-
Message: `No accessible agents found matching the criteria (minimum similarity: ${minimumSimilarityScore}). You may not have permission to run the matching agents.`
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
// AIEngine already loaded above - use it to get agent actions
|
|
113
|
-
// Create map of agentId -> action names
|
|
114
|
-
const agentActionsMap = new Map();
|
|
115
|
-
for (const agent of filteredAgents) {
|
|
116
|
-
const agentActions = AIEngine.Instance.AgentActions
|
|
117
|
-
.filter(aa => UUIDsEqual(aa.AgentID, agent.agentId) && aa.Status === 'Active')
|
|
118
|
-
.map(aa => aa.Action); // Get action name
|
|
119
|
-
agentActionsMap.set(agent.agentId, agentActions);
|
|
120
|
-
}
|
|
121
|
-
// Add output parameters
|
|
122
|
-
params.Params.push({
|
|
123
|
-
Name: 'MatchedAgents',
|
|
124
|
-
Type: 'Output',
|
|
125
|
-
Value: filteredAgents
|
|
126
|
-
});
|
|
127
|
-
params.Params.push({
|
|
128
|
-
Name: 'MatchCount',
|
|
129
|
-
Type: 'Output',
|
|
130
|
-
Value: filteredAgents.length
|
|
131
|
-
});
|
|
132
|
-
// Build response message with full descriptions and actions
|
|
133
|
-
const responseData = {
|
|
134
|
-
message: `Found ${filteredAgents.length} accessible agent(s)`,
|
|
135
|
-
taskDescription: taskDescription,
|
|
136
|
-
matchCount: filteredAgents.length,
|
|
137
|
-
allMatches: filteredAgents.map(a => ({
|
|
138
|
-
agentId: a.agentId, // Include agent ID for direct use with Load Agent Spec
|
|
139
|
-
agentName: a.agentName,
|
|
140
|
-
similarityScore: Math.round(a.similarityScore * 100) / 100, // Round to 2 decimal places
|
|
141
|
-
description: a.description, // Full description, no truncation
|
|
142
|
-
actions: agentActionsMap.get(a.agentId) || []
|
|
143
|
-
}))
|
|
144
|
-
};
|
|
145
|
-
return {
|
|
146
|
-
Success: true,
|
|
147
|
-
ResultCode: 'SUCCESS',
|
|
148
|
-
Message: JSON.stringify(responseData, null, 2)
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
return {
|
|
153
|
-
Success: false,
|
|
154
|
-
ResultCode: 'EXECUTION_ERROR',
|
|
155
|
-
Message: `Failed to find best agent: ${error instanceof Error ? error.message : String(error)}`
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Get boolean parameter with default
|
|
161
|
-
*/
|
|
162
|
-
getBooleanParam(params, name, defaultValue) {
|
|
163
|
-
const value = this.getParamValue(params, name);
|
|
164
|
-
if (value === undefined || value === null)
|
|
165
|
-
return defaultValue;
|
|
166
|
-
if (typeof value === 'boolean')
|
|
167
|
-
return value;
|
|
168
|
-
if (typeof value === 'string') {
|
|
169
|
-
return value.toLowerCase() === 'true';
|
|
170
|
-
}
|
|
171
|
-
return defaultValue;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Get parameter value by name (case-insensitive)
|
|
175
|
-
*/
|
|
176
|
-
getParamValue(params, name) {
|
|
177
|
-
const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
|
|
178
|
-
return param?.Value;
|
|
179
|
-
}
|
|
30
|
+
let FindBestAgentAction = class FindBestAgentAction extends BaseFindAgentsAction {
|
|
31
|
+
get actionLabel() { return 'find best agent'; }
|
|
180
32
|
};
|
|
181
33
|
FindBestAgentAction = __decorate([
|
|
182
34
|
RegisterClass(BaseAction, "Find Best Agent")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-best-agent.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-best-agent.action.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"find-best-agent.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-best-agent.action.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,oBAAoB;IACzD,IAAc,WAAW,KAAa,OAAO,iBAAiB,CAAC,CAAC,CAAC;CACpE,CAAA;AAFY,mBAAmB;IAD/B,aAAa,CAAC,UAAU,EAAE,iBAAiB,CAAC;GAChC,mBAAmB,CAE/B"}
|
|
@@ -1,49 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseAction } from "@memberjunction/actions";
|
|
1
|
+
import { BaseFindActionsAction } from "./base-find-actions.action.js";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Finds candidate actions for a given task using semantic search.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Backed by the unified `Provider.SearchEntity` pipeline (semantic mode over the
|
|
6
|
+
* daily-synced "Actions Search" EntityDocument). Shares all behavior with
|
|
7
|
+
* "Find Best Action" — see {@link BaseFindActionsAction}.
|
|
8
|
+
*
|
|
9
|
+
* Inputs: `TaskDescription` (required), `MaxResults` (default 10), `MinimumSimilarityScore`
|
|
10
|
+
* (cosine 0-1, default 0.5), `ExcludeAgentManagement` (default true).
|
|
8
11
|
*
|
|
9
12
|
* @example
|
|
10
13
|
* ```typescript
|
|
11
|
-
* // Find actions for a web search task
|
|
12
14
|
* await runAction({
|
|
13
15
|
* ActionName: 'Find Candidate Actions',
|
|
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
|
-
* }]
|
|
16
|
+
* Params: [{ Name: 'TaskDescription', Value: 'Search the internet for information' }]
|
|
24
17
|
* });
|
|
25
18
|
* ```
|
|
26
19
|
*/
|
|
27
|
-
export declare class FindCandidateActionsAction extends
|
|
28
|
-
|
|
29
|
-
* Executes the Find Candidate Actions 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;
|
|
20
|
+
export declare class FindCandidateActionsAction extends BaseFindActionsAction {
|
|
21
|
+
protected get actionLabel(): string;
|
|
48
22
|
}
|
|
49
23
|
//# sourceMappingURL=find-candidate-actions.action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-candidate-actions.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/find-candidate-actions.action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find-candidate-actions.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/find-candidate-actions.action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,0BAA2B,SAAQ,qBAAqB;IACjE,SAAS,KAAK,WAAW,IAAI,MAAM,CAAqC;CAC3E"}
|
|
@@ -6,193 +6,27 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { RegisterClass } from "@memberjunction/global";
|
|
8
8
|
import { BaseAction } from "@memberjunction/actions";
|
|
9
|
-
import {
|
|
10
|
-
import { RunView } from "@memberjunction/core";
|
|
9
|
+
import { BaseFindActionsAction } from "./base-find-actions.action.js";
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* Finds candidate actions for a given task using semantic search.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Backed by the unified `Provider.SearchEntity` pipeline (semantic mode over the
|
|
14
|
+
* daily-synced "Actions Search" EntityDocument). Shares all behavior with
|
|
15
|
+
* "Find Best Action" — see {@link BaseFindActionsAction}.
|
|
16
|
+
*
|
|
17
|
+
* Inputs: `TaskDescription` (required), `MaxResults` (default 10), `MinimumSimilarityScore`
|
|
18
|
+
* (cosine 0-1, default 0.5), `ExcludeAgentManagement` (default true).
|
|
16
19
|
*
|
|
17
20
|
* @example
|
|
18
21
|
* ```typescript
|
|
19
|
-
* // Find actions for a web search task
|
|
20
22
|
* await runAction({
|
|
21
23
|
* ActionName: 'Find Candidate Actions',
|
|
22
|
-
* Params: [{
|
|
23
|
-
* Name: 'TaskDescription',
|
|
24
|
-
* Value: 'Search the internet for information on a topic'
|
|
25
|
-
* }, {
|
|
26
|
-
* Name: 'MaxResults',
|
|
27
|
-
* Value: 5
|
|
28
|
-
* }, {
|
|
29
|
-
* Name: 'MinimumSimilarityScore',
|
|
30
|
-
* Value: 0.6
|
|
31
|
-
* }]
|
|
24
|
+
* Params: [{ Name: 'TaskDescription', Value: 'Search the internet for information' }]
|
|
32
25
|
* });
|
|
33
26
|
* ```
|
|
34
27
|
*/
|
|
35
|
-
let FindCandidateActionsAction = class FindCandidateActionsAction extends
|
|
36
|
-
|
|
37
|
-
* Executes the Find Candidate Actions action.
|
|
38
|
-
*
|
|
39
|
-
* @param params - The action parameters containing:
|
|
40
|
-
* - TaskDescription: Description of the task to find actions for (required)
|
|
41
|
-
* - MaxResults: Maximum number of actions to return (optional, default: 10)
|
|
42
|
-
* - MinimumSimilarityScore: Minimum similarity score 0-1 (optional, default: 0.5)
|
|
43
|
-
* - ExcludeAgentManagement: Exclude Agent Management actions (optional, default: true)
|
|
44
|
-
*
|
|
45
|
-
* @returns Action result with matched actions
|
|
46
|
-
*/
|
|
47
|
-
async InternalRunAction(params) {
|
|
48
|
-
try {
|
|
49
|
-
// Extract and validate input parameters
|
|
50
|
-
const taskDescription = this.getParamValue(params, 'taskdescription');
|
|
51
|
-
const maxResults = parseInt(this.getParamValue(params, 'maxresults') || '10');
|
|
52
|
-
const minimumSimilarityScore = parseFloat(this.getParamValue(params, 'minimumsimilarityscore') || '0.5');
|
|
53
|
-
const excludeAgentManagement = this.getBooleanParam(params, 'excludeagentmanagement', true);
|
|
54
|
-
// Validate required input
|
|
55
|
-
if (!taskDescription || taskDescription.trim().length === 0) {
|
|
56
|
-
return {
|
|
57
|
-
Success: false,
|
|
58
|
-
ResultCode: 'INVALID_INPUT',
|
|
59
|
-
Message: 'TaskDescription parameter is required and cannot be empty'
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
// Validate numeric ranges
|
|
63
|
-
if (maxResults < 1 || maxResults > 50) {
|
|
64
|
-
return {
|
|
65
|
-
Success: false,
|
|
66
|
-
ResultCode: 'INVALID_INPUT',
|
|
67
|
-
Message: 'MaxResults must be between 1 and 50'
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
if (minimumSimilarityScore < 0 || minimumSimilarityScore > 1) {
|
|
71
|
-
return {
|
|
72
|
-
Success: false,
|
|
73
|
-
ResultCode: 'INVALID_INPUT',
|
|
74
|
-
Message: 'MinimumSimilarityScore must be between 0 and 1'
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
// Validate contextUser is provided
|
|
78
|
-
if (!params.ContextUser) {
|
|
79
|
-
return {
|
|
80
|
-
Success: false,
|
|
81
|
-
ResultCode: 'MISSING_USER_CONTEXT',
|
|
82
|
-
Message: 'User context required'
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
// Ensure AIEngine is loaded (embeddings computed during initialization)
|
|
86
|
-
await AIEngine.Instance.Config(false, params.ContextUser);
|
|
87
|
-
// Find similar actions using AIEngine's built-in method - no database round trip!
|
|
88
|
-
const matchedActions = await AIEngine.Instance.FindSimilarActions(taskDescription, maxResults * 2, // Get 2x results to account for filtering
|
|
89
|
-
minimumSimilarityScore);
|
|
90
|
-
// Filter out Agent Management actions if requested
|
|
91
|
-
let filteredActions = matchedActions;
|
|
92
|
-
if (excludeAgentManagement) {
|
|
93
|
-
filteredActions = matchedActions.filter(a => a.categoryName !== 'Agent Management');
|
|
94
|
-
}
|
|
95
|
-
// Limit to maxResults after filtering
|
|
96
|
-
filteredActions = filteredActions.slice(0, maxResults);
|
|
97
|
-
if (filteredActions.length === 0) {
|
|
98
|
-
return {
|
|
99
|
-
Success: false,
|
|
100
|
-
ResultCode: 'NO_ACTIONS_FOUND',
|
|
101
|
-
Message: `No actions found matching the criteria (minimum similarity: ${minimumSimilarityScore}).`
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
// Load action parameters for all matched actions
|
|
105
|
-
const actionIds = filteredActions.map(a => a.actionId);
|
|
106
|
-
const rv = new RunView();
|
|
107
|
-
const paramsResult = await rv.RunView({
|
|
108
|
-
EntityName: 'MJ: Action Params',
|
|
109
|
-
ExtraFilter: `ActionID IN ('${actionIds.join("','")}')`,
|
|
110
|
-
OrderBy: 'ActionID, Name',
|
|
111
|
-
ResultType: 'entity_object'
|
|
112
|
-
}, params.ContextUser);
|
|
113
|
-
// Group parameters by action ID
|
|
114
|
-
const paramsByActionId = new Map();
|
|
115
|
-
if (paramsResult.Success && paramsResult.Results) {
|
|
116
|
-
for (const param of paramsResult.Results) {
|
|
117
|
-
const actionId = param.ActionID;
|
|
118
|
-
if (!paramsByActionId.has(actionId)) {
|
|
119
|
-
paramsByActionId.set(actionId, []);
|
|
120
|
-
}
|
|
121
|
-
paramsByActionId.get(actionId).push(param);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// Build response with parameters included
|
|
125
|
-
const actionsWithParams = filteredActions.map(a => ({
|
|
126
|
-
actionId: a.actionId,
|
|
127
|
-
actionName: a.actionName,
|
|
128
|
-
similarityScore: Math.round(a.similarityScore * 100) / 100,
|
|
129
|
-
description: a.description,
|
|
130
|
-
categoryName: a.categoryName,
|
|
131
|
-
status: a.status,
|
|
132
|
-
driverClass: a.driverClass,
|
|
133
|
-
parameters: (paramsByActionId.get(a.actionId) || []).map(p => ({
|
|
134
|
-
name: p.Name,
|
|
135
|
-
type: p.Type, // Input/Output
|
|
136
|
-
valueType: p.ValueType,
|
|
137
|
-
isArray: p.IsArray,
|
|
138
|
-
description: p.Description,
|
|
139
|
-
isRequired: p.IsRequired,
|
|
140
|
-
defaultValue: p.DefaultValue
|
|
141
|
-
}))
|
|
142
|
-
}));
|
|
143
|
-
// Add output parameters
|
|
144
|
-
params.Params.push({
|
|
145
|
-
Name: 'MatchedActions',
|
|
146
|
-
Type: 'Output',
|
|
147
|
-
Value: actionsWithParams
|
|
148
|
-
});
|
|
149
|
-
params.Params.push({
|
|
150
|
-
Name: 'MatchCount',
|
|
151
|
-
Type: 'Output',
|
|
152
|
-
Value: filteredActions.length
|
|
153
|
-
});
|
|
154
|
-
// Build response message with full descriptions and parameters
|
|
155
|
-
const responseData = {
|
|
156
|
-
message: `Found ${filteredActions.length} relevant action(s)`,
|
|
157
|
-
taskDescription: taskDescription,
|
|
158
|
-
matchCount: filteredActions.length,
|
|
159
|
-
allMatches: actionsWithParams
|
|
160
|
-
};
|
|
161
|
-
return {
|
|
162
|
-
Success: true,
|
|
163
|
-
ResultCode: 'SUCCESS',
|
|
164
|
-
Message: JSON.stringify(responseData, null, 2)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
catch (error) {
|
|
168
|
-
return {
|
|
169
|
-
Success: false,
|
|
170
|
-
ResultCode: 'EXECUTION_ERROR',
|
|
171
|
-
Message: `Failed to Find Candidate Actions: ${error instanceof Error ? error.message : String(error)}`
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Get boolean parameter with default
|
|
177
|
-
*/
|
|
178
|
-
getBooleanParam(params, name, defaultValue) {
|
|
179
|
-
const value = this.getParamValue(params, name);
|
|
180
|
-
if (value === undefined || value === null)
|
|
181
|
-
return defaultValue;
|
|
182
|
-
if (typeof value === 'boolean')
|
|
183
|
-
return value;
|
|
184
|
-
if (typeof value === 'string') {
|
|
185
|
-
return value.toLowerCase() === 'true';
|
|
186
|
-
}
|
|
187
|
-
return defaultValue;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Get parameter value by name (case-insensitive)
|
|
191
|
-
*/
|
|
192
|
-
getParamValue(params, name) {
|
|
193
|
-
const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
|
|
194
|
-
return param?.Value;
|
|
195
|
-
}
|
|
28
|
+
let FindCandidateActionsAction = class FindCandidateActionsAction extends BaseFindActionsAction {
|
|
29
|
+
get actionLabel() { return 'find candidate actions'; }
|
|
196
30
|
};
|
|
197
31
|
FindCandidateActionsAction = __decorate([
|
|
198
32
|
RegisterClass(BaseAction, "Find Candidate Actions")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-candidate-actions.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-candidate-actions.action.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"find-candidate-actions.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-candidate-actions.action.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,qBAAqB;IACjE,IAAc,WAAW,KAAa,OAAO,wBAAwB,CAAC,CAAC,CAAC;CAC3E,CAAA;AAFY,0BAA0B;IADtC,aAAa,CAAC,UAAU,EAAE,wBAAwB,CAAC;GACvC,0BAA0B,CAEtC"}
|
|
@@ -1,50 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { MJAIAgentEntityExtended } from "@memberjunction/ai-core-plus";
|
|
3
|
+
import { BaseFindAgentsAction } from "./base-find-agents.action.js";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Finds candidate AI agents for a given task using semantic search.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Backed by the unified `Provider.SearchEntity` pipeline (semantic mode over the
|
|
8
|
+
* daily-synced "AI Agents Search" EntityDocument). Extends the shared agent base
|
|
9
|
+
* (see {@link BaseFindAgentsAction}) to additionally surface each agent's
|
|
10
|
+
* sub-agents and default artifact type, and to optionally exclude Sub-Agents and
|
|
11
|
+
* child agents via the `ExcludeSubAgents` parameter.
|
|
12
|
+
*
|
|
13
|
+
* Inputs: `TaskDescription` (required), `MaxResults` (default 5), `MinimumSimilarityScore`
|
|
14
|
+
* (cosine 0-1, default 0.5), `IncludeInactive` (default false), `ExcludeSubAgents` (default true).
|
|
8
15
|
*
|
|
9
16
|
* @example
|
|
10
17
|
* ```typescript
|
|
11
|
-
* // Find agents for a research task
|
|
12
18
|
* await runAction({
|
|
13
19
|
* ActionName: 'Find Candidate Agents',
|
|
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
|
-
* }]
|
|
20
|
+
* Params: [{ Name: 'TaskDescription', Value: 'Research market trends' }]
|
|
24
21
|
* });
|
|
25
22
|
* ```
|
|
26
23
|
*/
|
|
27
|
-
export declare class FindCandidateAgentsAction extends
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
* - ExcludeSubAgents: Exclude agents with invocation mode 'Sub-Agent' (optional, default: true)
|
|
37
|
-
*
|
|
38
|
-
* @returns Action result with matched agents
|
|
39
|
-
*/
|
|
40
|
-
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
41
|
-
/**
|
|
42
|
-
* Get boolean parameter with default
|
|
43
|
-
*/
|
|
44
|
-
private getBooleanParam;
|
|
45
|
-
/**
|
|
46
|
-
* Get parameter value by name (case-insensitive)
|
|
47
|
-
*/
|
|
48
|
-
private getParamValue;
|
|
24
|
+
export declare class FindCandidateAgentsAction extends BaseFindAgentsAction {
|
|
25
|
+
protected get actionLabel(): string;
|
|
26
|
+
protected get includeSubAgentDetails(): boolean;
|
|
27
|
+
protected applyInvocationFilter(agents: MJAIAgentEntityExtended[], params: RunActionParams): MJAIAgentEntityExtended[];
|
|
49
28
|
}
|
|
50
29
|
//# sourceMappingURL=find-candidate-agents.action.d.ts.map
|