@memberjunction/core-actions 5.51.0 → 6.1.0-edge.1
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-candidate-agents.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/find-candidate-agents.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"find-candidate-agents.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/find-candidate-agents.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,yBAA0B,SAAQ,oBAAoB;IAC/D,SAAS,KAAK,WAAW,IAAI,MAAM,CAAoC;IACvE,SAAS,KAAK,sBAAsB,IAAI,OAAO,CAAiB;cAE7C,qBAAqB,CAAC,MAAM,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,uBAAuB,EAAE;CAQlI"}
|
|
@@ -4,208 +4,40 @@ 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 {
|
|
9
|
+
import { BaseFindAgentsAction } from "./base-find-agents.action.js";
|
|
10
|
+
import { getActionBooleanParam } from "./semantic-entity-search.helper.js";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Finds candidate AI agents for a given task using semantic search.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Backed by the unified `Provider.SearchEntity` pipeline (semantic mode over the
|
|
15
|
+
* daily-synced "AI Agents Search" EntityDocument). Extends the shared agent base
|
|
16
|
+
* (see {@link BaseFindAgentsAction}) to additionally surface each agent's
|
|
17
|
+
* sub-agents and default artifact type, and to optionally exclude Sub-Agents and
|
|
18
|
+
* child agents via the `ExcludeSubAgents` parameter.
|
|
19
|
+
*
|
|
20
|
+
* Inputs: `TaskDescription` (required), `MaxResults` (default 5), `MinimumSimilarityScore`
|
|
21
|
+
* (cosine 0-1, default 0.5), `IncludeInactive` (default false), `ExcludeSubAgents` (default true).
|
|
16
22
|
*
|
|
17
23
|
* @example
|
|
18
24
|
* ```typescript
|
|
19
|
-
* // Find agents for a research task
|
|
20
25
|
* await runAction({
|
|
21
26
|
* ActionName: 'Find Candidate Agents',
|
|
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
|
-
* }]
|
|
27
|
+
* Params: [{ Name: 'TaskDescription', Value: 'Research market trends' }]
|
|
32
28
|
* });
|
|
33
29
|
* ```
|
|
34
30
|
*/
|
|
35
|
-
let FindCandidateAgentsAction = class FindCandidateAgentsAction extends
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* - MinimumSimilarityScore: Minimum similarity score 0-1 (optional, default: 0.5)
|
|
44
|
-
* - IncludeInactive: Include inactive agents (optional, default: false)
|
|
45
|
-
* - ExcludeSubAgents: Exclude agents with invocation mode 'Sub-Agent' (optional, default: true)
|
|
46
|
-
*
|
|
47
|
-
* @returns Action result with matched agents
|
|
48
|
-
*/
|
|
49
|
-
async InternalRunAction(params) {
|
|
50
|
-
try {
|
|
51
|
-
// Extract and validate input parameters
|
|
52
|
-
const taskDescription = this.getParamValue(params, 'taskdescription');
|
|
53
|
-
const maxResults = parseInt(this.getParamValue(params, 'maxresults') || '5');
|
|
54
|
-
const minimumSimilarityScore = parseFloat(this.getParamValue(params, 'minimumsimilarityscore') || '0.5');
|
|
55
|
-
const includeInactive = this.getBooleanParam(params, 'includeinactive', false);
|
|
56
|
-
const excludeSubAgents = this.getBooleanParam(params, 'excludesubagents', 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 > 20) {
|
|
67
|
-
return {
|
|
68
|
-
Success: false,
|
|
69
|
-
ResultCode: 'INVALID_INPUT',
|
|
70
|
-
Message: 'MaxResults must be between 1 and 20'
|
|
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 for permission filtering
|
|
81
|
-
if (!params.ContextUser) {
|
|
82
|
-
return {
|
|
83
|
-
Success: false,
|
|
84
|
-
ResultCode: 'MISSING_USER_CONTEXT',
|
|
85
|
-
Message: 'User context required for permission filtering'
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
// Ensure AIEngine is loaded (embeddings computed during initialization)
|
|
89
|
-
await AIEngine.Instance.Config(false, params.ContextUser);
|
|
90
|
-
// Find similar agents using AIEngine's built-in method - no database round trip!
|
|
91
|
-
const matchedAgents = await AIEngine.Instance.FindSimilarAgents(taskDescription, maxResults * 3, // Get 3x results to account for filtering
|
|
92
|
-
minimumSimilarityScore);
|
|
93
|
-
// Filter by user permissions - user must have 'run' permission
|
|
94
|
-
const accessibleAgents = await AIAgentPermissionHelper.GetAccessibleAgents(params.ContextUser, 'run');
|
|
95
|
-
const accessibleAgentIds = new Set(accessibleAgents.map(a => NormalizeUUID(a.ID)));
|
|
96
|
-
// Filter matched agents by permissions
|
|
97
|
-
let permissionFilteredAgents = matchedAgents.filter(a => accessibleAgentIds.has(NormalizeUUID(a.agentId)));
|
|
98
|
-
// Filter by status if not including inactive
|
|
99
|
-
if (!includeInactive) {
|
|
100
|
-
permissionFilteredAgents = permissionFilteredAgents.filter(a => a.status === 'Active');
|
|
101
|
-
}
|
|
102
|
-
// Filter by invocation mode and parent relationship if excludeSubAgents is true
|
|
103
|
-
// Sub-Agents and child agents are meant to be called by other agents, not typically discovered by users/tools
|
|
104
|
-
let invocationFilteredAgents = permissionFilteredAgents;
|
|
105
|
-
if (excludeSubAgents) {
|
|
106
|
-
invocationFilteredAgents = permissionFilteredAgents.filter(a => a.invocationMode !== 'Sub-Agent' && !a.parentId);
|
|
107
|
-
}
|
|
108
|
-
// Limit to maxResults after all filtering
|
|
109
|
-
const filteredAgents = invocationFilteredAgents.slice(0, maxResults);
|
|
110
|
-
if (filteredAgents.length === 0) {
|
|
111
|
-
return {
|
|
112
|
-
Success: false,
|
|
113
|
-
ResultCode: 'NO_AGENTS_FOUND',
|
|
114
|
-
Message: `No accessible agents found matching the criteria (minimum similarity: ${minimumSimilarityScore}). You may not have permission to run the matching agents.`
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
// AIEngine already loaded above - use it to get agent actions
|
|
118
|
-
// Create map of agentId -> action names
|
|
119
|
-
const agentActionsMap = new Map();
|
|
120
|
-
for (const agent of filteredAgents) {
|
|
121
|
-
const agentActions = AIEngine.Instance.AgentActions
|
|
122
|
-
.filter(aa => UUIDsEqual(aa.AgentID, agent.agentId) && aa.Status === 'Active')
|
|
123
|
-
.map(aa => aa.Action); // Get action name
|
|
124
|
-
agentActionsMap.set(agent.agentId, agentActions);
|
|
125
|
-
}
|
|
126
|
-
// Create map of agentId -> sub-agents (name and description)
|
|
127
|
-
const agentSubAgentsMap = new Map();
|
|
128
|
-
for (const agent of filteredAgents) {
|
|
129
|
-
const subAgents = [];
|
|
130
|
-
// Find child agents (ParentID = this agent)
|
|
131
|
-
const childAgents = AIEngine.Instance.Agents.filter(a => UUIDsEqual(a.ParentID, agent.agentId) && a.Status === 'Active');
|
|
132
|
-
subAgents.push(...childAgents.map(a => ({
|
|
133
|
-
name: a.Name,
|
|
134
|
-
description: a.Description || ''
|
|
135
|
-
})));
|
|
136
|
-
// Find related agents (via AgentRelationships)
|
|
137
|
-
const relationships = AIEngine.Instance.AgentRelationships.filter(r => UUIDsEqual(r.AgentID, agent.agentId) && r.Status === 'Active');
|
|
138
|
-
for (const rel of relationships) {
|
|
139
|
-
const relatedAgent = AIEngine.Instance.Agents.find(a => UUIDsEqual(a.ID, rel.SubAgentID));
|
|
140
|
-
if (relatedAgent && relatedAgent.Status === 'Active') {
|
|
141
|
-
subAgents.push({
|
|
142
|
-
name: relatedAgent.Name,
|
|
143
|
-
description: relatedAgent.Description || ''
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
agentSubAgentsMap.set(agent.agentId, subAgents);
|
|
148
|
-
}
|
|
149
|
-
// Add output parameters
|
|
150
|
-
params.Params.push({
|
|
151
|
-
Name: 'MatchedAgents',
|
|
152
|
-
Type: 'Output',
|
|
153
|
-
Value: filteredAgents
|
|
154
|
-
});
|
|
155
|
-
params.Params.push({
|
|
156
|
-
Name: 'MatchCount',
|
|
157
|
-
Type: 'Output',
|
|
158
|
-
Value: filteredAgents.length
|
|
159
|
-
});
|
|
160
|
-
// Build response message with full descriptions, actions, and sub-agents
|
|
161
|
-
const responseData = {
|
|
162
|
-
message: `Found ${filteredAgents.length} accessible agent(s)`,
|
|
163
|
-
taskDescription: taskDescription,
|
|
164
|
-
matchCount: filteredAgents.length,
|
|
165
|
-
allMatches: filteredAgents.map(a => ({
|
|
166
|
-
agentId: a.agentId, // Include agent ID for direct use with Load Agent Spec
|
|
167
|
-
agentName: a.agentName,
|
|
168
|
-
similarityScore: Math.round(a.similarityScore * 100) / 100, // Round to 2 decimal places
|
|
169
|
-
description: a.description, // Full description, no truncation
|
|
170
|
-
actions: agentActionsMap.get(a.agentId) || [],
|
|
171
|
-
subAgents: agentSubAgentsMap.get(a.agentId) || [], // Sub-agents with name and description
|
|
172
|
-
defaultArtifactType: a.defaultArtifactType || null // Artifact type this agent produces
|
|
173
|
-
}))
|
|
174
|
-
};
|
|
175
|
-
return {
|
|
176
|
-
Success: true,
|
|
177
|
-
ResultCode: 'SUCCESS',
|
|
178
|
-
Message: JSON.stringify(responseData, null, 2)
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
return {
|
|
183
|
-
Success: false,
|
|
184
|
-
ResultCode: 'EXECUTION_ERROR',
|
|
185
|
-
Message: `Failed to Find Candidate Agents: ${error instanceof Error ? error.message : String(error)}`
|
|
186
|
-
};
|
|
31
|
+
let FindCandidateAgentsAction = class FindCandidateAgentsAction extends BaseFindAgentsAction {
|
|
32
|
+
get actionLabel() { return 'find candidate agents'; }
|
|
33
|
+
get includeSubAgentDetails() { return true; }
|
|
34
|
+
applyInvocationFilter(agents, params) {
|
|
35
|
+
const excludeSubAgents = getActionBooleanParam(params, 'excludesubagents', true);
|
|
36
|
+
if (excludeSubAgents) {
|
|
37
|
+
// Sub-Agents and child agents are meant to be called by other agents, not discovered directly
|
|
38
|
+
return agents.filter(a => a.InvocationMode !== 'Sub-Agent' && !a.ParentID);
|
|
187
39
|
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Get boolean parameter with default
|
|
191
|
-
*/
|
|
192
|
-
getBooleanParam(params, name, defaultValue) {
|
|
193
|
-
const value = this.getParamValue(params, name);
|
|
194
|
-
if (value === undefined || value === null)
|
|
195
|
-
return defaultValue;
|
|
196
|
-
if (typeof value === 'boolean')
|
|
197
|
-
return value;
|
|
198
|
-
if (typeof value === 'string') {
|
|
199
|
-
return value.toLowerCase() === 'true';
|
|
200
|
-
}
|
|
201
|
-
return defaultValue;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Get parameter value by name (case-insensitive)
|
|
205
|
-
*/
|
|
206
|
-
getParamValue(params, name) {
|
|
207
|
-
const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
|
|
208
|
-
return param?.Value;
|
|
40
|
+
return agents;
|
|
209
41
|
}
|
|
210
42
|
};
|
|
211
43
|
FindCandidateAgentsAction = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-candidate-agents.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-candidate-agents.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"find-candidate-agents.action.js","sourceRoot":"","sources":["../../../src/custom/ai/find-candidate-agents.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,oBAAoB;IAC/D,IAAc,WAAW,KAAa,OAAO,uBAAuB,CAAC,CAAC,CAAC;IACvE,IAAc,sBAAsB,KAAc,OAAO,IAAI,CAAC,CAAC,CAAC;IAE7C,qBAAqB,CAAC,MAAiC,EAAE,MAAuB;QAC/F,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACjF,IAAI,gBAAgB,EAAE,CAAC;YACnB,8FAA8F;YAC9F,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,WAAW,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AAZY,yBAAyB;IADrC,aAAa,CAAC,UAAU,EAAE,uBAAuB,CAAC;GACtC,yBAAyB,CAYrC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import type { EntitySearchResult } from "@memberjunction/core";
|
|
3
|
+
/**
|
|
4
|
+
* Shared helpers for the "find similar by description" actions (Find Best Action,
|
|
5
|
+
* Find Best Agent, Find Candidate Actions/Agents, Search Query Catalog).
|
|
6
|
+
*
|
|
7
|
+
* These actions used to each carry their own in-memory embedding pool (the old
|
|
8
|
+
* `AgentEmbeddingService` / `ActionEmbeddingService` on `AIEngine`). They now
|
|
9
|
+
* delegate ranking to the unified {@link IRunViewProvider.SearchEntity} pipeline,
|
|
10
|
+
* which is backed by daily-synced `EntityDocument` vectors. This module holds the
|
|
11
|
+
* thin glue they share so the wrappers stay small.
|
|
12
|
+
*/
|
|
13
|
+
/** Outcome of a semantic search attempt — ranked results on success, structured failure otherwise. */
|
|
14
|
+
export interface SemanticSearchOutcome {
|
|
15
|
+
/** True when the search ran; false when it could not (e.g., missing provider). */
|
|
16
|
+
ok: boolean;
|
|
17
|
+
/** Ranked results (empty on failure). */
|
|
18
|
+
results: EntitySearchResult[];
|
|
19
|
+
/** Action result code to surface on failure. */
|
|
20
|
+
resultCode?: string;
|
|
21
|
+
/** Human-readable failure message. */
|
|
22
|
+
message?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Runs a **semantic-only** ranked search over one entity via the invoking
|
|
26
|
+
* provider's {@link IRunViewProvider.SearchEntity}.
|
|
27
|
+
*
|
|
28
|
+
* Semantic mode is used (rather than hybrid) because these actions are drop-in
|
|
29
|
+
* replacements for the old cosine-similarity vector services: in semantic mode
|
|
30
|
+
* `EntitySearchResult.score` is the raw cosine similarity (0–1), so the legacy
|
|
31
|
+
* `MinimumSimilarityScore` threshold maps directly onto `minScore` and the
|
|
32
|
+
* returned scores stay meaningful to existing callers.
|
|
33
|
+
*
|
|
34
|
+
* Prefers the caller's threaded `params.Provider` (multi-server clients,
|
|
35
|
+
* request-scoped server-side providers, transaction-scoped work — e.g. the
|
|
36
|
+
* GraphQL `RunAction` resolver supplies it), and falls back to the global
|
|
37
|
+
* provider when none is threaded. This honors the documented
|
|
38
|
+
* `RunActionParams.Provider` contract (`params.Provider ?? new Metadata()`),
|
|
39
|
+
* which keeps the find-* actions working on the in-process invocation paths
|
|
40
|
+
* that don't thread a provider (agents, MCP, CLI, scheduled jobs) — exactly
|
|
41
|
+
* like every other action.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runSemanticEntitySearch(params: RunActionParams, entityName: string, searchText: string, topK: number, minScore: number): Promise<SemanticSearchOutcome>;
|
|
44
|
+
/** Case-insensitive lookup of a raw action parameter value. */
|
|
45
|
+
export declare function getActionParamValue(params: RunActionParams, name: string): unknown;
|
|
46
|
+
/** Case-insensitive boolean parameter accessor with a default. */
|
|
47
|
+
export declare function getActionBooleanParam(params: RunActionParams, name: string, defaultValue: boolean): boolean;
|
|
48
|
+
//# sourceMappingURL=semantic-entity-search.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-entity-search.helper.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/semantic-entity-search.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAwC,MAAM,sBAAsB,CAAC;AAErG;;;;;;;;;GASG;AAEH,sGAAsG;AACtG,MAAM,WAAW,qBAAqB;IAClC,kFAAkF;IAClF,EAAE,EAAE,OAAO,CAAC;IACZ,yCAAyC;IACzC,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,uBAAuB,CACzC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,CAAC,CAwBhC;AAED,+DAA+D;AAC/D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGlF;AAED,kEAAkE;AAClE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAM3G"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Metadata } from "@memberjunction/core";
|
|
2
|
+
/**
|
|
3
|
+
* Runs a **semantic-only** ranked search over one entity via the invoking
|
|
4
|
+
* provider's {@link IRunViewProvider.SearchEntity}.
|
|
5
|
+
*
|
|
6
|
+
* Semantic mode is used (rather than hybrid) because these actions are drop-in
|
|
7
|
+
* replacements for the old cosine-similarity vector services: in semantic mode
|
|
8
|
+
* `EntitySearchResult.score` is the raw cosine similarity (0–1), so the legacy
|
|
9
|
+
* `MinimumSimilarityScore` threshold maps directly onto `minScore` and the
|
|
10
|
+
* returned scores stay meaningful to existing callers.
|
|
11
|
+
*
|
|
12
|
+
* Prefers the caller's threaded `params.Provider` (multi-server clients,
|
|
13
|
+
* request-scoped server-side providers, transaction-scoped work — e.g. the
|
|
14
|
+
* GraphQL `RunAction` resolver supplies it), and falls back to the global
|
|
15
|
+
* provider when none is threaded. This honors the documented
|
|
16
|
+
* `RunActionParams.Provider` contract (`params.Provider ?? new Metadata()`),
|
|
17
|
+
* which keeps the find-* actions working on the in-process invocation paths
|
|
18
|
+
* that don't thread a provider (agents, MCP, CLI, scheduled jobs) — exactly
|
|
19
|
+
* like every other action.
|
|
20
|
+
*/
|
|
21
|
+
export async function runSemanticEntitySearch(params, entityName, searchText, topK, minScore) {
|
|
22
|
+
const md = (params.Provider ?? Metadata.Provider);
|
|
23
|
+
if (!md) {
|
|
24
|
+
return {
|
|
25
|
+
ok: false,
|
|
26
|
+
results: [],
|
|
27
|
+
resultCode: 'MISSING_PROVIDER',
|
|
28
|
+
message: 'No metadata provider available — semantic search requires a configured provider (threaded or global).',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const searchParams = {
|
|
32
|
+
entityName,
|
|
33
|
+
searchText,
|
|
34
|
+
options: {
|
|
35
|
+
mode: 'semantic',
|
|
36
|
+
topK,
|
|
37
|
+
minScore,
|
|
38
|
+
contextUser: params.ContextUser,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const results = await md.SearchEntity(searchParams);
|
|
42
|
+
return { ok: true, results };
|
|
43
|
+
}
|
|
44
|
+
/** Case-insensitive lookup of a raw action parameter value. */
|
|
45
|
+
export function getActionParamValue(params, name) {
|
|
46
|
+
const param = params.Params.find(p => p.Name.toLowerCase() === name.toLowerCase());
|
|
47
|
+
return param?.Value;
|
|
48
|
+
}
|
|
49
|
+
/** Case-insensitive boolean parameter accessor with a default. */
|
|
50
|
+
export function getActionBooleanParam(params, name, defaultValue) {
|
|
51
|
+
const value = getActionParamValue(params, name);
|
|
52
|
+
if (value === undefined || value === null)
|
|
53
|
+
return defaultValue;
|
|
54
|
+
if (typeof value === 'boolean')
|
|
55
|
+
return value;
|
|
56
|
+
if (typeof value === 'string')
|
|
57
|
+
return value.toLowerCase() === 'true';
|
|
58
|
+
return defaultValue;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=semantic-entity-search.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-entity-search.helper.js","sourceRoot":"","sources":["../../../src/custom/ai/semantic-entity-search.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA0BhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CACzC,MAAuB,EACvB,UAAkB,EAClB,UAAkB,EAClB,IAAY,EACZ,QAAgB;IAEhB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAA4C,CAAC;IAC7F,IAAI,CAAC,EAAE,EAAE,CAAC;QACN,OAAO;YACH,EAAE,EAAE,KAAK;YACT,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,kBAAkB;YAC9B,OAAO,EAAE,uGAAuG;SACnH,CAAC;IACN,CAAC;IAED,MAAM,YAAY,GAAuB;QACrC,UAAU;QACV,UAAU;QACV,OAAO,EAAE;YACL,IAAI,EAAE,UAAU;YAChB,IAAI;YACJ,QAAQ;YACR,WAAW,EAAE,MAAM,CAAC,WAAW;SAClC;KACJ,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACpD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACjC,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,mBAAmB,CAAC,MAAuB,EAAE,IAAY;IACrE,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;IACnF,OAAO,KAAK,EAAE,KAAK,CAAC;AACxB,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,qBAAqB,CAAC,MAAuB,EAAE,IAAY,EAAE,YAAqB;IAC9F,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,YAAY,CAAC;IAC/D,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IACrE,OAAO,YAAY,CAAC;AACxB,CAAC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
2
|
import { BaseAction } from "@memberjunction/actions";
|
|
3
3
|
/**
|
|
4
|
-
* Action that searches the saved query catalog using
|
|
4
|
+
* Action that searches the saved query catalog using semantic search.
|
|
5
5
|
* Takes a natural language description of what data is needed and returns ranked
|
|
6
6
|
* matching queries with similarity scores.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Ranking is delegated to the unified `Provider.SearchEntity` pipeline (semantic
|
|
9
|
+
* mode, backed by the daily-synced "Queries Search" EntityDocument) instead of
|
|
10
|
+
* the bespoke `QueryEngineServer.FindSimilarQueries` vector index. Matched query
|
|
11
|
+
* metadata is hydrated from QueryEngine's cache to preserve the existing ranked
|
|
12
|
+
* output + AI directive guidance.
|
|
10
13
|
*
|
|
11
14
|
* @example
|
|
12
15
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-query-catalog.action.d.ts","sourceRoot":"","sources":["../../../src/custom/data/search-query-catalog.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEhG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"search-query-catalog.action.d.ts","sourceRoot":"","sources":["../../../src/custom/data/search-query-catalog.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEhG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBACa,wBAAyB,SAAQ,UAAU;cACpC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgHvF,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,aAAa;IAKrB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAwF7B,4EAA4E;IAC5E,OAAO,CAAC,oBAAoB;IAM5B,oGAAoG;IACpG,OAAO,CAAC,iBAAiB;CAI5B"}
|
|
@@ -4,18 +4,21 @@ 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 } from "@memberjunction/global";
|
|
7
|
+
import { RegisterClass, NormalizeUUID } from "@memberjunction/global";
|
|
8
8
|
import { BaseAction } from "@memberjunction/actions";
|
|
9
|
-
import { AIEngine } from "@memberjunction/aiengine";
|
|
10
9
|
import { QueryEngineServer } from "@memberjunction/core-entities-server";
|
|
11
10
|
import { LogError } from "@memberjunction/core";
|
|
11
|
+
import { runSemanticEntitySearch } from "../ai/semantic-entity-search.helper.js";
|
|
12
12
|
/**
|
|
13
|
-
* Action that searches the saved query catalog using
|
|
13
|
+
* Action that searches the saved query catalog using semantic search.
|
|
14
14
|
* Takes a natural language description of what data is needed and returns ranked
|
|
15
15
|
* matching queries with similarity scores.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Ranking is delegated to the unified `Provider.SearchEntity` pipeline (semantic
|
|
18
|
+
* mode, backed by the daily-synced "Queries Search" EntityDocument) instead of
|
|
19
|
+
* the bespoke `QueryEngineServer.FindSimilarQueries` vector index. Matched query
|
|
20
|
+
* metadata is hydrated from QueryEngine's cache to preserve the existing ranked
|
|
21
|
+
* output + AI directive guidance.
|
|
19
22
|
*
|
|
20
23
|
* @example
|
|
21
24
|
* ```typescript
|
|
@@ -56,44 +59,51 @@ let SearchQueryCatalogAction = class SearchQueryCatalogAction extends BaseAction
|
|
|
56
59
|
Message: 'User context required'
|
|
57
60
|
};
|
|
58
61
|
}
|
|
59
|
-
//
|
|
60
|
-
await
|
|
62
|
+
// Rank via the unified SearchEntity pipeline (over-fetch to allow status/reusable filtering)
|
|
63
|
+
const search = await runSemanticEntitySearch(params, 'MJ: Queries', searchText, Math.max(topK * 3, 30), minSimilarity);
|
|
64
|
+
if (!search.ok) {
|
|
65
|
+
return { Success: false, ResultCode: search.resultCode ?? 'SEARCH_FAILED', Message: search.message ?? 'Semantic search failed' };
|
|
66
|
+
}
|
|
61
67
|
// Ensure QueryEngineServer is loaded (uses cached queries, no DB call if already loaded)
|
|
62
68
|
await QueryEngineServer.Instance.Config(false, params.ContextUser);
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
const queriesById = new Map();
|
|
70
|
+
for (const q of QueryEngineServer.Instance.Queries) {
|
|
71
|
+
queriesById.set(NormalizeUUID(q.ID), q);
|
|
72
|
+
}
|
|
73
|
+
// Hydrate + filter, preserving the search rank order
|
|
74
|
+
const results = [];
|
|
75
|
+
for (const r of search.results) {
|
|
76
|
+
const q = queriesById.get(NormalizeUUID(r.recordId));
|
|
77
|
+
if (!q)
|
|
78
|
+
continue;
|
|
79
|
+
if (approvedOnly && q.Status !== 'Approved')
|
|
80
|
+
continue;
|
|
81
|
+
if (reusableOnly && !q.Reusable)
|
|
82
|
+
continue;
|
|
83
|
+
const result = {
|
|
84
|
+
QueryID: q.ID,
|
|
85
|
+
Name: q.Name,
|
|
86
|
+
Description: q.Description,
|
|
87
|
+
Category: q.Category,
|
|
88
|
+
Similarity: Math.round(r.score * 100) / 100,
|
|
89
|
+
Status: q.Status,
|
|
90
|
+
Reusable: q.Reusable,
|
|
91
|
+
UserQuestion: q.UserQuestion
|
|
92
|
+
};
|
|
93
|
+
if (includeSQL) {
|
|
94
|
+
result.SQL = q.SQL;
|
|
95
|
+
}
|
|
96
|
+
results.push(result);
|
|
97
|
+
if (results.length >= topK)
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (results.length === 0) {
|
|
74
101
|
return {
|
|
75
102
|
Success: true,
|
|
76
103
|
ResultCode: 'NO_MATCHES',
|
|
77
104
|
Message: `No matching queries found in the catalog for: "${searchText}". Proceed with schema exploration and fresh SQL.`
|
|
78
105
|
};
|
|
79
106
|
}
|
|
80
|
-
// Format results, optionally excluding SQL
|
|
81
|
-
const results = matches.map(m => {
|
|
82
|
-
const result = {
|
|
83
|
-
QueryID: m.queryId,
|
|
84
|
-
Name: m.queryName,
|
|
85
|
-
Description: m.description,
|
|
86
|
-
Category: m.category,
|
|
87
|
-
Similarity: Math.round(m.similarityScore * 100) / 100,
|
|
88
|
-
Status: m.status,
|
|
89
|
-
Reusable: m.reusable,
|
|
90
|
-
UserQuestion: m.userQuestion
|
|
91
|
-
};
|
|
92
|
-
if (includeSQL) {
|
|
93
|
-
result.SQL = m.sql;
|
|
94
|
-
}
|
|
95
|
-
return result;
|
|
96
|
-
});
|
|
97
107
|
// Set output parameters
|
|
98
108
|
params.Params.push({
|
|
99
109
|
Name: 'Results',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-query-catalog.action.js","sourceRoot":"","sources":["../../../src/custom/data/search-query-catalog.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"search-query-catalog.action.js","sourceRoot":"","sources":["../../../src/custom/data/search-query-catalog.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,UAAU;IAC1C,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,qBAAqB;YACrB,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAC5D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;YAClE,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC;YACvF,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,cAAc,E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CAAC;QAC1C,MAAM,UAAU,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACrE,OAAO,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,CAAC;IAED,oGAAoG;IAC5F,iBAAiB,CAAC,MAA+B;QACrD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAyB,CAAC;QAC7C,OAAO,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACpD,CAAC;CACJ,CAAA;AAxOY,wBAAwB;IADpC,aAAa,CAAC,UAAU,EAAE,sBAAsB,CAAC;GACrC,wBAAwB,CAwOpC"}
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { BaseAction } from "@memberjunction/actions";
|
|
8
8
|
import { RegisterClass, UUIDsEqual } from "@memberjunction/global";
|
|
9
9
|
import { LogError, LogStatusEx, IsVerboseLoggingEnabled, Metadata } from "@memberjunction/core";
|
|
10
|
-
import { SearchEngine,
|
|
10
|
+
import { SearchEngine, GetSearchScopePermissionResolver } from "@memberjunction/search-engine";
|
|
11
11
|
import { SearchEngineBase } from "@memberjunction/core-entities";
|
|
12
12
|
/**
|
|
13
13
|
* `__Scoped_Search` — scope-aware universal search for AI agents.
|
|
@@ -189,7 +189,7 @@ let ScopedSearchAction = class ScopedSearchAction extends BaseAction {
|
|
|
189
189
|
async enforceUserPermission(agent, scopeID, query, params, startTime) {
|
|
190
190
|
if (!scopeID)
|
|
191
191
|
return null;
|
|
192
|
-
const permResolver =
|
|
192
|
+
const permResolver = GetSearchScopePermissionResolver();
|
|
193
193
|
const verdict = await permResolver.ResolveEffectivePermission({
|
|
194
194
|
User: params.ContextUser,
|
|
195
195
|
SearchScopeID: scopeID,
|