@memberjunction/ng-composer 6.3.0-edge.1 → 6.3.0-edge.3
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/lib/components/mention/mention-dropdown.component.d.ts +47 -17
- package/dist/lib/components/mention/mention-dropdown.component.d.ts.map +1 -1
- package/dist/lib/components/mention/mention-dropdown.component.js +444 -129
- package/dist/lib/components/mention/mention-dropdown.component.js.map +1 -1
- package/dist/lib/components/mention/mention-editor.component.d.ts +9 -1
- package/dist/lib/components/mention/mention-editor.component.d.ts.map +1 -1
- package/dist/lib/components/mention/mention-editor.component.js +43 -13
- package/dist/lib/components/mention/mention-editor.component.js.map +1 -1
- package/dist/lib/composer-trigger-provider.d.ts +38 -0
- package/dist/lib/composer-trigger-provider.d.ts.map +1 -1
- package/dist/lib/composer-trigger-provider.js +8 -0
- package/dist/lib/composer-trigger-provider.js.map +1 -1
- package/package.json +5 -5
|
@@ -22,6 +22,21 @@ export interface MentionSuggestionPreset {
|
|
|
22
22
|
/** The preset preselected on chip insert. First preset wins when none is flagged. */
|
|
23
23
|
IsDefault?: boolean;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Population filter narrowing which categories of `@` suggestions are returned.
|
|
27
|
+
* Structurally identical to `MentionPopulationFilter` in `@memberjunction/conversations-runtime`.
|
|
28
|
+
*/
|
|
29
|
+
export type ComposerPopulationFilter = 'all' | 'my-agents' | 'shared' | 'people';
|
|
30
|
+
/**
|
|
31
|
+
* Field scope restricting which fields a non-empty `@` search query matches against.
|
|
32
|
+
* Structurally identical to `MentionSearchField` in `@memberjunction/conversations-runtime`.
|
|
33
|
+
*/
|
|
34
|
+
export type ComposerSearchField = 'all' | 'name' | 'capabilities' | 'lineage';
|
|
35
|
+
/**
|
|
36
|
+
* Display section grouping key assigned to `@` mention suggestions.
|
|
37
|
+
* Structurally identical to `MentionGroupKey` in `@memberjunction/conversations-runtime`.
|
|
38
|
+
*/
|
|
39
|
+
export type ComposerGroupKey = 'frequent' | 'my-agents' | 'shared' | 'people' | 'results';
|
|
25
40
|
/**
|
|
26
41
|
* Item in the mention-autocomplete dropdown, and the payload carried by an inserted
|
|
27
42
|
* mention chip. Fully generic — `type` is an open string (providers choose their own
|
|
@@ -46,6 +61,20 @@ export interface MentionSuggestion {
|
|
|
46
61
|
presets?: MentionSuggestionPreset[];
|
|
47
62
|
/** Provider-defined extra payload; the composer never inspects it. */
|
|
48
63
|
data?: Record<string, unknown>;
|
|
64
|
+
/** Section key used to group suggestions in the dropdown. */
|
|
65
|
+
group?: ComposerGroupKey;
|
|
66
|
+
/** Human-readable section heading corresponding to {@link group}. */
|
|
67
|
+
groupLabel?: string;
|
|
68
|
+
/** Provenance / inheritance label (e.g. `'Chief of Staff · My Agent'`, `'Shared'`). */
|
|
69
|
+
lineage?: string;
|
|
70
|
+
/** True when this suggestion is a personal derived agent instance owned by the current user. */
|
|
71
|
+
isMyAgent?: boolean;
|
|
72
|
+
/** True when this suggestion matches the user's default chat agent. */
|
|
73
|
+
isDefaultChatAgent?: boolean;
|
|
74
|
+
/** True when this suggestion is already active in the current conversation thread. */
|
|
75
|
+
isInCurrentThread?: boolean;
|
|
76
|
+
/** Decayed frequency + recency score for this item. */
|
|
77
|
+
frecencyScore?: number;
|
|
49
78
|
}
|
|
50
79
|
/**
|
|
51
80
|
* Request passed to {@link ComposerTriggerProvider.GetSuggestions} each time the user
|
|
@@ -60,6 +89,10 @@ export interface ComposerSuggestionRequest {
|
|
|
60
89
|
ContextUser: UserInfo | null;
|
|
61
90
|
/** The metadata provider scoping this editor instance, when the host supplied one (multi-provider support). */
|
|
62
91
|
Provider: IMetadataProvider | null;
|
|
92
|
+
/** Optional population filter selected in the `@` dropdown header (`'all'` by default). */
|
|
93
|
+
PopulationFilter?: ComposerPopulationFilter;
|
|
94
|
+
/** Optional search-field scope selected in the `@` dropdown header (`'all'` by default). */
|
|
95
|
+
SearchField?: ComposerSearchField;
|
|
63
96
|
}
|
|
64
97
|
/**
|
|
65
98
|
* Pluggable mention/command trigger for the composer's mention editor.
|
|
@@ -104,6 +137,11 @@ export declare abstract class ComposerTriggerProvider {
|
|
|
104
137
|
* keystroke is fast. Must be safe to call repeatedly and concurrently.
|
|
105
138
|
*/
|
|
106
139
|
Initialize(contextUser: UserInfo | null): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Optional selection hook invoked by the mention editor whenever the user inserts a
|
|
142
|
+
* suggestion owned by this trigger (e.g. to record frecency telemetry). Default is a no-op.
|
|
143
|
+
*/
|
|
144
|
+
OnSuggestionSelected(suggestion: MentionSuggestion, contextUser: UserInfo | null): void;
|
|
107
145
|
}
|
|
108
146
|
/**
|
|
109
147
|
* Resolves every `@RegisterClass(ComposerTriggerProvider, ...)` registration in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer-trigger-provider.d.ts","sourceRoot":"","sources":["../../src/lib/composer-trigger-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGnE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,uBAAuB;IACtC,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,OAAO,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACpC,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"composer-trigger-provider.d.ts","sourceRoot":"","sources":["../../src/lib/composer-trigger-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGnE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,uBAAuB;IACtC,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,KAAK,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;AAE9E;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1F;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sFAAsF;IACtF,Q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G;aACa,cAAc,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAEhG;;;;OAIG;IACU,UAAU,CAAC,WAAW,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpE;;;OAGG;IACI,oBAAoB,CAAC,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI;CAI/F;AASD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gCAAgC,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,uBAAuB,EAAE,CAsCnG"}
|
|
@@ -32,6 +32,14 @@ export class ComposerTriggerProvider {
|
|
|
32
32
|
// default no-op — providers override to warm caches
|
|
33
33
|
void contextUser;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Optional selection hook invoked by the mention editor whenever the user inserts a
|
|
37
|
+
* suggestion owned by this trigger (e.g. to record frecency telemetry). Default is a no-op.
|
|
38
|
+
*/
|
|
39
|
+
OnSuggestionSelected(suggestion, contextUser) {
|
|
40
|
+
void suggestion;
|
|
41
|
+
void contextUser;
|
|
42
|
+
}
|
|
35
43
|
}
|
|
36
44
|
/**
|
|
37
45
|
* One instance per registered provider subclass, shared across all editors in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer-trigger-provider.js","sourceRoot":"","sources":["../../src/lib/composer-trigger-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAmElD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAgB,uBAAuB;IAU3C;;;OAGG;IACa,QAAQ,GAAW,CAAC,CAAC;IASrC;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAC,WAA4B;QAClD,oDAAoD;QACpD,KAAK,WAAW,CAAC;IACnB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,2BAA2B,GAAG,IAAI,GAAG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AC;YACd,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAA6C,CAAC;YACjF,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAC;YACrC,2BAA2B,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;YAAE,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QAC9D,OAAO,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { IMetadataProvider, UserInfo } from '@memberjunction/core';\nimport { MJGlobal } from '@memberjunction/global';\n\n/**\n * A configuration preset attached to a mention suggestion (e.g. an agent's\n * Fast / Standard / High Power presets). When a suggestion carries 2+ presets the\n * mention editor renders a preset picker on the inserted chip; the selected preset's\n * ID/Name travel with the chip (`data-preset-id` / `data-preset-name`) and survive\n * serialization via `getPlainTextWithJsonMentions()`.\n *\n * This is a deliberately generic shape — the composer has no knowledge of what a\n * preset IS. Trigger providers map their domain objects (e.g. `MJ: AI Agent\n * Configurations` rows) into this shape when building suggestions.\n */\nexport interface MentionSuggestionPreset {\n /** Stable identifier stored on the chip (`data-preset-id`). */\n ID: string;\n /** Machine name stored on the chip (`data-preset-name`). */\n Name: string;\n /** Friendly label shown in the preset picker (falls back to Name). */\n DisplayName?: string;\n /** Optional descriptive text shown under the preset label. */\n Description?: string;\n /** The preset preselected on chip insert. First preset wins when none is flagged. */\n IsDefault?: boolean;\n}\n\n/**\n * Item in the mention-autocomplete dropdown, and the payload carried by an inserted\n * mention chip. Fully generic — `type` is an open string (providers choose their own\n * vocabulary, e.g. 'agent' | 'user' | 'entity' | 'query' | 'skill'); the editor and\n * dropdown only use it for cosmetic styling (chip palette, badge label) and for the\n * plain-text serialization prefix.\n */\nexport interface MentionSuggestion {\n /** Open string discriminator chosen by the provider (drives chip/badge styling). */\n type: string;\n id: string;\n name: string;\n displayName: string;\n description?: string;\n /** Image rendered in the dropdown row + chip when present (e.g. an agent LogoURL). */\n imageUrl?: string;\n /** Font Awesome (or custom) icon class for the dropdown row + chip. */\n icon?: string;\n /** Accent color for the chip/badge (e.g. a skill's own Color UX metadata). */\n color?: string;\n /** Optional presets — 2+ presets render a preset picker on the inserted chip. */\n presets?: MentionSuggestionPreset[];\n /** Provider-defined extra payload; the composer never inspects it. */\n data?: Record<string, unknown>;\n}\n\n/**\n * Request passed to {@link ComposerTriggerProvider.GetSuggestions} each time the user\n * types after an active trigger character.\n */\nexport interface ComposerSuggestionRequest {\n /** The text typed after the trigger character (may be empty — show the full list). */\n Query: string;\n /** Maximum number of suggestions the editor will display; providers should honor it. */\n MaxResults: number;\n /** The current user, when the host supplied one. Providers should fail closed (return []) if they require a user and none is present. */\n ContextUser: UserInfo | null;\n /** The metadata provider scoping this editor instance, when the host supplied one (multi-provider support). */\n Provider: IMetadataProvider | null;\n}\n\n/**\n * Pluggable mention/command trigger for the composer's mention editor.\n *\n * Each provider owns ONE trigger character (e.g. '@', '#', '/') and supplies the\n * suggestions shown while the user types after it. The composer itself ships with\n * ZERO providers — it is a plain text editor until providers are supplied, either:\n *\n * 1. **Explicitly** — bind `[TriggerProviders]` on `mj-mention-editor` /\n * `mj-message-input-box` with provider instances (explicit list always wins), or\n * 2. **By discovery** — register subclasses with the MJ ClassFactory via\n * `@RegisterClass(ComposerTriggerProvider, '<Key>')`; the editor resolves them\n * through {@link DiscoverComposerTriggerProviders} when no explicit list is bound.\n * Hosts opt individual triggers out with `[ExcludedTriggerKeys]`.\n *\n * The AI-aware providers (agent mentions, entity/query record mentions, skill\n * commands) live in `@memberjunction/ng-conversations` — see its `composer-plugins`\n * folder and the `mj-ai-composer` wrapper component.\n */\nexport abstract class ComposerTriggerProvider {\n /** The single character that opens this provider's autocomplete (e.g. '@'). */\n public abstract readonly TriggerChar: string;\n\n /**\n * Stable identifier for this provider (e.g. 'agent-mentions'). Used as the\n * ClassFactory registration key and by `ExcludedTriggerKeys` filtering.\n */\n public abstract readonly Key: string;\n\n /**\n * Ordering weight — higher runs first. When multiple providers share a\n * TriggerChar, results are concatenated in priority order (then Key order).\n */\n public readonly Priority: number = 0;\n\n /**\n * Returns the suggestions for the current query. Called on every keystroke after\n * an active trigger; implementations should be fast (serve from warm caches) and\n * must never throw — return [] on failure.\n */\n public abstract GetSuggestions(request: ComposerSuggestionRequest): Promise<MentionSuggestion[]>;\n\n /**\n * Optional warm-up hook, invoked once by the editor when it initializes with this\n * provider active. Default is a no-op; override to pre-load caches so the first\n * keystroke is fast. Must be safe to call repeatedly and concurrently.\n */\n public async Initialize(contextUser: UserInfo | null): Promise<void> {\n // default no-op — providers override to warm caches\n void contextUser;\n }\n}\n\n/**\n * One instance per registered provider subclass, shared across all editors in the\n * process — providers are expected to be stateless facades over shared engines, so a\n * single instance avoids duplicate cache warm-ups.\n */\nconst discoveredProviderInstances = new Map<unknown, ComposerTriggerProvider>();\n\n/**\n * Resolves every `@RegisterClass(ComposerTriggerProvider, ...)` registration in the\n * MJ ClassFactory into a provider instance list.\n *\n * - Instantiates each winning registration once (module-level cache keyed by the\n * registered subclass) — repeated calls are cheap.\n * - When multiple registrations share a Key, the ClassFactory's highest-priority\n * registration wins (standard override-by-import-order semantics).\n * - `excludedKeys` filters providers out by their stable Key (case-insensitive).\n * - Returns [] gracefully when nothing is registered — the editor then behaves as a\n * plain text editor.\n *\n * Results are sorted by provider `Priority` (desc), then `Key` (asc) for stability.\n */\nexport function DiscoverComposerTriggerProviders(excludedKeys?: string[]): ComposerTriggerProvider[] {\n const factory = MJGlobal.Instance.ClassFactory;\n const registrations = factory.GetAllRegistrations(ComposerTriggerProvider);\n if (!registrations || registrations.length === 0) {\n return [];\n }\n\n const excluded = new Set((excludedKeys ?? []).map((k) => k.trim().toLowerCase()));\n const seenKeys = new Set<string>();\n const providers: ComposerTriggerProvider[] = [];\n\n for (const registration of registrations) {\n const normalizedKey = registration.Key?.trim().toLowerCase();\n if (!normalizedKey || seenKeys.has(normalizedKey) || excluded.has(normalizedKey)) {\n continue;\n }\n seenKeys.add(normalizedKey);\n\n // Resolve the WINNING registration for this key (there may be multiple when a\n // consumer overrides a provider) — mirrors GetRegistration's priority semantics.\n const winner = factory.GetRegistration(ComposerTriggerProvider, registration.Key);\n if (!winner?.SubClass) {\n continue;\n }\n\n let instance = discoveredProviderInstances.get(winner.SubClass);\n if (!instance) {\n const ProviderConstructor = winner.SubClass as new () => ComposerTriggerProvider;\n instance = new ProviderConstructor();\n discoveredProviderInstances.set(winner.SubClass, instance);\n }\n providers.push(instance);\n }\n\n return providers.sort((a, b) => {\n if (b.Priority !== a.Priority) return b.Priority - a.Priority;\n return a.Key.localeCompare(b.Key);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"composer-trigger-provider.js","sourceRoot":"","sources":["../../src/lib/composer-trigger-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAuGlD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAgB,uBAAuB;IAU3C;;;OAGG;IACa,QAAQ,GAAW,CAAC,CAAC;IASrC;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAC,WAA4B;QAClD,oDAAoD;QACpD,KAAK,WAAW,CAAC;IACnB,CAAC;IAED;;;OAGG;IACI,oBAAoB,CAAC,UAA6B,EAAE,WAA4B;QACrF,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW,CAAC;IACnB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,2BAA2B,GAAG,IAAI,GAAG,EAAoC,CAAC;AAEhF;;;;;;;;;;;;;GAaG;AACH,MAAM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C;YACjF,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAC;YACrC,2BAA2B,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;YAAE,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QAC9D,OAAO,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { IMetadataProvider, UserInfo } from '@memberjunction/core';\nimport { MJGlobal } from '@memberjunction/global';\n\n/**\n * A configuration preset attached to a mention suggestion (e.g. an agent's\n * Fast / Standard / High Power presets). When a suggestion carries 2+ presets the\n * mention editor renders a preset picker on the inserted chip; the selected preset's\n * ID/Name travel with the chip (`data-preset-id` / `data-preset-name`) and survive\n * serialization via `getPlainTextWithJsonMentions()`.\n *\n * This is a deliberately generic shape — the composer has no knowledge of what a\n * preset IS. Trigger providers map their domain objects (e.g. `MJ: AI Agent\n * Configurations` rows) into this shape when building suggestions.\n */\nexport interface MentionSuggestionPreset {\n /** Stable identifier stored on the chip (`data-preset-id`). */\n ID: string;\n /** Machine name stored on the chip (`data-preset-name`). */\n Name: string;\n /** Friendly label shown in the preset picker (falls back to Name). */\n DisplayName?: string;\n /** Optional descriptive text shown under the preset label. */\n Description?: string;\n /** The preset preselected on chip insert. First preset wins when none is flagged. */\n IsDefault?: boolean;\n}\n\n/**\n * Population filter narrowing which categories of `@` suggestions are returned.\n * Structurally identical to `MentionPopulationFilter` in `@memberjunction/conversations-runtime`.\n */\nexport type ComposerPopulationFilter = 'all' | 'my-agents' | 'shared' | 'people';\n\n/**\n * Field scope restricting which fields a non-empty `@` search query matches against.\n * Structurally identical to `MentionSearchField` in `@memberjunction/conversations-runtime`.\n */\nexport type ComposerSearchField = 'all' | 'name' | 'capabilities' | 'lineage';\n\n/**\n * Display section grouping key assigned to `@` mention suggestions.\n * Structurally identical to `MentionGroupKey` in `@memberjunction/conversations-runtime`.\n */\nexport type ComposerGroupKey = 'frequent' | 'my-agents' | 'shared' | 'people' | 'results';\n\n/**\n * Item in the mention-autocomplete dropdown, and the payload carried by an inserted\n * mention chip. Fully generic — `type` is an open string (providers choose their own\n * vocabulary, e.g. 'agent' | 'user' | 'entity' | 'query' | 'skill'); the editor and\n * dropdown only use it for cosmetic styling (chip palette, badge label) and for the\n * plain-text serialization prefix.\n */\nexport interface MentionSuggestion {\n /** Open string discriminator chosen by the provider (drives chip/badge styling). */\n type: string;\n id: string;\n name: string;\n displayName: string;\n description?: string;\n /** Image rendered in the dropdown row + chip when present (e.g. an agent LogoURL). */\n imageUrl?: string;\n /** Font Awesome (or custom) icon class for the dropdown row + chip. */\n icon?: string;\n /** Accent color for the chip/badge (e.g. a skill's own Color UX metadata). */\n color?: string;\n /** Optional presets — 2+ presets render a preset picker on the inserted chip. */\n presets?: MentionSuggestionPreset[];\n /** Provider-defined extra payload; the composer never inspects it. */\n data?: Record<string, unknown>;\n /** Section key used to group suggestions in the dropdown. */\n group?: ComposerGroupKey;\n /** Human-readable section heading corresponding to {@link group}. */\n groupLabel?: string;\n /** Provenance / inheritance label (e.g. `'Chief of Staff · My Agent'`, `'Shared'`). */\n lineage?: string;\n /** True when this suggestion is a personal derived agent instance owned by the current user. */\n isMyAgent?: boolean;\n /** True when this suggestion matches the user's default chat agent. */\n isDefaultChatAgent?: boolean;\n /** True when this suggestion is already active in the current conversation thread. */\n isInCurrentThread?: boolean;\n /** Decayed frequency + recency score for this item. */\n frecencyScore?: number;\n}\n\n/**\n * Request passed to {@link ComposerTriggerProvider.GetSuggestions} each time the user\n * types after an active trigger character.\n */\nexport interface ComposerSuggestionRequest {\n /** The text typed after the trigger character (may be empty — show the full list). */\n Query: string;\n /** Maximum number of suggestions the editor will display; providers should honor it. */\n MaxResults: number;\n /** The current user, when the host supplied one. Providers should fail closed (return []) if they require a user and none is present. */\n ContextUser: UserInfo | null;\n /** The metadata provider scoping this editor instance, when the host supplied one (multi-provider support). */\n Provider: IMetadataProvider | null;\n /** Optional population filter selected in the `@` dropdown header (`'all'` by default). */\n PopulationFilter?: ComposerPopulationFilter;\n /** Optional search-field scope selected in the `@` dropdown header (`'all'` by default). */\n SearchField?: ComposerSearchField;\n}\n\n/**\n * Pluggable mention/command trigger for the composer's mention editor.\n *\n * Each provider owns ONE trigger character (e.g. '@', '#', '/') and supplies the\n * suggestions shown while the user types after it. The composer itself ships with\n * ZERO providers — it is a plain text editor until providers are supplied, either:\n *\n * 1. **Explicitly** — bind `[TriggerProviders]` on `mj-mention-editor` /\n * `mj-message-input-box` with provider instances (explicit list always wins), or\n * 2. **By discovery** — register subclasses with the MJ ClassFactory via\n * `@RegisterClass(ComposerTriggerProvider, '<Key>')`; the editor resolves them\n * through {@link DiscoverComposerTriggerProviders} when no explicit list is bound.\n * Hosts opt individual triggers out with `[ExcludedTriggerKeys]`.\n *\n * The AI-aware providers (agent mentions, entity/query record mentions, skill\n * commands) live in `@memberjunction/ng-conversations` — see its `composer-plugins`\n * folder and the `mj-ai-composer` wrapper component.\n */\nexport abstract class ComposerTriggerProvider {\n /** The single character that opens this provider's autocomplete (e.g. '@'). */\n public abstract readonly TriggerChar: string;\n\n /**\n * Stable identifier for this provider (e.g. 'agent-mentions'). Used as the\n * ClassFactory registration key and by `ExcludedTriggerKeys` filtering.\n */\n public abstract readonly Key: string;\n\n /**\n * Ordering weight — higher runs first. When multiple providers share a\n * TriggerChar, results are concatenated in priority order (then Key order).\n */\n public readonly Priority: number = 0;\n\n /**\n * Returns the suggestions for the current query. Called on every keystroke after\n * an active trigger; implementations should be fast (serve from warm caches) and\n * must never throw — return [] on failure.\n */\n public abstract GetSuggestions(request: ComposerSuggestionRequest): Promise<MentionSuggestion[]>;\n\n /**\n * Optional warm-up hook, invoked once by the editor when it initializes with this\n * provider active. Default is a no-op; override to pre-load caches so the first\n * keystroke is fast. Must be safe to call repeatedly and concurrently.\n */\n public async Initialize(contextUser: UserInfo | null): Promise<void> {\n // default no-op — providers override to warm caches\n void contextUser;\n }\n\n /**\n * Optional selection hook invoked by the mention editor whenever the user inserts a\n * suggestion owned by this trigger (e.g. to record frecency telemetry). Default is a no-op.\n */\n public OnSuggestionSelected(suggestion: MentionSuggestion, contextUser: UserInfo | null): void {\n void suggestion;\n void contextUser;\n }\n}\n\n/**\n * One instance per registered provider subclass, shared across all editors in the\n * process — providers are expected to be stateless facades over shared engines, so a\n * single instance avoids duplicate cache warm-ups.\n */\nconst discoveredProviderInstances = new Map<unknown, ComposerTriggerProvider>();\n\n/**\n * Resolves every `@RegisterClass(ComposerTriggerProvider, ...)` registration in the\n * MJ ClassFactory into a provider instance list.\n *\n * - Instantiates each winning registration once (module-level cache keyed by the\n * registered subclass) — repeated calls are cheap.\n * - When multiple registrations share a Key, the ClassFactory's highest-priority\n * registration wins (standard override-by-import-order semantics).\n * - `excludedKeys` filters providers out by their stable Key (case-insensitive).\n * - Returns [] gracefully when nothing is registered — the editor then behaves as a\n * plain text editor.\n *\n * Results are sorted by provider `Priority` (desc), then `Key` (asc) for stability.\n */\nexport function DiscoverComposerTriggerProviders(excludedKeys?: string[]): ComposerTriggerProvider[] {\n const factory = MJGlobal.Instance.ClassFactory;\n const registrations = factory.GetAllRegistrations(ComposerTriggerProvider);\n if (!registrations || registrations.length === 0) {\n return [];\n }\n\n const excluded = new Set((excludedKeys ?? []).map((k) => k.trim().toLowerCase()));\n const seenKeys = new Set<string>();\n const providers: ComposerTriggerProvider[] = [];\n\n for (const registration of registrations) {\n const normalizedKey = registration.Key?.trim().toLowerCase();\n if (!normalizedKey || seenKeys.has(normalizedKey) || excluded.has(normalizedKey)) {\n continue;\n }\n seenKeys.add(normalizedKey);\n\n // Resolve the WINNING registration for this key (there may be multiple when a\n // consumer overrides a provider) — mirrors GetRegistration's priority semantics.\n const winner = factory.GetRegistration(ComposerTriggerProvider, registration.Key);\n if (!winner?.SubClass) {\n continue;\n }\n\n let instance = discoveredProviderInstances.get(winner.SubClass);\n if (!instance) {\n const ProviderConstructor = winner.SubClass as new () => ComposerTriggerProvider;\n instance = new ProviderConstructor();\n discoveredProviderInstances.set(winner.SubClass, instance);\n }\n providers.push(instance);\n }\n\n return providers.sort((a, b) => {\n if (b.Priority !== a.Priority) return b.Priority - a.Priority;\n return a.Key.localeCompare(b.Key);\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-composer",
|
|
3
|
-
"version": "6.3.0-edge.
|
|
3
|
+
"version": "6.3.0-edge.3",
|
|
4
4
|
"description": "MemberJunction: Generic message composer components — mention editor with pluggable trigger providers (ComposerTriggerProvider), mention dropdown, and send-button input box wrapper. Ships zero AI knowledge; trigger plugins are supplied by hosts (see @memberjunction/ng-conversations).",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@angular/compiler": "21.2.22",
|
|
15
15
|
"@angular/compiler-cli": "21.2.22",
|
|
16
|
-
"@memberjunction/ng-test-utils": "6.3.0-edge.
|
|
16
|
+
"@memberjunction/ng-test-utils": "6.3.0-edge.3",
|
|
17
17
|
"vitest": "^4.0.18"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"@angular/forms": "^21.2.22"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@memberjunction/core": "6.3.0-edge.
|
|
26
|
-
"@memberjunction/global": "6.3.0-edge.
|
|
27
|
-
"@memberjunction/ng-ui-components": "6.3.0-edge.
|
|
25
|
+
"@memberjunction/core": "6.3.0-edge.3",
|
|
26
|
+
"@memberjunction/global": "6.3.0-edge.3",
|
|
27
|
+
"@memberjunction/ng-ui-components": "6.3.0-edge.3",
|
|
28
28
|
"tslib": "^2.8.1"
|
|
29
29
|
},
|
|
30
30
|
"sideEffects": false,
|