@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.
Files changed (36) hide show
  1. package/LICENSE +7 -0
  2. package/dist/custom/ai/base-find-actions.action.d.ts +22 -0
  3. package/dist/custom/ai/base-find-actions.action.d.ts.map +1 -0
  4. package/dist/custom/ai/base-find-actions.action.js +118 -0
  5. package/dist/custom/ai/base-find-actions.action.js.map +1 -0
  6. package/dist/custom/ai/base-find-agents.action.d.ts +40 -0
  7. package/dist/custom/ai/base-find-agents.action.d.ts.map +1 -0
  8. package/dist/custom/ai/base-find-agents.action.js +139 -0
  9. package/dist/custom/ai/base-find-agents.action.js.map +1 -0
  10. package/dist/custom/ai/find-best-action.action.d.ts +12 -37
  11. package/dist/custom/ai/find-best-action.action.d.ts.map +1 -1
  12. package/dist/custom/ai/find-best-action.action.js +12 -177
  13. package/dist/custom/ai/find-best-action.action.js.map +1 -1
  14. package/dist/custom/ai/find-best-agent.action.d.ts +13 -37
  15. package/dist/custom/ai/find-best-agent.action.d.ts.map +1 -1
  16. package/dist/custom/ai/find-best-agent.action.js +14 -162
  17. package/dist/custom/ai/find-best-agent.action.js.map +1 -1
  18. package/dist/custom/ai/find-candidate-actions.action.d.ts +11 -37
  19. package/dist/custom/ai/find-candidate-actions.action.d.ts.map +1 -1
  20. package/dist/custom/ai/find-candidate-actions.action.js +11 -177
  21. package/dist/custom/ai/find-candidate-actions.action.js.map +1 -1
  22. package/dist/custom/ai/find-candidate-agents.action.d.ts +17 -38
  23. package/dist/custom/ai/find-candidate-agents.action.d.ts.map +1 -1
  24. package/dist/custom/ai/find-candidate-agents.action.js +22 -190
  25. package/dist/custom/ai/find-candidate-agents.action.js.map +1 -1
  26. package/dist/custom/ai/semantic-entity-search.helper.d.ts +48 -0
  27. package/dist/custom/ai/semantic-entity-search.helper.d.ts.map +1 -0
  28. package/dist/custom/ai/semantic-entity-search.helper.js +60 -0
  29. package/dist/custom/ai/semantic-entity-search.helper.js.map +1 -0
  30. package/dist/custom/data/search-query-catalog.action.d.ts +6 -3
  31. package/dist/custom/data/search-query-catalog.action.d.ts.map +1 -1
  32. package/dist/custom/data/search-query-catalog.action.js +45 -35
  33. package/dist/custom/data/search-query-catalog.action.js.map +1 -1
  34. package/dist/custom/search/scoped-search.action.js +2 -2
  35. package/dist/custom/search/scoped-search.action.js.map +1 -1
  36. 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":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,UAAU;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,eA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C,UAAU,EAAE,kBAAkB,CAAC;GACjC,oBAAoB,CAsLhC"}
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 { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
- import { BaseAction } from "@memberjunction/actions";
1
+ import { BaseFindAgentsAction } from "./base-find-agents.action.js";
3
2
  /**
4
- * Action that finds the best-matching AI agents for a given task using embedding-based semantic search.
3
+ * Finds the best-matching AI agents for a given task using semantic search.
5
4
  *
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.
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 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;
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":"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"}
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, UUIDsEqual, NormalizeUUID } from "@memberjunction/global";
7
+ import { RegisterClass } from "@memberjunction/global";
8
8
  import { BaseAction } from "@memberjunction/actions";
9
- import { AIEngine } from "@memberjunction/aiengine";
10
- import { AIAgentPermissionHelper } from "@memberjunction/ai-engine-base";
9
+ import { BaseFindAgentsAction } from "./base-find-agents.action.js";
11
10
  /**
12
- * Action that finds the best-matching AI agents for a given task using embedding-based semantic search.
11
+ * Finds the best-matching AI agents for a given task using semantic search.
13
12
  *
14
- * This action uses local embeddings to perform fast similarity search across all available agents,
15
- * returning the most relevant agents based on their descriptions and capabilities.
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 BaseAction {
36
- // Singleton initialization removed - AIEngine handles embedding lifecycle
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":[],"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,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;AA3KY,mBAAmB;IAD/B,aAAa,CAAC,UAAU,EAAE,iBAAiB,CAAC;GAChC,mBAAmB,CA2K/B"}
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 { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
- import { BaseAction } from "@memberjunction/actions";
1
+ import { BaseFindActionsAction } from "./base-find-actions.action.js";
3
2
  /**
4
- * Action that finds the best-matching actions for a given task using embedding-based semantic search.
3
+ * Finds candidate actions for a given task using semantic search.
5
4
  *
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.
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 BaseAction {
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":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,0BAA2B,SAAQ,UAAU;IACtD;;;;;;;;;;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"}
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 { AIEngine } from "@memberjunction/aiengine";
10
- import { RunView } from "@memberjunction/core";
9
+ import { BaseFindActionsAction } from "./base-find-actions.action.js";
11
10
  /**
12
- * Action that finds the best-matching actions for a given task using embedding-based semantic search.
11
+ * Finds candidate actions for a given task using semantic search.
13
12
  *
14
- * This action uses local embeddings to perform fast similarity search across all available actions,
15
- * returning the most relevant actions based on their descriptions and capabilities.
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 BaseAction {
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":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,UAAU;IACtD;;;;;;;;;;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,IA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,EAAE,CAAC,CAAC;aACjD,CAAC;QAEN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,iBAAiB;gBAC7B,OAAO,EAAE,qCAAqC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACzG,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,0BAA0B;IADtC,aAAa,CAAC,UAAU,EAAE,wBAAwB,CAAC;GACvC,0BAA0B,CAsLtC"}
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 { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
- import { BaseAction } from "@memberjunction/actions";
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
- * Action that finds the best-matching AI agents for a given task using embedding-based semantic search.
5
+ * Finds candidate AI agents for a given task using semantic search.
5
6
  *
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.
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 BaseAction {
28
- /**
29
- * Executes the Find Candidate Agents 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
- * - 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