@memberjunction/conversations-runtime 6.1.2 → 6.2.0-edge.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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 +151 -0
- package/dist/mentions/MentionAutocomplete.d.ts.map +1 -0
- package/dist/mentions/MentionAutocomplete.js +468 -0
- package/dist/mentions/MentionAutocomplete.js.map +1 -0
- package/dist/mentions/MentionSuggestion.d.ts +66 -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/timeline/RealtimeSessionTimeline.d.ts +182 -0
- package/dist/timeline/RealtimeSessionTimeline.d.ts.map +1 -0
- package/dist/timeline/RealtimeSessionTimeline.js +233 -0
- package/dist/timeline/RealtimeSessionTimeline.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,468 @@
|
|
|
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
|
+
* @returns Filtered and ranked suggestions
|
|
205
|
+
*/
|
|
206
|
+
getSuggestions(query, includeUsers = true, trigger = '@', targetAgentId = null) {
|
|
207
|
+
// The '#' trigger searches entities + queries; '/' searches skills; '@' searches agents + users
|
|
208
|
+
if (trigger === '#') {
|
|
209
|
+
return this.getEntityAndQuerySuggestions(query);
|
|
210
|
+
}
|
|
211
|
+
if (trigger === '/') {
|
|
212
|
+
return this.getSkillSuggestions(query, targetAgentId);
|
|
213
|
+
}
|
|
214
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
215
|
+
const suggestions = [];
|
|
216
|
+
// Add agent suggestions
|
|
217
|
+
for (const agent of this.agentsCache) {
|
|
218
|
+
const score = this.calculateMatchScore(agent.Name || '', lowerQuery);
|
|
219
|
+
if (score > 0 || !lowerQuery) {
|
|
220
|
+
suggestions.push({
|
|
221
|
+
type: 'agent',
|
|
222
|
+
id: agent.ID,
|
|
223
|
+
name: agent.Name || 'Unknown',
|
|
224
|
+
displayName: agent.Name || 'Unknown',
|
|
225
|
+
description: agent.Description || undefined,
|
|
226
|
+
imageUrl: agent.LogoURL || undefined, // Agent logo/avatar image
|
|
227
|
+
icon: this.getAgentIcon(agent),
|
|
228
|
+
// Configuration presets ride on the suggestion — the (AI-blind) composer
|
|
229
|
+
// renders a preset picker on the inserted chip when there are 2+.
|
|
230
|
+
presets: this.getAgentPresets(agent.ID)
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Add user suggestions (if enabled)
|
|
235
|
+
if (includeUsers) {
|
|
236
|
+
for (const user of this.usersCache) {
|
|
237
|
+
const score = this.calculateMatchScore(user.Name, lowerQuery);
|
|
238
|
+
if (score > 0 || !lowerQuery) {
|
|
239
|
+
suggestions.push({
|
|
240
|
+
type: 'user',
|
|
241
|
+
id: user.ID,
|
|
242
|
+
name: user.Name,
|
|
243
|
+
displayName: user.Name,
|
|
244
|
+
description: user.Email || undefined
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Sort by relevance: exact match > starts with > contains
|
|
250
|
+
return suggestions.sort((a, b) => {
|
|
251
|
+
const scoreA = this.calculateMatchScore(a.name, lowerQuery);
|
|
252
|
+
const scoreB = this.calculateMatchScore(b.name, lowerQuery);
|
|
253
|
+
if (scoreB !== scoreA)
|
|
254
|
+
return scoreB - scoreA;
|
|
255
|
+
// If scores are equal, sort agents before users
|
|
256
|
+
if (a.type !== b.type)
|
|
257
|
+
return a.type === 'agent' ? -1 : 1;
|
|
258
|
+
// Otherwise alphabetically
|
|
259
|
+
return a.name.localeCompare(b.name);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get entity + query suggestions for #mentions, ranked by query match.
|
|
264
|
+
* Capped to keep the dropdown light (entity/query sets can be large).
|
|
265
|
+
*/
|
|
266
|
+
getEntityAndQuerySuggestions(query) {
|
|
267
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
268
|
+
const MAX_SUGGESTIONS = 50;
|
|
269
|
+
const entityItems = this.entitiesCache.map(entity => ({
|
|
270
|
+
label: entity.DisplayNameOrName,
|
|
271
|
+
score: Math.max(this.calculateMatchScore(entity.Name || '', lowerQuery), this.calculateMatchScore(entity.DisplayName || '', lowerQuery)),
|
|
272
|
+
suggestion: {
|
|
273
|
+
type: 'entity',
|
|
274
|
+
id: entity.ID,
|
|
275
|
+
name: entity.Name,
|
|
276
|
+
displayName: entity.DisplayNameOrName,
|
|
277
|
+
description: entity.Description || undefined,
|
|
278
|
+
icon: entity.Icon || 'fa-solid fa-table'
|
|
279
|
+
}
|
|
280
|
+
}));
|
|
281
|
+
const queryItems = this.queriesCache.map(q => ({
|
|
282
|
+
label: q.Name || '',
|
|
283
|
+
score: this.calculateMatchScore(q.Name || '', lowerQuery),
|
|
284
|
+
suggestion: {
|
|
285
|
+
type: 'query',
|
|
286
|
+
id: q.ID,
|
|
287
|
+
name: q.Name || '',
|
|
288
|
+
displayName: q.Name || '',
|
|
289
|
+
description: q.Description || undefined,
|
|
290
|
+
icon: this.queriesEntityIcon
|
|
291
|
+
}
|
|
292
|
+
}));
|
|
293
|
+
return [...entityItems, ...queryItems]
|
|
294
|
+
.filter(x => x.score > 0 || !lowerQuery)
|
|
295
|
+
.sort((a, b) => {
|
|
296
|
+
if (b.score !== a.score)
|
|
297
|
+
return b.score - a.score;
|
|
298
|
+
// When scores tie, prioritize entities over queries
|
|
299
|
+
if (a.suggestion.type !== b.suggestion.type) {
|
|
300
|
+
return a.suggestion.type === 'entity' ? -1 : 1;
|
|
301
|
+
}
|
|
302
|
+
return a.label.localeCompare(b.label);
|
|
303
|
+
})
|
|
304
|
+
.slice(0, MAX_SUGGESTIONS)
|
|
305
|
+
.map(x => x.suggestion);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* The skills to offer under '/': the user's runnable catalog, narrowed to the target agent's
|
|
309
|
+
* accepted set when the agent is known. Intersection only — the agent filter never adds a skill
|
|
310
|
+
* the user could not run. Unknown agent id (not in the user's runnable agents) → no narrowing.
|
|
311
|
+
*/
|
|
312
|
+
skillsForTarget(targetAgentId) {
|
|
313
|
+
if (!targetAgentId) {
|
|
314
|
+
return this.skillsCache;
|
|
315
|
+
}
|
|
316
|
+
const agent = this.agentsCache.find(a => UUIDsEqual(a.ID, targetAgentId));
|
|
317
|
+
if (!agent) {
|
|
318
|
+
return this.skillsCache;
|
|
319
|
+
}
|
|
320
|
+
const engine = this.provider
|
|
321
|
+
? AIEngineBase.GetProviderInstance(this.provider, AIEngineBase)
|
|
322
|
+
: AIEngineBase.Instance;
|
|
323
|
+
return IntersectAcceptedSkills(this.skillsCache, engine.GetSkillsForAgent(agent));
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Get skill suggestions for '/'-mentions, ranked by query match. Each carries the skill's own
|
|
327
|
+
* IconClass/Color (UX metadata) so the dropdown + inserted chip render distinctly per skill.
|
|
328
|
+
*/
|
|
329
|
+
getSkillSuggestions(query, targetAgentId = null) {
|
|
330
|
+
const lowerQuery = query.toLowerCase().trim();
|
|
331
|
+
const MAX_SUGGESTIONS = 12;
|
|
332
|
+
return this.skillsForTarget(targetAgentId)
|
|
333
|
+
.map(skill => ({
|
|
334
|
+
score: this.calculateMatchScore(skill.Name || '', lowerQuery),
|
|
335
|
+
suggestion: {
|
|
336
|
+
type: 'skill',
|
|
337
|
+
id: skill.ID,
|
|
338
|
+
name: skill.Name || 'Unknown Skill',
|
|
339
|
+
displayName: skill.Name || 'Unknown Skill',
|
|
340
|
+
description: skill.Description || undefined,
|
|
341
|
+
icon: skill.IconClass || this.defaultSkillIcon,
|
|
342
|
+
color: skill.Color || undefined
|
|
343
|
+
}
|
|
344
|
+
}))
|
|
345
|
+
.filter(x => x.score > 0 || !lowerQuery)
|
|
346
|
+
.sort((a, b) => {
|
|
347
|
+
if (b.score !== a.score)
|
|
348
|
+
return b.score - a.score;
|
|
349
|
+
return a.suggestion.name.localeCompare(b.suggestion.name);
|
|
350
|
+
})
|
|
351
|
+
.slice(0, MAX_SUGGESTIONS)
|
|
352
|
+
.map(x => x.suggestion);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Calculate match score for ranking
|
|
356
|
+
* Higher score = better match
|
|
357
|
+
*/
|
|
358
|
+
calculateMatchScore(name, query) {
|
|
359
|
+
if (!query)
|
|
360
|
+
return 1; // Show all if no query
|
|
361
|
+
const lowerName = name.toLowerCase();
|
|
362
|
+
const lowerQuery = query.toLowerCase();
|
|
363
|
+
// Exact match
|
|
364
|
+
if (lowerName === lowerQuery)
|
|
365
|
+
return 100;
|
|
366
|
+
// Starts with
|
|
367
|
+
if (lowerName.startsWith(lowerQuery))
|
|
368
|
+
return 50;
|
|
369
|
+
// Contains
|
|
370
|
+
if (lowerName.includes(lowerQuery))
|
|
371
|
+
return 25;
|
|
372
|
+
// Word boundary match (e.g., "MA" matches "Marketing Agent")
|
|
373
|
+
const words = lowerName.split(/\s+/);
|
|
374
|
+
for (const word of words) {
|
|
375
|
+
if (word.startsWith(lowerQuery))
|
|
376
|
+
return 40;
|
|
377
|
+
}
|
|
378
|
+
return 0; // No match
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Map an agent's AI Agent Configuration presets into the composer's generic
|
|
382
|
+
* `MentionSuggestionPreset` shape so the chip's preset picker works without the
|
|
383
|
+
* composer knowing anything about agents.
|
|
384
|
+
*
|
|
385
|
+
* IMPORTANT: preset.ID is the AIAgentConfiguration.ID (preset ID), not
|
|
386
|
+
* AIConfigurationID — the backend mapping converts preset ID -> AIConfigurationID.
|
|
387
|
+
*/
|
|
388
|
+
getAgentPresets(agentId) {
|
|
389
|
+
try {
|
|
390
|
+
const presets = AIEngineBase.Instance.GetAgentConfigurationPresets(agentId, true);
|
|
391
|
+
if (!presets || presets.length === 0) {
|
|
392
|
+
return undefined;
|
|
393
|
+
}
|
|
394
|
+
return presets.map(p => ({
|
|
395
|
+
ID: p.ID,
|
|
396
|
+
Name: p.Name,
|
|
397
|
+
DisplayName: p.DisplayName || undefined,
|
|
398
|
+
Description: p.Description || undefined,
|
|
399
|
+
IsDefault: p.IsDefault
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
// Presets are a chip nicety — never let them break suggestion building
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get icon for agent based on type/name
|
|
409
|
+
*/
|
|
410
|
+
getAgentIcon(agent) {
|
|
411
|
+
// Use agent's icon if available, otherwise default based on type
|
|
412
|
+
if (agent.IconClass)
|
|
413
|
+
return agent.IconClass;
|
|
414
|
+
// Default icons based on agent name patterns
|
|
415
|
+
const name = agent.Name?.toLowerCase() || '';
|
|
416
|
+
if (name.includes('marketing'))
|
|
417
|
+
return 'fa-megaphone';
|
|
418
|
+
if (name.includes('data') || name.includes('analysis'))
|
|
419
|
+
return 'fa-chart-line';
|
|
420
|
+
if (name.includes('code') || name.includes('developer'))
|
|
421
|
+
return 'fa-code';
|
|
422
|
+
if (name.includes('design'))
|
|
423
|
+
return 'fa-palette';
|
|
424
|
+
if (name.includes('conversation') || name.includes('manager'))
|
|
425
|
+
return 'fa-comments';
|
|
426
|
+
return 'fa-robot'; // Default
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Get available agents for parsing
|
|
430
|
+
*/
|
|
431
|
+
getAvailableAgents() {
|
|
432
|
+
return this.agentsCache;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Get available users for parsing
|
|
436
|
+
*/
|
|
437
|
+
getAvailableUsers() {
|
|
438
|
+
return this.usersCache;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Get available entities for parsing
|
|
442
|
+
*/
|
|
443
|
+
getAvailableEntities() {
|
|
444
|
+
return this.entitiesCache;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Get available queries for parsing
|
|
448
|
+
*/
|
|
449
|
+
getAvailableQueries() {
|
|
450
|
+
return this.queriesCache;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Get the generic icon used for all query mentions.
|
|
454
|
+
*/
|
|
455
|
+
getQueriesEntityIcon() {
|
|
456
|
+
return this.queriesEntityIcon;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Refresh the caches
|
|
460
|
+
* Resets initialization state and reloads agents
|
|
461
|
+
*/
|
|
462
|
+
async refresh(currentUser) {
|
|
463
|
+
this.isInitialized = false;
|
|
464
|
+
this.initializationPromise = null;
|
|
465
|
+
await this.initialize(currentUser);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
//# 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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suggestion engine returns.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this lives here and not in the composer
|
|
5
|
+
*
|
|
6
|
+
* `@memberjunction/ng-composer` declares a structurally identical `MentionSuggestion` as its
|
|
7
|
+
* **rendering** contract — what a dropdown row and an inserted chip display. This is the
|
|
8
|
+
* **data** contract: what a suggestion engine produces, independent of anything drawing it.
|
|
9
|
+
*
|
|
10
|
+
* They are the same shape today because the Angular composer was the only consumer. Now that a
|
|
11
|
+
* React Native host renders the same suggestions with entirely different primitives, the producer
|
|
12
|
+
* needs a home that does not live inside one renderer's package — a native app cannot depend on an
|
|
13
|
+
* Angular library for a plain object, and MJ does not permit cross-package re-exports.
|
|
14
|
+
*
|
|
15
|
+
* The shapes are kept assignable on purpose, so the Angular shim can hand a runtime suggestion
|
|
16
|
+
* straight to the composer with no mapping layer.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* A configuration preset attached to a mention suggestion (e.g. an agent's Fast / Standard /
|
|
20
|
+
* High Power presets).
|
|
21
|
+
*
|
|
22
|
+
* Deliberately generic — a suggestion engine has no knowledge of what a preset IS. Producers map
|
|
23
|
+
* their domain objects (e.g. `MJ: AI Agent Configurations` rows) into this shape.
|
|
24
|
+
*/
|
|
25
|
+
export interface MentionSuggestionPreset {
|
|
26
|
+
/** Stable identifier, carried by the inserted chip. */
|
|
27
|
+
ID: string;
|
|
28
|
+
/** Machine name, carried by the inserted chip. */
|
|
29
|
+
Name: string;
|
|
30
|
+
/** Friendly label shown in a preset picker (falls back to {@link Name}). */
|
|
31
|
+
DisplayName?: string;
|
|
32
|
+
/** Optional descriptive text shown under the preset label. */
|
|
33
|
+
Description?: string;
|
|
34
|
+
/** The preset preselected on insert. First preset wins when none is flagged. */
|
|
35
|
+
IsDefault?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One item in a mention-autocomplete list, and the payload an inserted mention carries.
|
|
39
|
+
*
|
|
40
|
+
* `type` is an open string so a host can add its own vocabulary; the shipped producers use
|
|
41
|
+
* `'agent' | 'user' | 'entity' | 'query' | 'skill'`. Renderers use it only for cosmetics (chip
|
|
42
|
+
* palette, badge label) and for the plain-text serialization prefix.
|
|
43
|
+
*/
|
|
44
|
+
export interface MentionSuggestion {
|
|
45
|
+
/** Open discriminator chosen by the producer. */
|
|
46
|
+
type: string;
|
|
47
|
+
/** Record id the mention resolves to. */
|
|
48
|
+
id: string;
|
|
49
|
+
/** Machine name. */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Name as shown to a person. */
|
|
52
|
+
displayName: string;
|
|
53
|
+
/** Secondary line — an agent's description, a user's email. */
|
|
54
|
+
description?: string;
|
|
55
|
+
/** Image for the row and the chip (e.g. an agent's `LogoURL`). */
|
|
56
|
+
imageUrl?: string;
|
|
57
|
+
/** Font Awesome (or custom) icon class for the row and the chip. */
|
|
58
|
+
icon?: string;
|
|
59
|
+
/** Accent colour for the chip/badge (e.g. a skill's own Color metadata). */
|
|
60
|
+
color?: string;
|
|
61
|
+
/** Optional presets — 2+ presets warrant a preset picker on the inserted chip. */
|
|
62
|
+
presets?: MentionSuggestionPreset[];
|
|
63
|
+
/** Producer-defined extra payload; renderers never inspect it. */
|
|
64
|
+
data?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=MentionSuggestion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MentionSuggestion.d.ts","sourceRoot":"","sources":["../../src/mentions/MentionSuggestion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACpC,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAC9B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,OAAO,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACpC,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The data shape a mention-suggestion engine returns.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this lives here and not in the composer
|
|
5
|
+
*
|
|
6
|
+
* `@memberjunction/ng-composer` declares a structurally identical `MentionSuggestion` as its
|
|
7
|
+
* **rendering** contract — what a dropdown row and an inserted chip display. This is the
|
|
8
|
+
* **data** contract: what a suggestion engine produces, independent of anything drawing it.
|
|
9
|
+
*
|
|
10
|
+
* They are the same shape today because the Angular composer was the only consumer. Now that a
|
|
11
|
+
* React Native host renders the same suggestions with entirely different primitives, the producer
|
|
12
|
+
* needs a home that does not live inside one renderer's package — a native app cannot depend on an
|
|
13
|
+
* Angular library for a plain object, and MJ does not permit cross-package re-exports.
|
|
14
|
+
*
|
|
15
|
+
* The shapes are kept assignable on purpose, so the Angular shim can hand a runtime suggestion
|
|
16
|
+
* straight to the composer with no mapping layer.
|
|
17
|
+
*/
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=MentionSuggestion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MentionSuggestion.js","sourceRoot":"","sources":["../../src/mentions/MentionSuggestion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `/` picker's narrowing rule: the skills to offer are the user's RUNNABLE set intersected
|
|
3
|
+
* with the target agent's ACCEPTED set (`AIEngineBase.GetSkillsForAgent(agent)` — `AcceptsSkills`
|
|
4
|
+
* plus its `MJ: AI Agent Skills` grants).
|
|
5
|
+
*
|
|
6
|
+
* Intersection only. The agent's set can remove a skill the user could run; it can never add one
|
|
7
|
+
* the user could not — the permission filter is upstream and this must not widen it. Order follows
|
|
8
|
+
* `runnable`, and UUIDs compare case-insensitively because casing differs by platform.
|
|
9
|
+
*
|
|
10
|
+
* Pure by design so it can be tested directly rather than through a picker.
|
|
11
|
+
*/
|
|
12
|
+
export declare function IntersectAcceptedSkills<T extends {
|
|
13
|
+
ID: string;
|
|
14
|
+
}>(runnable: T[], accepted: ReadonlyArray<{
|
|
15
|
+
ID: string;
|
|
16
|
+
}>): T[];
|
|
17
|
+
//# sourceMappingURL=SkillNarrowing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkillNarrowing.d.ts","sourceRoot":"","sources":["../../src/mentions/SkillNarrowing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC5D,QAAQ,EAAE,CAAC,EAAE,EACb,QAAQ,EAAE,aAAa,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GACxC,CAAC,EAAE,CAGL"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NormalizeUUID } from '@memberjunction/global';
|
|
2
|
+
/**
|
|
3
|
+
* The `/` picker's narrowing rule: the skills to offer are the user's RUNNABLE set intersected
|
|
4
|
+
* with the target agent's ACCEPTED set (`AIEngineBase.GetSkillsForAgent(agent)` — `AcceptsSkills`
|
|
5
|
+
* plus its `MJ: AI Agent Skills` grants).
|
|
6
|
+
*
|
|
7
|
+
* Intersection only. The agent's set can remove a skill the user could run; it can never add one
|
|
8
|
+
* the user could not — the permission filter is upstream and this must not widen it. Order follows
|
|
9
|
+
* `runnable`, and UUIDs compare case-insensitively because casing differs by platform.
|
|
10
|
+
*
|
|
11
|
+
* Pure by design so it can be tested directly rather than through a picker.
|
|
12
|
+
*/
|
|
13
|
+
export function IntersectAcceptedSkills(runnable, accepted) {
|
|
14
|
+
const acceptedIDs = new Set(accepted.map((sk) => NormalizeUUID(sk.ID)));
|
|
15
|
+
return runnable.filter((sk) => acceptedIDs.has(NormalizeUUID(sk.ID)));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=SkillNarrowing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkillNarrowing.js","sourceRoot":"","sources":["../../src/mentions/SkillNarrowing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CACnC,QAAa,EACb,QAAuC;IAEvC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|