@memberjunction/conversations-runtime 6.1.4 → 6.2.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/dist/ConversationsRuntime.d.ts +10 -0
- package/dist/ConversationsRuntime.d.ts.map +1 -1
- package/dist/ConversationsRuntime.js +12 -0
- package/dist/ConversationsRuntime.js.map +1 -1
- package/dist/agent-runner/ConversationAgentRunner.d.ts +27 -1
- package/dist/agent-runner/ConversationAgentRunner.d.ts.map +1 -1
- package/dist/agent-runner/ConversationAgentRunner.js +26 -3
- package/dist/agent-runner/ConversationAgentRunner.js.map +1 -1
- package/dist/default-agent/DefaultAgentResolver.d.ts +2 -0
- package/dist/default-agent/DefaultAgentResolver.d.ts.map +1 -1
- package/dist/default-agent/DefaultAgentResolver.js +5 -1
- package/dist/default-agent/DefaultAgentResolver.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mentions/MentionAutocomplete.d.ts +178 -0
- package/dist/mentions/MentionAutocomplete.d.ts.map +1 -0
- package/dist/mentions/MentionAutocomplete.js +507 -0
- package/dist/mentions/MentionAutocomplete.js.map +1 -0
- package/dist/mentions/MentionParser.d.ts +10 -0
- package/dist/mentions/MentionParser.d.ts.map +1 -1
- package/dist/mentions/MentionParser.js +25 -5
- package/dist/mentions/MentionParser.js.map +1 -1
- package/dist/mentions/MentionSuggestion.d.ts +92 -0
- package/dist/mentions/MentionSuggestion.d.ts.map +1 -0
- package/dist/mentions/MentionSuggestion.js +19 -0
- package/dist/mentions/MentionSuggestion.js.map +1 -0
- package/dist/mentions/SkillNarrowing.d.ts +17 -0
- package/dist/mentions/SkillNarrowing.d.ts.map +1 -0
- package/dist/mentions/SkillNarrowing.js +17 -0
- package/dist/mentions/SkillNarrowing.js.map +1 -0
- package/dist/streaming/ConversationStreaming.d.ts +34 -1
- package/dist/streaming/ConversationStreaming.d.ts.map +1 -1
- package/dist/streaming/ConversationStreaming.js +58 -14
- package/dist/streaming/ConversationStreaming.js.map +1 -1
- package/dist/timeline/RealtimeSessionTimeline.d.ts +250 -0
- package/dist/timeline/RealtimeSessionTimeline.d.ts.map +1 -0
- package/dist/timeline/RealtimeSessionTimeline.js +347 -0
- package/dist/timeline/RealtimeSessionTimeline.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
import { Metadata } from '@memberjunction/core';
|
|
2
|
+
import { AIEngineBase, AIAgentPermissionHelper, AISkillPermissionHelper } from '@memberjunction/ai-engine-base';
|
|
3
|
+
import { BaseSingleton, UUIDsEqual } from '@memberjunction/global';
|
|
4
|
+
import { IntersectAcceptedSkills } from './SkillNarrowing.js';
|
|
5
|
+
/**
|
|
6
|
+
* Shared engine behind the conversations composer plugins (the agent-mentions /
|
|
7
|
+
* record-mentions / skill-commands `ComposerTriggerProvider`s) and the mention-parsing
|
|
8
|
+
* consumers (message routing, saved-message badge rendering). Loads the
|
|
9
|
+
* permission-filtered agent / user / entity / query / skill caches once per session and
|
|
10
|
+
* serves ranked `MentionSuggestion` lists per trigger char.
|
|
11
|
+
*
|
|
12
|
+
* Framework-agnostic by construction: a `BaseSingleton` with no Angular, no DOM and no renderer
|
|
13
|
+
* in its graph. That is what lets the ClassFactory-instantiated trigger providers (which live
|
|
14
|
+
* outside Angular DI), the Angular components, and a React Native host all share ONE instance and
|
|
15
|
+
* one cache warm-up.
|
|
16
|
+
*
|
|
17
|
+
* It previously lived in `@memberjunction/ng-conversations` and was Angular-coupled only by
|
|
18
|
+
* location — no import from `@angular/*`, no decorator. A native host cannot depend on an Angular
|
|
19
|
+
* library, so the same permission filtering, skill narrowing and ranking would have had to be
|
|
20
|
+
* written a second time to reach mobile, and a second copy of a permission rule is the copy that
|
|
21
|
+
* drifts. Angular keeps a thin DI shim over this so its call sites are unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export class MentionAutocomplete extends BaseSingleton {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.agentsCache = [];
|
|
27
|
+
this.usersCache = [];
|
|
28
|
+
this.entitiesCache = [];
|
|
29
|
+
this.queriesCache = [];
|
|
30
|
+
/** Active skills the current user can Run — surfaced under the '/' trigger. */
|
|
31
|
+
this.skillsCache = [];
|
|
32
|
+
/** Default icon for a skill with no IconClass of its own. */
|
|
33
|
+
this.defaultSkillIcon = 'fa-solid fa-wand-magic-sparkles';
|
|
34
|
+
/** Generic icon for all query mentions, sourced from the 'MJ: Queries' entity. */
|
|
35
|
+
this.queriesEntityIcon = 'fa-solid fa-database';
|
|
36
|
+
this.isInitialized = false;
|
|
37
|
+
this.initializationPromise = null;
|
|
38
|
+
}
|
|
39
|
+
/** The process-wide shared instance (Global Object Store backed). */
|
|
40
|
+
static get Instance() {
|
|
41
|
+
return super.getInstance();
|
|
42
|
+
}
|
|
43
|
+
/** True once the caches have loaded (agents/users/entities/queries/skills). */
|
|
44
|
+
get IsInitialized() {
|
|
45
|
+
return this.isInitialized;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Initialize the service by loading agents and users
|
|
49
|
+
* Prevents concurrent initialization with promise lock
|
|
50
|
+
*/
|
|
51
|
+
async initialize(currentUser, provider) {
|
|
52
|
+
// If already initialized, return immediately
|
|
53
|
+
if (this.isInitialized) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// If initialization is in progress, wait for it
|
|
57
|
+
if (this.initializationPromise) {
|
|
58
|
+
return this.initializationPromise;
|
|
59
|
+
}
|
|
60
|
+
// Create initialization promise and store it
|
|
61
|
+
this.initializationPromise = this._initializeInternal(currentUser, provider);
|
|
62
|
+
try {
|
|
63
|
+
await this.initializationPromise;
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
this.initializationPromise = null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Internal initialization logic
|
|
71
|
+
*/
|
|
72
|
+
async _initializeInternal(currentUser, provider) {
|
|
73
|
+
try {
|
|
74
|
+
// Load agents from AIEngineBase
|
|
75
|
+
await AIEngineBase.Instance.Config(false);
|
|
76
|
+
const allAgents = AIEngineBase.Instance.Agents || [];
|
|
77
|
+
// Filter by status, hierarchy, and invocation mode first
|
|
78
|
+
const candidateAgents = allAgents.filter(a => !a.ParentID && a.Status === 'Active' && a.InvocationMode !== 'Sub-Agent' && !a.IsRestricted);
|
|
79
|
+
// Filter by user's 'run' permission — respects open-by-default + explicit permissions
|
|
80
|
+
this.agentsCache = await this.filterAgentsByRunPermission(candidateAgents, currentUser);
|
|
81
|
+
// Load users from the system (optional - can be expanded later)
|
|
82
|
+
// For now, we'll just use the current user
|
|
83
|
+
this.usersCache = [currentUser];
|
|
84
|
+
// Load entities the current user can read (candidates for #entity mentions)
|
|
85
|
+
this.entitiesCache = this.loadReadableEntities(currentUser, provider);
|
|
86
|
+
// Load queries the current user can run (also surfaced under the '#' trigger)
|
|
87
|
+
this.queriesCache = this.loadRunnableQueries(currentUser, provider);
|
|
88
|
+
this.queriesEntityIcon = this.resolveQueriesEntityIcon(provider);
|
|
89
|
+
// Load Active skills the current user can Run (surfaced under the '/' trigger). Mirrors the
|
|
90
|
+
// agent filter: open-by-default unless a skill has explicit permission rows. This is the user's
|
|
91
|
+
// full run-permitted set; when the host names the target agent (getSuggestions' targetAgentId)
|
|
92
|
+
// the picker narrows it to what that agent accepts, and the server's RequestedSkills guard is
|
|
93
|
+
// the backstop either way.
|
|
94
|
+
this.skillsCache = await this.filterSkillsByRunPermission(currentUser);
|
|
95
|
+
this.provider = provider;
|
|
96
|
+
this.isInitialized = true;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error('Failed to initialize MentionAutocomplete:', error);
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Filter agents to only those the current user has 'run' permission for.
|
|
105
|
+
* Agents with no permission records are open to everyone (canRun = true).
|
|
106
|
+
* Agents with explicit permission records are checked against the user.
|
|
107
|
+
*/
|
|
108
|
+
async filterAgentsByRunPermission(agents, user) {
|
|
109
|
+
const permitted = [];
|
|
110
|
+
for (const agent of agents) {
|
|
111
|
+
try {
|
|
112
|
+
const canRun = await AIAgentPermissionHelper.HasPermission(agent.ID, user, 'run');
|
|
113
|
+
if (canRun) {
|
|
114
|
+
permitted.push(agent);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Fail closed — exclude agent on error
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return permitted;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Filter Active skills to those the current user has 'run' permission for.
|
|
125
|
+
* Skills with no permission records are open to everyone (canRun = true);
|
|
126
|
+
* skills with explicit records are checked against the user (open-by-default).
|
|
127
|
+
*/
|
|
128
|
+
async filterSkillsByRunPermission(user) {
|
|
129
|
+
try {
|
|
130
|
+
const runnable = await AISkillPermissionHelper.GetAccessibleSkills(user, 'run');
|
|
131
|
+
return runnable.filter(s => s.Status === 'Active');
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Fail closed — no skills on error.
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Load entities the current user has read permission for.
|
|
140
|
+
* These are the candidates surfaced for #entity mentions.
|
|
141
|
+
*/
|
|
142
|
+
loadReadableEntities(user, provider) {
|
|
143
|
+
try {
|
|
144
|
+
const md = provider ?? Metadata.Provider;
|
|
145
|
+
return (md.Entities || []).filter(entity => {
|
|
146
|
+
try {
|
|
147
|
+
return entity.GetUserPermisions(user).CanRead;
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// Fail closed — exclude entity on permission-check error
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
console.error('Failed to load entities for mention autocomplete:', error);
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Load queries the current user has run permission for.
|
|
162
|
+
* These are the candidates surfaced for #query mentions.
|
|
163
|
+
*/
|
|
164
|
+
loadRunnableQueries(user, provider) {
|
|
165
|
+
try {
|
|
166
|
+
const md = provider ?? Metadata.Provider;
|
|
167
|
+
return (md.Queries || []).filter(query => {
|
|
168
|
+
try {
|
|
169
|
+
return query.UserCanRun(user);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
// Fail closed — exclude query on permission-check error
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
console.error('Failed to load queries for mention autocomplete:', error);
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Resolve the generic icon used for all query mentions from the 'MJ: Queries' entity.
|
|
184
|
+
*/
|
|
185
|
+
resolveQueriesEntityIcon(provider) {
|
|
186
|
+
try {
|
|
187
|
+
const md = provider ?? Metadata.Provider;
|
|
188
|
+
return md.EntityByName('MJ: Queries')?.Icon || 'fa-solid fa-database';
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return 'fa-solid fa-database';
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Get suggestions based on search query
|
|
196
|
+
* @param query The search text after the trigger character
|
|
197
|
+
* @param includeUsers Whether to include users in suggestions
|
|
198
|
+
* @param trigger '@' (agents + users), '#' (entities + queries) or '/' (skills)
|
|
199
|
+
* @param targetAgentId When the host knows which agent the message will go to (the '/' trigger
|
|
200
|
+
* only), skill suggestions are narrowed to what THAT agent accepts — `AcceptsSkills` + its
|
|
201
|
+
* `MJ: AI Agent Skills` grants — via {@link AIEngineBase.GetSkillsForAgent}. Without it (or for an
|
|
202
|
+
* agent not in the user's runnable set) the user's full runnable catalog is shown, as before, and
|
|
203
|
+
* the server's `RequestedSkills` guard is the backstop.
|
|
204
|
+
* @param scope Narrows the '@' list for one composer: the agents it may offer and the people it
|
|
205
|
+
* offers. Passed per call, never stored, because this engine is shared by every composer on the
|
|
206
|
+
* page. Omitted keeps today's list: every agent the user can run, and the current user.
|
|
207
|
+
* @returns Filtered and ranked suggestions
|
|
208
|
+
*/
|
|
209
|
+
GetSuggestions(query, includeUsers = true, trigger = '@', targetAgentId = null, scope = null) {
|
|
210
|
+
// The '#' trigger searches entities + queries; '/' searches skills; '@' searches agents + users
|
|
211
|
+
if (trigger === '#') {
|
|
212
|
+
return this.getEntityAndQuerySuggestions(query);
|
|
213
|
+
}
|
|
214
|
+
if (trigger === '/') {
|
|
215
|
+
return this.getSkillSuggestions(query, targetAgentId);
|
|
216
|
+
}
|
|
217
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
218
|
+
const suggestions = [
|
|
219
|
+
...this.getAgentSuggestions(lowerQuery, scope?.AllowedAgentIDs ?? null),
|
|
220
|
+
...(includeUsers ? this.getPeopleSuggestions(lowerQuery, scope?.People ?? null) : []),
|
|
221
|
+
];
|
|
222
|
+
// Sort by relevance: exact match > starts with > contains
|
|
223
|
+
return suggestions.sort((a, b) => {
|
|
224
|
+
const scoreA = this.calculateMatchScore(a.name, lowerQuery);
|
|
225
|
+
const scoreB = this.calculateMatchScore(b.name, lowerQuery);
|
|
226
|
+
if (scoreB !== scoreA)
|
|
227
|
+
return scoreB - scoreA;
|
|
228
|
+
// If scores are equal, sort agents before users
|
|
229
|
+
if (a.type !== b.type)
|
|
230
|
+
return a.type === 'agent' ? -1 : 1;
|
|
231
|
+
// Otherwise alphabetically
|
|
232
|
+
return a.name.localeCompare(b.name);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/** @deprecated Use {@link GetSuggestions}. */
|
|
236
|
+
getSuggestions(query, includeUsers = true, trigger = '@', targetAgentId = null, scope = null) {
|
|
237
|
+
return this.GetSuggestions(query, includeUsers, trigger, targetAgentId, scope);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Agent suggestions for '@': the user's runnable agents that match the query, narrowed to
|
|
241
|
+
* `allowedAgentIDs` when one is given (null offers every runnable agent).
|
|
242
|
+
*/
|
|
243
|
+
getAgentSuggestions(lowerQuery, allowedAgentIDs) {
|
|
244
|
+
return this.agentsCache
|
|
245
|
+
.filter(agent => allowedAgentIDs == null || allowedAgentIDs.some(id => UUIDsEqual(id, agent.ID)))
|
|
246
|
+
.filter(agent => !lowerQuery || this.calculateMatchScore(agent.Name || '', lowerQuery) > 0)
|
|
247
|
+
.map(agent => ({
|
|
248
|
+
type: 'agent',
|
|
249
|
+
id: agent.ID,
|
|
250
|
+
name: agent.Name || 'Unknown',
|
|
251
|
+
displayName: agent.Name || 'Unknown',
|
|
252
|
+
description: agent.Description || undefined,
|
|
253
|
+
imageUrl: agent.LogoURL || undefined, // Agent logo/avatar image
|
|
254
|
+
icon: this.getAgentIcon(agent),
|
|
255
|
+
// Configuration presets ride on the suggestion — the (AI-blind) composer
|
|
256
|
+
// renders a preset picker on the inserted chip when there are 2+.
|
|
257
|
+
presets: this.getAgentPresets(agent.ID)
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* People suggestions for '@': the host's list when a composer supplies one, otherwise the
|
|
262
|
+
* engine's own (which holds only the current user).
|
|
263
|
+
*/
|
|
264
|
+
getPeopleSuggestions(lowerQuery, people) {
|
|
265
|
+
const candidates = people
|
|
266
|
+
?? this.usersCache.map(user => ({ ID: user.ID, Name: user.Name, Email: user.Email }));
|
|
267
|
+
return candidates
|
|
268
|
+
.filter(person => !lowerQuery || this.calculateMatchScore(person.Name, lowerQuery) > 0)
|
|
269
|
+
.map(person => ({
|
|
270
|
+
type: 'user',
|
|
271
|
+
id: person.ID,
|
|
272
|
+
name: person.Name,
|
|
273
|
+
displayName: person.Name,
|
|
274
|
+
description: person.Email || undefined
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Get entity + query suggestions for #mentions, ranked by query match.
|
|
279
|
+
* Capped to keep the dropdown light (entity/query sets can be large).
|
|
280
|
+
*/
|
|
281
|
+
getEntityAndQuerySuggestions(query) {
|
|
282
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
283
|
+
const MAX_SUGGESTIONS = 50;
|
|
284
|
+
const entityItems = this.entitiesCache.map(entity => ({
|
|
285
|
+
label: entity.DisplayNameOrName,
|
|
286
|
+
score: Math.max(this.calculateMatchScore(entity.Name || '', lowerQuery), this.calculateMatchScore(entity.DisplayName || '', lowerQuery)),
|
|
287
|
+
suggestion: {
|
|
288
|
+
type: 'entity',
|
|
289
|
+
id: entity.ID,
|
|
290
|
+
name: entity.Name,
|
|
291
|
+
displayName: entity.DisplayNameOrName,
|
|
292
|
+
description: entity.Description || undefined,
|
|
293
|
+
icon: entity.Icon || 'fa-solid fa-table'
|
|
294
|
+
}
|
|
295
|
+
}));
|
|
296
|
+
const queryItems = this.queriesCache.map(q => ({
|
|
297
|
+
label: q.Name || '',
|
|
298
|
+
score: this.calculateMatchScore(q.Name || '', lowerQuery),
|
|
299
|
+
suggestion: {
|
|
300
|
+
type: 'query',
|
|
301
|
+
id: q.ID,
|
|
302
|
+
name: q.Name || '',
|
|
303
|
+
displayName: q.Name || '',
|
|
304
|
+
description: q.Description || undefined,
|
|
305
|
+
icon: this.queriesEntityIcon
|
|
306
|
+
}
|
|
307
|
+
}));
|
|
308
|
+
return [...entityItems, ...queryItems]
|
|
309
|
+
.filter(x => x.score > 0 || !lowerQuery)
|
|
310
|
+
.sort((a, b) => {
|
|
311
|
+
if (b.score !== a.score)
|
|
312
|
+
return b.score - a.score;
|
|
313
|
+
// When scores tie, prioritize entities over queries
|
|
314
|
+
if (a.suggestion.type !== b.suggestion.type) {
|
|
315
|
+
return a.suggestion.type === 'entity' ? -1 : 1;
|
|
316
|
+
}
|
|
317
|
+
return a.label.localeCompare(b.label);
|
|
318
|
+
})
|
|
319
|
+
.slice(0, MAX_SUGGESTIONS)
|
|
320
|
+
.map(x => x.suggestion);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* The skills to offer under '/': the user's runnable catalog, narrowed to the target agent's
|
|
324
|
+
* accepted set when the agent is known. Intersection only — the agent filter never adds a skill
|
|
325
|
+
* the user could not run. Unknown agent id (not in the user's runnable agents) → no narrowing.
|
|
326
|
+
*/
|
|
327
|
+
skillsForTarget(targetAgentId) {
|
|
328
|
+
if (!targetAgentId) {
|
|
329
|
+
return this.skillsCache;
|
|
330
|
+
}
|
|
331
|
+
const agent = this.agentsCache.find(a => UUIDsEqual(a.ID, targetAgentId));
|
|
332
|
+
if (!agent) {
|
|
333
|
+
return this.skillsCache;
|
|
334
|
+
}
|
|
335
|
+
const engine = this.provider
|
|
336
|
+
? AIEngineBase.GetProviderInstance(this.provider, AIEngineBase)
|
|
337
|
+
: AIEngineBase.Instance;
|
|
338
|
+
return IntersectAcceptedSkills(this.skillsCache, engine.GetSkillsForAgent(agent));
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Get skill suggestions for '/'-mentions, ranked by query match. Each carries the skill's own
|
|
342
|
+
* IconClass/Color (UX metadata) so the dropdown + inserted chip render distinctly per skill.
|
|
343
|
+
*/
|
|
344
|
+
getSkillSuggestions(query, targetAgentId = null) {
|
|
345
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
346
|
+
const MAX_SUGGESTIONS = 12;
|
|
347
|
+
return this.skillsForTarget(targetAgentId)
|
|
348
|
+
.map(skill => ({
|
|
349
|
+
score: this.calculateMatchScore(skill.Name || '', lowerQuery),
|
|
350
|
+
suggestion: {
|
|
351
|
+
type: 'skill',
|
|
352
|
+
id: skill.ID,
|
|
353
|
+
name: skill.Name || 'Unknown Skill',
|
|
354
|
+
displayName: skill.Name || 'Unknown Skill',
|
|
355
|
+
description: skill.Description || undefined,
|
|
356
|
+
icon: skill.IconClass || this.defaultSkillIcon,
|
|
357
|
+
color: skill.Color || undefined
|
|
358
|
+
}
|
|
359
|
+
}))
|
|
360
|
+
.filter(x => x.score > 0 || !lowerQuery)
|
|
361
|
+
.sort((a, b) => {
|
|
362
|
+
if (b.score !== a.score)
|
|
363
|
+
return b.score - a.score;
|
|
364
|
+
return a.suggestion.name.localeCompare(b.suggestion.name);
|
|
365
|
+
})
|
|
366
|
+
.slice(0, MAX_SUGGESTIONS)
|
|
367
|
+
.map(x => x.suggestion);
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Calculate match score for ranking
|
|
371
|
+
* Higher score = better match
|
|
372
|
+
*/
|
|
373
|
+
calculateMatchScore(name, query) {
|
|
374
|
+
if (!query)
|
|
375
|
+
return 1; // Show all if no query
|
|
376
|
+
const lowerName = name.toLowerCase();
|
|
377
|
+
const lowerQuery = query.toLowerCase();
|
|
378
|
+
// Exact match
|
|
379
|
+
if (lowerName === lowerQuery)
|
|
380
|
+
return 100;
|
|
381
|
+
// Starts with
|
|
382
|
+
if (lowerName.startsWith(lowerQuery))
|
|
383
|
+
return 50;
|
|
384
|
+
// Contains
|
|
385
|
+
if (lowerName.includes(lowerQuery))
|
|
386
|
+
return 25;
|
|
387
|
+
// Word boundary match (e.g., "MA" matches "Marketing Agent")
|
|
388
|
+
const words = lowerName.split(/\s+/);
|
|
389
|
+
for (const word of words) {
|
|
390
|
+
if (word.startsWith(lowerQuery))
|
|
391
|
+
return 40;
|
|
392
|
+
}
|
|
393
|
+
return 0; // No match
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Map an agent's AI Agent Configuration presets into the composer's generic
|
|
397
|
+
* `MentionSuggestionPreset` shape so the chip's preset picker works without the
|
|
398
|
+
* composer knowing anything about agents.
|
|
399
|
+
*
|
|
400
|
+
* IMPORTANT: preset.ID is the AIAgentConfiguration.ID (preset ID), not
|
|
401
|
+
* AIConfigurationID — the backend mapping converts preset ID -> AIConfigurationID.
|
|
402
|
+
*/
|
|
403
|
+
getAgentPresets(agentId) {
|
|
404
|
+
try {
|
|
405
|
+
const presets = AIEngineBase.Instance.GetAgentConfigurationPresets(agentId, true);
|
|
406
|
+
if (!presets || presets.length === 0) {
|
|
407
|
+
return undefined;
|
|
408
|
+
}
|
|
409
|
+
return presets.map(p => ({
|
|
410
|
+
ID: p.ID,
|
|
411
|
+
Name: p.Name,
|
|
412
|
+
DisplayName: p.DisplayName || undefined,
|
|
413
|
+
Description: p.Description || undefined,
|
|
414
|
+
IsDefault: p.IsDefault
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
// Presets are a chip nicety — never let them break suggestion building
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Get icon for agent based on type/name
|
|
424
|
+
*/
|
|
425
|
+
getAgentIcon(agent) {
|
|
426
|
+
// Use agent's icon if available, otherwise default based on type
|
|
427
|
+
if (agent.IconClass)
|
|
428
|
+
return agent.IconClass;
|
|
429
|
+
// Default icons based on agent name patterns
|
|
430
|
+
const name = agent.Name?.toLowerCase() || '';
|
|
431
|
+
if (name.includes('marketing'))
|
|
432
|
+
return 'fa-megaphone';
|
|
433
|
+
if (name.includes('data') || name.includes('analysis'))
|
|
434
|
+
return 'fa-chart-line';
|
|
435
|
+
if (name.includes('code') || name.includes('developer'))
|
|
436
|
+
return 'fa-code';
|
|
437
|
+
if (name.includes('design'))
|
|
438
|
+
return 'fa-palette';
|
|
439
|
+
if (name.includes('conversation') || name.includes('manager'))
|
|
440
|
+
return 'fa-comments';
|
|
441
|
+
return 'fa-robot'; // Default
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Get available agents for parsing
|
|
445
|
+
*/
|
|
446
|
+
GetAvailableAgents() {
|
|
447
|
+
return this.agentsCache;
|
|
448
|
+
}
|
|
449
|
+
/** @deprecated Use {@link GetAvailableAgents}. */
|
|
450
|
+
getAvailableAgents() {
|
|
451
|
+
return this.GetAvailableAgents();
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Get available users for parsing
|
|
455
|
+
*/
|
|
456
|
+
GetAvailableUsers() {
|
|
457
|
+
return this.usersCache;
|
|
458
|
+
}
|
|
459
|
+
/** @deprecated Use {@link GetAvailableUsers}. */
|
|
460
|
+
getAvailableUsers() {
|
|
461
|
+
return this.GetAvailableUsers();
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Get available entities for parsing
|
|
465
|
+
*/
|
|
466
|
+
GetAvailableEntities() {
|
|
467
|
+
return this.entitiesCache;
|
|
468
|
+
}
|
|
469
|
+
/** @deprecated Use {@link GetAvailableEntities}. */
|
|
470
|
+
getAvailableEntities() {
|
|
471
|
+
return this.GetAvailableEntities();
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Get available queries for parsing
|
|
475
|
+
*/
|
|
476
|
+
GetAvailableQueries() {
|
|
477
|
+
return this.queriesCache;
|
|
478
|
+
}
|
|
479
|
+
/** @deprecated Use {@link GetAvailableQueries}. */
|
|
480
|
+
getAvailableQueries() {
|
|
481
|
+
return this.GetAvailableQueries();
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Get the generic icon used for all query mentions.
|
|
485
|
+
*/
|
|
486
|
+
GetQueriesEntityIcon() {
|
|
487
|
+
return this.queriesEntityIcon;
|
|
488
|
+
}
|
|
489
|
+
/** @deprecated Use {@link GetQueriesEntityIcon}. */
|
|
490
|
+
getQueriesEntityIcon() {
|
|
491
|
+
return this.GetQueriesEntityIcon();
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Refresh the caches
|
|
495
|
+
* Resets initialization state and reloads agents
|
|
496
|
+
*/
|
|
497
|
+
async Refresh(currentUser) {
|
|
498
|
+
this.isInitialized = false;
|
|
499
|
+
this.initializationPromise = null;
|
|
500
|
+
await this.initialize(currentUser);
|
|
501
|
+
}
|
|
502
|
+
/** @deprecated Use {@link Refresh}. */
|
|
503
|
+
async refresh(currentUser) {
|
|
504
|
+
return this.Refresh(currentUser);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
//# sourceMappingURL=MentionAutocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MentionAutocomplete.js","sourceRoot":"","sources":["../../src/mentions/MentionAutocomplete.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,QAAQ,EAA4C,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAChH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAG3D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAkC;IACzE;QACE,KAAK,EAAE,CAAC;QAQF,gBAAW,GAA8B,EAAE,CAAC;QAC5C,eAAU,GAAe,EAAE,CAAC;QAC5B,kBAAa,GAAiB,EAAE,CAAC;QACjC,iBAAY,GAAgB,EAAE,CAAC;QACvC,+EAA+E;QACvE,gBAAW,GAAsB,EAAE,CAAC;QAG5C,6DAA6D;QACrD,qBAAgB,GAAG,iCAAiC,CAAC;QAC7D,kFAAkF;QAC1E,sBAAiB,GAAG,sBAAsB,CAAC;QAC3C,kBAAa,GAAG,KAAK,CAAC;QACtB,0BAAqB,GAAyB,IAAI,CAAC;IApB3D,CAAC;IAED,qEAAqE;IAC9D,MAAM,KAAK,QAAQ;QACxB,OAAO,KAAK,CAAC,WAAW,EAAuB,CAAC;IAClD,CAAC;IAiBD,+EAA+E;IAC/E,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,WAAqB,EAAE,QAA4B;QAClE,6CAA6C;QAC7C,IAAI,IAAI,CAAC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AAI,CAAC,iBAAiB,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,oDAAoD;IACpD,oBAAoB;QAClB,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,mDAAmD;IACnD,mBAAmB;QACjB,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,oDAAoD;IACpD,oBAAoB;QAClB,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,WAAqB;QACjC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;IAED,uCAAuC;IACvC,KAAK,CAAC,OAAO,CAAC,WAAqB;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -73,20 +73,28 @@ export declare class MentionParser {
|
|
|
73
73
|
* }
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
|
+
ParseMentions(text: string, availableAgents: MJAIAgentEntityExtended[], availableUsers?: UserInfo[]): MentionParseResult;
|
|
77
|
+
/** @deprecated Use {@link ParseMentions}. */
|
|
76
78
|
parseMentions(text: string, availableAgents: MJAIAgentEntityExtended[], availableUsers?: UserInfo[]): MentionParseResult;
|
|
77
79
|
/**
|
|
78
80
|
* Validate every mention in `text`. Returns an array of mention names that could not be
|
|
79
81
|
* resolved to a known agent or user.
|
|
80
82
|
*/
|
|
83
|
+
ValidateMentions(text: string, availableAgents: MJAIAgentEntityExtended[], availableUsers?: UserInfo[]): string[];
|
|
84
|
+
/** @deprecated Use {@link ValidateMentions}. */
|
|
81
85
|
validateMentions(text: string, availableAgents: MJAIAgentEntityExtended[], availableUsers?: UserInfo[]): string[];
|
|
82
86
|
/**
|
|
83
87
|
* Extract every raw mention name from `text` (no resolution against agents/users).
|
|
84
88
|
*/
|
|
89
|
+
ExtractMentionNames(text: string): string[];
|
|
90
|
+
/** @deprecated Use {@link ExtractMentionNames}. */
|
|
85
91
|
extractMentionNames(text: string): string[];
|
|
86
92
|
/**
|
|
87
93
|
* Rewrite mentions in `text` to a canonical `@Name` format using the proper casing
|
|
88
94
|
* from `mentions`. Useful when normalizing user-typed mentions before storage or display.
|
|
89
95
|
*/
|
|
96
|
+
FormatMentions(text: string, mentions: Mention[]): string;
|
|
97
|
+
/** @deprecated Use {@link FormatMentions}. */
|
|
90
98
|
formatMentions(text: string, mentions: Mention[]): string;
|
|
91
99
|
/**
|
|
92
100
|
* Convert a message containing JSON-encoded mentions to plain text — `@{…}` blocks
|
|
@@ -99,6 +107,8 @@ export declare class MentionParser {
|
|
|
99
107
|
* // Output: '@Sage help me'
|
|
100
108
|
* ```
|
|
101
109
|
*/
|
|
110
|
+
ToPlainText(text: string, agents?: MJAIAgentEntityExtended[], users?: UserInfo[]): string;
|
|
111
|
+
/** @deprecated Use {@link ToPlainText}. */
|
|
102
112
|
toPlainText(text: string, agents?: MJAIAgentEntityExtended[], users?: UserInfo[]): string;
|
|
103
113
|
/**
|
|
104
114
|
* Find an agent by name (case-insensitive). Tries exact match first, then starts-with.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionParser.d.ts","sourceRoot":"","sources":["../../src/mentions/MentionParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,uBAAuB,EAAuB,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAE,QAAQ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|
|
|
49
49
|
* }
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
ParseMentions(text, availableAgents, availableUsers) {
|
|
53
53
|
const mentions = [];
|
|
54
54
|
// First, try to parse JSON mentions (new format)
|
|
55
55
|
const jsonMatches = Array.from(text.matchAll(this.JSON_MENTION_REGEX));
|
|
@@ -118,11 +118,15 @@ export class MentionParser {
|
|
|
118
118
|
const skillMentions = mentions.filter((m) => m.type === 'skill');
|
|
119
119
|
return { mentions, agentMention, userMentions, entityMentions, skillMentions };
|
|
120
120
|
}
|
|
121
|
+
/** @deprecated Use {@link ParseMentions}. */
|
|
122
|
+
parseMentions(text, availableAgents, availableUsers) {
|
|
123
|
+
return this.ParseMentions(text, availableAgents, availableUsers);
|
|
124
|
+
}
|
|
121
125
|
/**
|
|
122
126
|
* Validate every mention in `text`. Returns an array of mention names that could not be
|
|
123
127
|
* resolved to a known agent or user.
|
|
124
128
|
*/
|
|
125
|
-
|
|
129
|
+
ValidateMentions(text, availableAgents, availableUsers) {
|
|
126
130
|
const invalidMentions = [];
|
|
127
131
|
// Check JSON mentions first
|
|
128
132
|
const jsonMatches = Array.from(text.matchAll(this.JSON_MENTION_REGEX));
|
|
@@ -171,10 +175,14 @@ export class MentionParser {
|
|
|
171
175
|
}
|
|
172
176
|
return invalidMentions;
|
|
173
177
|
}
|
|
178
|
+
/** @deprecated Use {@link ValidateMentions}. */
|
|
179
|
+
validateMentions(text, availableAgents, availableUsers) {
|
|
180
|
+
return this.ValidateMentions(text, availableAgents, availableUsers);
|
|
181
|
+
}
|
|
174
182
|
/**
|
|
175
183
|
* Extract every raw mention name from `text` (no resolution against agents/users).
|
|
176
184
|
*/
|
|
177
|
-
|
|
185
|
+
ExtractMentionNames(text) {
|
|
178
186
|
// Check JSON mentions first
|
|
179
187
|
const jsonMatches = Array.from(text.matchAll(this.JSON_MENTION_REGEX));
|
|
180
188
|
if (jsonMatches.length > 0) {
|
|
@@ -195,11 +203,15 @@ export class MentionParser {
|
|
|
195
203
|
const matches = Array.from(text.matchAll(this.LEGACY_MENTION_REGEX));
|
|
196
204
|
return matches.map((match) => match[1] || match[2]).filter(Boolean);
|
|
197
205
|
}
|
|
206
|
+
/** @deprecated Use {@link ExtractMentionNames}. */
|
|
207
|
+
extractMentionNames(text) {
|
|
208
|
+
return this.ExtractMentionNames(text);
|
|
209
|
+
}
|
|
198
210
|
/**
|
|
199
211
|
* Rewrite mentions in `text` to a canonical `@Name` format using the proper casing
|
|
200
212
|
* from `mentions`. Useful when normalizing user-typed mentions before storage or display.
|
|
201
213
|
*/
|
|
202
|
-
|
|
214
|
+
FormatMentions(text, mentions) {
|
|
203
215
|
let formattedText = text;
|
|
204
216
|
for (const mention of mentions) {
|
|
205
217
|
// Find the mention in the text and replace with proper name
|
|
@@ -213,6 +225,10 @@ export class MentionParser {
|
|
|
213
225
|
}
|
|
214
226
|
return formattedText;
|
|
215
227
|
}
|
|
228
|
+
/** @deprecated Use {@link FormatMentions}. */
|
|
229
|
+
formatMentions(text, mentions) {
|
|
230
|
+
return this.FormatMentions(text, mentions);
|
|
231
|
+
}
|
|
216
232
|
/**
|
|
217
233
|
* Convert a message containing JSON-encoded mentions to plain text — `@{…}` blocks
|
|
218
234
|
* become simple `@Name` strings. Delegates to
|
|
@@ -224,7 +240,7 @@ export class MentionParser {
|
|
|
224
240
|
* // Output: '@Sage help me'
|
|
225
241
|
* ```
|
|
226
242
|
*/
|
|
227
|
-
|
|
243
|
+
ToPlainText(text, agents, users) {
|
|
228
244
|
if (!text)
|
|
229
245
|
return '';
|
|
230
246
|
// Convert agents to the AgentInfo format expected by ConversationUtility
|
|
@@ -239,6 +255,10 @@ export class MentionParser {
|
|
|
239
255
|
}));
|
|
240
256
|
return ConversationUtility.ToPlainText(text, agentInfos, userInfos);
|
|
241
257
|
}
|
|
258
|
+
/** @deprecated Use {@link ToPlainText}. */
|
|
259
|
+
toPlainText(text, agents, users) {
|
|
260
|
+
return this.ToPlainText(text, agents, users);
|
|
261
|
+
}
|
|
242
262
|
/**
|
|
243
263
|
* Find an agent by name (case-insensitive). Tries exact match first, then starts-with.
|
|
244
264
|
* Explicitly does NOT do a contains-match — that would be ambiguous when multiple agent
|