@memberjunction/ng-conversations 2.104.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/README.md +197 -0
- package/dist/lib/components/active-tasks/active-tasks-panel.component.d.ts +20 -0
- package/dist/lib/components/active-tasks/active-tasks-panel.component.d.ts.map +1 -0
- package/dist/lib/components/active-tasks/active-tasks-panel.component.js +125 -0
- package/dist/lib/components/active-tasks/active-tasks-panel.component.js.map +1 -0
- package/dist/lib/components/agent/active-agent-indicator.component.d.ts +48 -0
- package/dist/lib/components/agent/active-agent-indicator.component.d.ts.map +1 -0
- package/dist/lib/components/agent/active-agent-indicator.component.js +199 -0
- package/dist/lib/components/agent/active-agent-indicator.component.js.map +1 -0
- package/dist/lib/components/agent/agent-process-panel.component.d.ts +30 -0
- package/dist/lib/components/agent/agent-process-panel.component.d.ts.map +1 -0
- package/dist/lib/components/agent/agent-process-panel.component.js +333 -0
- package/dist/lib/components/agent/agent-process-panel.component.js.map +1 -0
- package/dist/lib/components/artifact/artifact-panel.component.d.ts +22 -0
- package/dist/lib/components/artifact/artifact-panel.component.d.ts.map +1 -0
- package/dist/lib/components/artifact/artifact-panel.component.js +237 -0
- package/dist/lib/components/artifact/artifact-panel.component.js.map +1 -0
- package/dist/lib/components/artifact/artifact-upload-modal.component.d.ts +39 -0
- package/dist/lib/components/artifact/artifact-upload-modal.component.d.ts.map +1 -0
- package/dist/lib/components/artifact/artifact-upload-modal.component.js +384 -0
- package/dist/lib/components/artifact/artifact-upload-modal.component.js.map +1 -0
- package/dist/lib/components/artifact/artifact-version-history.component.d.ts +28 -0
- package/dist/lib/components/artifact/artifact-version-history.component.d.ts.map +1 -0
- package/dist/lib/components/artifact/artifact-version-history.component.js +280 -0
- package/dist/lib/components/artifact/artifact-version-history.component.js.map +1 -0
- package/dist/lib/components/artifact/artifact-viewer-panel.component.d.ts +22 -0
- package/dist/lib/components/artifact/artifact-viewer-panel.component.d.ts.map +1 -0
- package/dist/lib/components/artifact/artifact-viewer-panel.component.js +182 -0
- package/dist/lib/components/artifact/artifact-viewer-panel.component.js.map +1 -0
- package/dist/lib/components/artifact/artifact-viewer.component.d.ts +27 -0
- package/dist/lib/components/artifact/artifact-viewer.component.d.ts.map +1 -0
- package/dist/lib/components/artifact/artifact-viewer.component.js +266 -0
- package/dist/lib/components/artifact/artifact-viewer.component.js.map +1 -0
- package/dist/lib/components/artifact/inline-artifact.component.d.ts +46 -0
- package/dist/lib/components/artifact/inline-artifact.component.d.ts.map +1 -0
- package/dist/lib/components/artifact/inline-artifact.component.js +447 -0
- package/dist/lib/components/artifact/inline-artifact.component.js.map +1 -0
- package/dist/lib/components/collection/collection-artifact-card.component.d.ts +18 -0
- package/dist/lib/components/collection/collection-artifact-card.component.d.ts.map +1 -0
- package/dist/lib/components/collection/collection-artifact-card.component.js +147 -0
- package/dist/lib/components/collection/collection-artifact-card.component.js.map +1 -0
- package/dist/lib/components/collection/collection-form-modal.component.d.ts +33 -0
- package/dist/lib/components/collection/collection-form-modal.component.d.ts.map +1 -0
- package/dist/lib/components/collection/collection-form-modal.component.js +245 -0
- package/dist/lib/components/collection/collection-form-modal.component.js.map +1 -0
- package/dist/lib/components/collection/collection-tree.component.d.ts +42 -0
- package/dist/lib/components/collection/collection-tree.component.d.ts.map +1 -0
- package/dist/lib/components/collection/collection-tree.component.js +482 -0
- package/dist/lib/components/collection/collection-tree.component.js.map +1 -0
- package/dist/lib/components/collection/collection-view.component.d.ts +31 -0
- package/dist/lib/components/collection/collection-view.component.d.ts.map +1 -0
- package/dist/lib/components/collection/collection-view.component.js +254 -0
- package/dist/lib/components/collection/collection-view.component.js.map +1 -0
- package/dist/lib/components/collection/collections-full-view.component.d.ts +55 -0
- package/dist/lib/components/collection/collections-full-view.component.d.ts.map +1 -0
- package/dist/lib/components/collection/collections-full-view.component.js +578 -0
- package/dist/lib/components/collection/collections-full-view.component.js.map +1 -0
- package/dist/lib/components/conversation/conversation-chat-area.component.d.ts +160 -0
- package/dist/lib/components/conversation/conversation-chat-area.component.d.ts.map +1 -0
- package/dist/lib/components/conversation/conversation-chat-area.component.js +891 -0
- package/dist/lib/components/conversation/conversation-chat-area.component.js.map +1 -0
- package/dist/lib/components/conversation/conversation-list.component.d.ts +29 -0
- package/dist/lib/components/conversation/conversation-list.component.d.ts.map +1 -0
- package/dist/lib/components/conversation/conversation-list.component.js +255 -0
- package/dist/lib/components/conversation/conversation-list.component.js.map +1 -0
- package/dist/lib/components/dialogs/input-dialog.component.d.ts +17 -0
- package/dist/lib/components/dialogs/input-dialog.component.d.ts.map +1 -0
- package/dist/lib/components/dialogs/input-dialog.component.js +122 -0
- package/dist/lib/components/dialogs/input-dialog.component.js.map +1 -0
- package/dist/lib/components/export/export-modal.component.d.ts +37 -0
- package/dist/lib/components/export/export-modal.component.d.ts.map +1 -0
- package/dist/lib/components/export/export-modal.component.js +414 -0
- package/dist/lib/components/export/export-modal.component.js.map +1 -0
- package/dist/lib/components/library/library-full-view.component.d.ts +36 -0
- package/dist/lib/components/library/library-full-view.component.d.ts.map +1 -0
- package/dist/lib/components/library/library-full-view.component.js +270 -0
- package/dist/lib/components/library/library-full-view.component.js.map +1 -0
- package/dist/lib/components/members/members-modal.component.d.ts +42 -0
- package/dist/lib/components/members/members-modal.component.d.ts.map +1 -0
- package/dist/lib/components/members/members-modal.component.js +352 -0
- package/dist/lib/components/members/members-modal.component.js.map +1 -0
- package/dist/lib/components/mention/mention-dropdown.component.d.ts +44 -0
- package/dist/lib/components/mention/mention-dropdown.component.d.ts.map +1 -0
- package/dist/lib/components/mention/mention-dropdown.component.js +194 -0
- package/dist/lib/components/mention/mention-dropdown.component.js.map +1 -0
- package/dist/lib/components/message/message-input.component.d.ts +137 -0
- package/dist/lib/components/message/message-input.component.d.ts.map +1 -0
- package/dist/lib/components/message/message-input.component.js +1159 -0
- package/dist/lib/components/message/message-input.component.js.map +1 -0
- package/dist/lib/components/message/message-item.component.d.ts +140 -0
- package/dist/lib/components/message/message-item.component.d.ts.map +1 -0
- package/dist/lib/components/message/message-item.component.js +817 -0
- package/dist/lib/components/message/message-item.component.js.map +1 -0
- package/dist/lib/components/message/message-list.component.d.ts +77 -0
- package/dist/lib/components/message/message-list.component.d.ts.map +1 -0
- package/dist/lib/components/message/message-list.component.js +316 -0
- package/dist/lib/components/message/message-list.component.js.map +1 -0
- package/dist/lib/components/navigation/conversation-navigation.component.d.ts +13 -0
- package/dist/lib/components/navigation/conversation-navigation.component.d.ts.map +1 -0
- package/dist/lib/components/navigation/conversation-navigation.component.js +88 -0
- package/dist/lib/components/navigation/conversation-navigation.component.js.map +1 -0
- package/dist/lib/components/notification/activity-indicator.component.d.ts +11 -0
- package/dist/lib/components/notification/activity-indicator.component.d.ts.map +1 -0
- package/dist/lib/components/notification/activity-indicator.component.js +56 -0
- package/dist/lib/components/notification/activity-indicator.component.js.map +1 -0
- package/dist/lib/components/notification/notification-badge.component.d.ts +27 -0
- package/dist/lib/components/notification/notification-badge.component.d.ts.map +1 -0
- package/dist/lib/components/notification/notification-badge.component.js +160 -0
- package/dist/lib/components/notification/notification-badge.component.js.map +1 -0
- package/dist/lib/components/project/project-form-modal.component.d.ts +34 -0
- package/dist/lib/components/project/project-form-modal.component.d.ts.map +1 -0
- package/dist/lib/components/project/project-form-modal.component.js +357 -0
- package/dist/lib/components/project/project-form-modal.component.js.map +1 -0
- package/dist/lib/components/project/project-selector.component.d.ts +36 -0
- package/dist/lib/components/project/project-selector.component.d.ts.map +1 -0
- package/dist/lib/components/project/project-selector.component.js +317 -0
- package/dist/lib/components/project/project-selector.component.js.map +1 -0
- package/dist/lib/components/search/search-panel.component.d.ts +120 -0
- package/dist/lib/components/search/search-panel.component.d.ts.map +1 -0
- package/dist/lib/components/search/search-panel.component.js +714 -0
- package/dist/lib/components/search/search-panel.component.js.map +1 -0
- package/dist/lib/components/share/share-modal.component.d.ts +46 -0
- package/dist/lib/components/share/share-modal.component.d.ts.map +1 -0
- package/dist/lib/components/share/share-modal.component.js +431 -0
- package/dist/lib/components/share/share-modal.component.js.map +1 -0
- package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts +18 -0
- package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts.map +1 -0
- package/dist/lib/components/sidebar/conversation-sidebar.component.js +81 -0
- package/dist/lib/components/sidebar/conversation-sidebar.component.js.map +1 -0
- package/dist/lib/components/task/task-form-modal.component.d.ts +42 -0
- package/dist/lib/components/task/task-form-modal.component.d.ts.map +1 -0
- package/dist/lib/components/task/task-form-modal.component.js +329 -0
- package/dist/lib/components/task/task-form-modal.component.js.map +1 -0
- package/dist/lib/components/task/task-item.component.d.ts +22 -0
- package/dist/lib/components/task/task-item.component.d.ts.map +1 -0
- package/dist/lib/components/task/task-item.component.js +234 -0
- package/dist/lib/components/task/task-item.component.js.map +1 -0
- package/dist/lib/components/task/task-list.component.d.ts +32 -0
- package/dist/lib/components/task/task-list.component.d.ts.map +1 -0
- package/dist/lib/components/task/task-list.component.js +290 -0
- package/dist/lib/components/task/task-list.component.js.map +1 -0
- package/dist/lib/components/tasks/tasks-dropdown.component.d.ts +27 -0
- package/dist/lib/components/tasks/tasks-dropdown.component.d.ts.map +1 -0
- package/dist/lib/components/tasks/tasks-dropdown.component.js +254 -0
- package/dist/lib/components/tasks/tasks-dropdown.component.js.map +1 -0
- package/dist/lib/components/thread/thread-panel.component.d.ts +65 -0
- package/dist/lib/components/thread/thread-panel.component.d.ts.map +1 -0
- package/dist/lib/components/thread/thread-panel.component.js +325 -0
- package/dist/lib/components/thread/thread-panel.component.js.map +1 -0
- package/dist/lib/components/toast/toast.component.d.ts +26 -0
- package/dist/lib/components/toast/toast.component.d.ts.map +1 -0
- package/dist/lib/components/toast/toast.component.js +108 -0
- package/dist/lib/components/toast/toast.component.js.map +1 -0
- package/dist/lib/components/workspace/conversation-workspace.component.d.ts +75 -0
- package/dist/lib/components/workspace/conversation-workspace.component.d.ts.map +1 -0
- package/dist/lib/components/workspace/conversation-workspace.component.js +299 -0
- package/dist/lib/components/workspace/conversation-workspace.component.js.map +1 -0
- package/dist/lib/conversations.module.d.ts +62 -0
- package/dist/lib/conversations.module.d.ts.map +1 -0
- package/dist/lib/conversations.module.js +248 -0
- package/dist/lib/conversations.module.js.map +1 -0
- package/dist/lib/directives/search-shortcut.directive.d.ts +17 -0
- package/dist/lib/directives/search-shortcut.directive.d.ts.map +1 -0
- package/dist/lib/directives/search-shortcut.directive.js +39 -0
- package/dist/lib/directives/search-shortcut.directive.js.map +1 -0
- package/dist/lib/models/conversation-state.model.d.ts +72 -0
- package/dist/lib/models/conversation-state.model.d.ts.map +1 -0
- package/dist/lib/models/conversation-state.model.js +2 -0
- package/dist/lib/models/conversation-state.model.js.map +1 -0
- package/dist/lib/models/notification.model.d.ts +89 -0
- package/dist/lib/models/notification.model.d.ts.map +1 -0
- package/dist/lib/models/notification.model.js +11 -0
- package/dist/lib/models/notification.model.js.map +1 -0
- package/dist/lib/services/active-tasks.service.d.ts +65 -0
- package/dist/lib/services/active-tasks.service.d.ts.map +1 -0
- package/dist/lib/services/active-tasks.service.js +95 -0
- package/dist/lib/services/active-tasks.service.js.map +1 -0
- package/dist/lib/services/agent-state.service.d.ts +78 -0
- package/dist/lib/services/agent-state.service.d.ts.map +1 -0
- package/dist/lib/services/agent-state.service.js +213 -0
- package/dist/lib/services/agent-state.service.js.map +1 -0
- package/dist/lib/services/artifact-state.service.d.ts +114 -0
- package/dist/lib/services/artifact-state.service.d.ts.map +1 -0
- package/dist/lib/services/artifact-state.service.js +288 -0
- package/dist/lib/services/artifact-state.service.js.map +1 -0
- package/dist/lib/services/conversation-agent.service.d.ts +79 -0
- package/dist/lib/services/conversation-agent.service.d.ts.map +1 -0
- package/dist/lib/services/conversation-agent.service.js +259 -0
- package/dist/lib/services/conversation-agent.service.js.map +1 -0
- package/dist/lib/services/conversation-state.service.d.ts +122 -0
- package/dist/lib/services/conversation-state.service.d.ts.map +1 -0
- package/dist/lib/services/conversation-state.service.js +255 -0
- package/dist/lib/services/conversation-state.service.js.map +1 -0
- package/dist/lib/services/dialog.service.d.ts +54 -0
- package/dist/lib/services/dialog.service.d.ts.map +1 -0
- package/dist/lib/services/dialog.service.js +157 -0
- package/dist/lib/services/dialog.service.js.map +1 -0
- package/dist/lib/services/export.service.d.ts +25 -0
- package/dist/lib/services/export.service.d.ts.map +1 -0
- package/dist/lib/services/export.service.js +237 -0
- package/dist/lib/services/export.service.js.map +1 -0
- package/dist/lib/services/mention-autocomplete.service.d.ts +59 -0
- package/dist/lib/services/mention-autocomplete.service.d.ts.map +1 -0
- package/dist/lib/services/mention-autocomplete.service.js +160 -0
- package/dist/lib/services/mention-autocomplete.service.js.map +1 -0
- package/dist/lib/services/mention-parser.service.d.ts +46 -0
- package/dist/lib/services/mention-parser.service.d.ts.map +1 -0
- package/dist/lib/services/mention-parser.service.js +156 -0
- package/dist/lib/services/mention-parser.service.js.map +1 -0
- package/dist/lib/services/notification.service.d.ts +108 -0
- package/dist/lib/services/notification.service.d.ts.map +1 -0
- package/dist/lib/services/notification.service.js +431 -0
- package/dist/lib/services/notification.service.js.map +1 -0
- package/dist/lib/services/search.service.d.ts +144 -0
- package/dist/lib/services/search.service.d.ts.map +1 -0
- package/dist/lib/services/search.service.js +370 -0
- package/dist/lib/services/search.service.js.map +1 -0
- package/dist/lib/services/toast.service.d.ts +46 -0
- package/dist/lib/services/toast.service.d.ts.map +1 -0
- package/dist/lib/services/toast.service.js +76 -0
- package/dist/lib/services/toast.service.js.map +1 -0
- package/dist/public-api.d.ts +42 -0
- package/dist/public-api.d.ts.map +1 -0
- package/dist/public-api.js +49 -0
- package/dist/public-api.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { ExecuteAgentResult, AgentExecutionProgressCallback } from '@memberjunction/ai-core-plus';
|
|
3
|
+
import { AIAgentEntityExtended, ConversationDetailEntity } from '@memberjunction/core-entities';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Service for managing agent interactions within conversations.
|
|
7
|
+
* Handles communication with the ambient Conversation Manager Agent and other agents.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ConversationAgentService {
|
|
10
|
+
private _aiClient;
|
|
11
|
+
private _conversationManagerAgent;
|
|
12
|
+
private _sessionIds;
|
|
13
|
+
private _isProcessing$;
|
|
14
|
+
/**
|
|
15
|
+
* Observable indicating if the ambient agent is currently processing
|
|
16
|
+
*/
|
|
17
|
+
readonly isProcessing$: Observable<boolean>;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the GraphQL AI Client
|
|
21
|
+
*/
|
|
22
|
+
private initializeAIClient;
|
|
23
|
+
/**
|
|
24
|
+
* Get or load the Conversation Manager Agent
|
|
25
|
+
*/
|
|
26
|
+
getConversationManagerAgent(): Promise<AIAgentEntityExtended | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Get or create a session ID for a conversation
|
|
29
|
+
*/
|
|
30
|
+
private getSessionId;
|
|
31
|
+
/**
|
|
32
|
+
* Process a message through the ambient Conversation Manager Agent.
|
|
33
|
+
* This should be called for every message sent in a conversation.
|
|
34
|
+
*
|
|
35
|
+
* @param conversationId The conversation ID
|
|
36
|
+
* @param message The message that was just sent
|
|
37
|
+
* @param conversationHistory Recent messages in the conversation for context
|
|
38
|
+
* @param conversationDetailId The ID of the conversation detail record to link to the agent run
|
|
39
|
+
* @param onProgress Optional callback for receiving progress updates during execution
|
|
40
|
+
* @returns The agent's response, or null if the agent chooses not to respond
|
|
41
|
+
*/
|
|
42
|
+
processMessage(conversationId: string, message: ConversationDetailEntity, conversationHistory: ConversationDetailEntity[], conversationDetailId: string, onProgress?: AgentExecutionProgressCallback): Promise<ExecuteAgentResult | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Build the message array for the agent from conversation history
|
|
45
|
+
*/
|
|
46
|
+
private buildAgentMessages;
|
|
47
|
+
/**
|
|
48
|
+
* Map ConversationDetail Role to agent message role
|
|
49
|
+
*/
|
|
50
|
+
private mapRoleToAgentRole;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a message is tagging another user or agent.
|
|
53
|
+
* Returns true if the message contains @mentions that are NOT the ambient agent.
|
|
54
|
+
* Future enhancement: parse @mentions and determine if ambient agent should process.
|
|
55
|
+
*/
|
|
56
|
+
private isTaggingOthers;
|
|
57
|
+
/**
|
|
58
|
+
* Invoke a sub-agent based on Conversation Manager Agent's payload.
|
|
59
|
+
* This is called when the Conversation Manager decides to delegate to a specialist agent.
|
|
60
|
+
*
|
|
61
|
+
* @param agentName Name of the agent to invoke
|
|
62
|
+
* @param conversationId The conversation ID
|
|
63
|
+
* @param message The user message that triggered this
|
|
64
|
+
* @param conversationHistory Recent conversation history for context
|
|
65
|
+
* @param reasoning Why this agent is being invoked
|
|
66
|
+
* @param conversationDetailId The ID of the conversation detail record to link to the agent run
|
|
67
|
+
* @param payload Optional payload to pass to the agent (e.g., previous OUTPUT artifact for continuity)
|
|
68
|
+
* @param onProgress Optional callback for receiving progress updates during execution
|
|
69
|
+
* @returns The agent's execution result, or null if agent not found
|
|
70
|
+
*/
|
|
71
|
+
invokeSubAgent(agentName: string, conversationId: string, message: ConversationDetailEntity, conversationHistory: ConversationDetailEntity[], reasoning: string, conversationDetailId: string, payload?: any, onProgress?: AgentExecutionProgressCallback): Promise<ExecuteAgentResult | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Clear the session for a conversation (useful when starting a new topic)
|
|
74
|
+
*/
|
|
75
|
+
clearSession(conversationId: string): void;
|
|
76
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ConversationAgentService, never>;
|
|
77
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ConversationAgentService>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=conversation-agent.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-agent.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/conversation-ag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,GAAG,IAAI,CAAC;IAqDrC;;OAEG;IACH,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;yCAxR/B,wBAAwB;6CAAxB,wBAAwB;CA2RpC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { Metadata } from '@memberjunction/core';
|
|
4
|
+
import { GraphQLAIClient } from '@memberjunction/graphql-dataprovider';
|
|
5
|
+
import { AIEngineBase } from '@memberjunction/ai-engine-base';
|
|
6
|
+
import { MJNotificationService } from '@memberjunction/ng-notifications';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
/**
|
|
9
|
+
* Service for managing agent interactions within conversations.
|
|
10
|
+
* Handles communication with the ambient Conversation Manager Agent and other agents.
|
|
11
|
+
*/
|
|
12
|
+
export class ConversationAgentService {
|
|
13
|
+
_aiClient = null;
|
|
14
|
+
_conversationManagerAgent = null;
|
|
15
|
+
_sessionIds = new Map(); // conversationId -> sessionId
|
|
16
|
+
_isProcessing$ = new BehaviorSubject(false);
|
|
17
|
+
/**
|
|
18
|
+
* Observable indicating if the ambient agent is currently processing
|
|
19
|
+
*/
|
|
20
|
+
isProcessing$ = this._isProcessing$.asObservable();
|
|
21
|
+
constructor() {
|
|
22
|
+
this.initializeAIClient();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the GraphQL AI Client
|
|
26
|
+
*/
|
|
27
|
+
initializeAIClient() {
|
|
28
|
+
try {
|
|
29
|
+
const provider = Metadata.Provider;
|
|
30
|
+
if (provider) {
|
|
31
|
+
this._aiClient = new GraphQLAIClient(provider);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.warn('GraphQLDataProvider not available, agent functionality will be limited');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error('Failed to initialize GraphQL AI Client:', error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get or load the Conversation Manager Agent
|
|
43
|
+
*/
|
|
44
|
+
async getConversationManagerAgent() {
|
|
45
|
+
if (this._conversationManagerAgent) {
|
|
46
|
+
return this._conversationManagerAgent;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
// Ensure AIEngineBase is configured
|
|
50
|
+
await AIEngineBase.Instance.Config(false);
|
|
51
|
+
// Find the Conversation Manager Agent
|
|
52
|
+
const agents = AIEngineBase.Instance.Agents;
|
|
53
|
+
this._conversationManagerAgent = agents.find((agent) => agent.Name === 'Conversation Manager Agent') || null;
|
|
54
|
+
if (!this._conversationManagerAgent) {
|
|
55
|
+
const errorMsg = 'Conversation Manager Agent not found in AIEngineBase.Agents';
|
|
56
|
+
console.warn(errorMsg);
|
|
57
|
+
MJNotificationService.Instance?.CreateSimpleNotification(errorMsg, 'error', 5000);
|
|
58
|
+
}
|
|
59
|
+
return this._conversationManagerAgent;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
const errorMsg = 'Error loading Conversation Manager Agent: ' + (error instanceof Error ? error.message : String(error));
|
|
63
|
+
console.error('Error loading Conversation Manager Agent:', error);
|
|
64
|
+
MJNotificationService.Instance?.CreateSimpleNotification(errorMsg, 'error', 5000);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get or create a session ID for a conversation
|
|
70
|
+
*/
|
|
71
|
+
getSessionId(conversationId) {
|
|
72
|
+
if (!this._sessionIds.has(conversationId)) {
|
|
73
|
+
// Create a new session ID for this conversation
|
|
74
|
+
this._sessionIds.set(conversationId, `conv-${conversationId}-${Date.now()}`);
|
|
75
|
+
}
|
|
76
|
+
return this._sessionIds.get(conversationId);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Process a message through the ambient Conversation Manager Agent.
|
|
80
|
+
* This should be called for every message sent in a conversation.
|
|
81
|
+
*
|
|
82
|
+
* @param conversationId The conversation ID
|
|
83
|
+
* @param message The message that was just sent
|
|
84
|
+
* @param conversationHistory Recent messages in the conversation for context
|
|
85
|
+
* @param conversationDetailId The ID of the conversation detail record to link to the agent run
|
|
86
|
+
* @param onProgress Optional callback for receiving progress updates during execution
|
|
87
|
+
* @returns The agent's response, or null if the agent chooses not to respond
|
|
88
|
+
*/
|
|
89
|
+
async processMessage(conversationId, message, conversationHistory, conversationDetailId, onProgress) {
|
|
90
|
+
// Don't process if user is tagging someone else (future enhancement)
|
|
91
|
+
// For now, we'll always send to the ambient agent
|
|
92
|
+
if (!this._aiClient) {
|
|
93
|
+
const errorMsg = 'AI Client not initialized, cannot process message through agent';
|
|
94
|
+
console.warn(errorMsg);
|
|
95
|
+
MJNotificationService.Instance?.CreateSimpleNotification(errorMsg, 'warning', 5000);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const agent = await this.getConversationManagerAgent();
|
|
99
|
+
if (!agent || !agent.ID) {
|
|
100
|
+
const errorMsg = 'Conversation Manager Agent not available';
|
|
101
|
+
console.warn(errorMsg);
|
|
102
|
+
MJNotificationService.Instance?.CreateSimpleNotification(errorMsg, 'warning', 5000);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
// Indicate agent is processing
|
|
107
|
+
this._isProcessing$.next(true);
|
|
108
|
+
// Build conversation messages for the agent
|
|
109
|
+
const conversationMessages = this.buildAgentMessages(conversationHistory, message);
|
|
110
|
+
// Prepare parameters using the correct ExecuteAgentParams type
|
|
111
|
+
const availAgents = AIEngineBase.Instance.Agents.filter(a => a.ID !== agent.ID && !a.ParentID && a.Status === 'Active');
|
|
112
|
+
const params = {
|
|
113
|
+
agent: agent,
|
|
114
|
+
conversationMessages: conversationMessages,
|
|
115
|
+
conversationDetailId: conversationDetailId,
|
|
116
|
+
data: {
|
|
117
|
+
ALL_AVAILABLE_AGENTS: availAgents.map(a => {
|
|
118
|
+
return {
|
|
119
|
+
ID: a.ID,
|
|
120
|
+
Name: a.Name,
|
|
121
|
+
Description: a.Description
|
|
122
|
+
};
|
|
123
|
+
}),
|
|
124
|
+
conversationId: conversationId,
|
|
125
|
+
latestMessageId: message.ID
|
|
126
|
+
},
|
|
127
|
+
onProgress: onProgress
|
|
128
|
+
};
|
|
129
|
+
// Run the agent
|
|
130
|
+
const result = await this._aiClient.RunAIAgent(params);
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
const errorMsg = 'Error processing message through agent: ' + (error instanceof Error ? error.message : String(error));
|
|
135
|
+
console.error('Error processing message through agent:', error);
|
|
136
|
+
MJNotificationService.Instance?.CreateSimpleNotification(errorMsg, 'error', 5000);
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
// Always clear processing state
|
|
141
|
+
this._isProcessing$.next(false);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Build the message array for the agent from conversation history
|
|
146
|
+
*/
|
|
147
|
+
buildAgentMessages(history, currentMessage) {
|
|
148
|
+
const messages = [];
|
|
149
|
+
// Add historical messages (limit to recent context, e.g., last 20 messages)
|
|
150
|
+
const recentHistory = history.slice(-20);
|
|
151
|
+
for (const msg of recentHistory) {
|
|
152
|
+
messages.push({
|
|
153
|
+
role: this.mapRoleToAgentRole(msg.Role),
|
|
154
|
+
content: msg.Message || ''
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// Add the current message
|
|
158
|
+
messages.push({
|
|
159
|
+
role: this.mapRoleToAgentRole(currentMessage.Role),
|
|
160
|
+
content: currentMessage.Message || ''
|
|
161
|
+
});
|
|
162
|
+
return messages;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Map ConversationDetail Role to agent message role
|
|
166
|
+
*/
|
|
167
|
+
mapRoleToAgentRole(role) {
|
|
168
|
+
const roleLower = (role || '').toLowerCase();
|
|
169
|
+
if (roleLower === 'user')
|
|
170
|
+
return 'user';
|
|
171
|
+
if (roleLower === 'assistant' || roleLower === 'agent')
|
|
172
|
+
return 'assistant';
|
|
173
|
+
return 'user'; // Default to user
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Check if a message is tagging another user or agent.
|
|
177
|
+
* Returns true if the message contains @mentions that are NOT the ambient agent.
|
|
178
|
+
* Future enhancement: parse @mentions and determine if ambient agent should process.
|
|
179
|
+
*/
|
|
180
|
+
isTaggingOthers(message) {
|
|
181
|
+
// Future implementation: check for @mentions
|
|
182
|
+
// For now, always return false (always process through ambient agent)
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Invoke a sub-agent based on Conversation Manager Agent's payload.
|
|
187
|
+
* This is called when the Conversation Manager decides to delegate to a specialist agent.
|
|
188
|
+
*
|
|
189
|
+
* @param agentName Name of the agent to invoke
|
|
190
|
+
* @param conversationId The conversation ID
|
|
191
|
+
* @param message The user message that triggered this
|
|
192
|
+
* @param conversationHistory Recent conversation history for context
|
|
193
|
+
* @param reasoning Why this agent is being invoked
|
|
194
|
+
* @param conversationDetailId The ID of the conversation detail record to link to the agent run
|
|
195
|
+
* @param payload Optional payload to pass to the agent (e.g., previous OUTPUT artifact for continuity)
|
|
196
|
+
* @param onProgress Optional callback for receiving progress updates during execution
|
|
197
|
+
* @returns The agent's execution result, or null if agent not found
|
|
198
|
+
*/
|
|
199
|
+
async invokeSubAgent(agentName, conversationId, message, conversationHistory, reasoning, conversationDetailId, payload, onProgress) {
|
|
200
|
+
if (!this._aiClient) {
|
|
201
|
+
const errorMsg = 'AI Client not initialized, cannot invoke sub-agent';
|
|
202
|
+
console.warn(errorMsg);
|
|
203
|
+
MJNotificationService.Instance?.CreateSimpleNotification(errorMsg, 'warning', 5000);
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
// Ensure AIEngineBase is configured
|
|
208
|
+
await AIEngineBase.Instance.Config(false);
|
|
209
|
+
// Find the agent by name
|
|
210
|
+
const agent = AIEngineBase.Instance.Agents.find(a => a.Name === agentName);
|
|
211
|
+
if (!agent || !agent.ID) {
|
|
212
|
+
const errorMsg = `Sub-agent "${agentName}" not found`;
|
|
213
|
+
console.warn(`❌ ${errorMsg}`);
|
|
214
|
+
MJNotificationService.Instance?.CreateSimpleNotification(errorMsg, 'error', 5000);
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
console.log(`🎯 Invoking sub-agent: ${agentName}`, { reasoning, hasPayload: !!payload });
|
|
218
|
+
// Build conversation messages for the sub-agent
|
|
219
|
+
const conversationMessages = this.buildAgentMessages(conversationHistory, message);
|
|
220
|
+
// Prepare parameters with optional payload and progress callback
|
|
221
|
+
const params = {
|
|
222
|
+
agent: agent,
|
|
223
|
+
conversationMessages: conversationMessages,
|
|
224
|
+
conversationDetailId: conversationDetailId,
|
|
225
|
+
data: {
|
|
226
|
+
conversationId: conversationId,
|
|
227
|
+
latestMessageId: message.ID,
|
|
228
|
+
invocationReason: reasoning
|
|
229
|
+
},
|
|
230
|
+
...(payload ? { payload } : {}),
|
|
231
|
+
onProgress: onProgress
|
|
232
|
+
};
|
|
233
|
+
// Run the sub-agent
|
|
234
|
+
const result = await this._aiClient.RunAIAgent(params);
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
const errorMsg = `Error invoking sub-agent "${agentName}": ` + (error instanceof Error ? error.message : String(error));
|
|
239
|
+
console.error(`Error invoking sub-agent "${agentName}":`, error);
|
|
240
|
+
MJNotificationService.Instance?.CreateSimpleNotification(errorMsg, 'error', 5000);
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Clear the session for a conversation (useful when starting a new topic)
|
|
246
|
+
*/
|
|
247
|
+
clearSession(conversationId) {
|
|
248
|
+
this._sessionIds.delete(conversationId);
|
|
249
|
+
}
|
|
250
|
+
static ɵfac = function ConversationAgentService_Factory(t) { return new (t || ConversationAgentService)(); };
|
|
251
|
+
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ConversationAgentService, factory: ConversationAgentService.ɵfac, providedIn: 'root' });
|
|
252
|
+
}
|
|
253
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConversationAgentService, [{
|
|
254
|
+
type: Injectable,
|
|
255
|
+
args: [{
|
|
256
|
+
providedIn: 'root'
|
|
257
|
+
}]
|
|
258
|
+
}], () => [], null); })();
|
|
259
|
+
//# sourceMappingURL=conversation-agent.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-agent.service.js","sourceRoot":"","sources":["../../../src/lib/services/conversation-agent.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;;AAEzE;;;GAGG;AAIH,MAAM,OAAO,wBAAwB;IAC3B,SAAS,GAA2B,IAAI,CAAC;IACzC,yBAAyB,GAAiC,IAAI,CAAC;IAC/D,WAAW,GAAwB,IAAI,GAAG,EAAE,CAAC,CAAC,8BAA8B;IAC5E,cAAc,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC,CAAC;IAE7D;;OAEG;IACa,aAAa,GAAwB,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;IAExF;QACE,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACK,kBAAkB;QACxB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,QAAQ,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AM;;iFAEP,wBAAwB;cAHpC,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ConversationEntity } from '@memberjunction/core-entities';
|
|
2
|
+
import { UserInfo } from '@memberjunction/core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Simplified state management for conversations
|
|
6
|
+
* Uses simple arrays with Angular change detection instead of complex observables
|
|
7
|
+
* This prevents synchronization issues when updating conversation properties
|
|
8
|
+
*/
|
|
9
|
+
export declare class ConversationStateService {
|
|
10
|
+
conversations: ConversationEntity[];
|
|
11
|
+
activeConversationId: string | null;
|
|
12
|
+
searchQuery: string;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
activeThreadId: string | null;
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Gets the active conversation object
|
|
18
|
+
*/
|
|
19
|
+
get activeConversation(): ConversationEntity | null;
|
|
20
|
+
/**
|
|
21
|
+
* Gets filtered conversations based on search query
|
|
22
|
+
*/
|
|
23
|
+
get filteredConversations(): ConversationEntity[];
|
|
24
|
+
/**
|
|
25
|
+
* Gets pinned conversations
|
|
26
|
+
*/
|
|
27
|
+
get pinnedConversations(): ConversationEntity[];
|
|
28
|
+
/**
|
|
29
|
+
* Sets the active conversation
|
|
30
|
+
* @param id The conversation ID to activate (or null to clear)
|
|
31
|
+
*/
|
|
32
|
+
setActiveConversation(id: string | null): void;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the current active conversation ID
|
|
35
|
+
*/
|
|
36
|
+
getActiveConversationId(): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Adds a conversation to the list
|
|
39
|
+
* @param conversation The conversation to add
|
|
40
|
+
*/
|
|
41
|
+
addConversation(conversation: ConversationEntity): void;
|
|
42
|
+
/**
|
|
43
|
+
* Updates a conversation in the list by directly modifying the entity object
|
|
44
|
+
* Angular change detection will pick up the changes automatically
|
|
45
|
+
* @param id The conversation ID
|
|
46
|
+
* @param updates The fields to update
|
|
47
|
+
*/
|
|
48
|
+
updateConversationInPlace(id: string, updates: Partial<ConversationEntity>): void;
|
|
49
|
+
/**
|
|
50
|
+
* Removes a conversation from the list
|
|
51
|
+
* @param id The conversation ID to remove
|
|
52
|
+
*/
|
|
53
|
+
removeConversation(id: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Sets the search query
|
|
56
|
+
* @param query The search query string
|
|
57
|
+
*/
|
|
58
|
+
setSearchQuery(query: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Clears the search query
|
|
61
|
+
*/
|
|
62
|
+
clearSearchQuery(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Loads conversations from the database
|
|
65
|
+
* @param environmentId The environment ID to filter by
|
|
66
|
+
* @param currentUser The current user context
|
|
67
|
+
*/
|
|
68
|
+
loadConversations(environmentId: string, currentUser: UserInfo): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new conversation
|
|
71
|
+
* @param name The conversation name
|
|
72
|
+
* @param environmentId The environment ID
|
|
73
|
+
* @param currentUser The current user context
|
|
74
|
+
* @param description Optional description
|
|
75
|
+
* @param projectId Optional project ID
|
|
76
|
+
* @returns The created conversation entity
|
|
77
|
+
*/
|
|
78
|
+
createConversation(name: string, environmentId: string, currentUser: UserInfo, description?: string, projectId?: string): Promise<ConversationEntity>;
|
|
79
|
+
/**
|
|
80
|
+
* Deletes a conversation
|
|
81
|
+
* @param id The conversation ID
|
|
82
|
+
* @param currentUser The current user context
|
|
83
|
+
* @returns True if successful
|
|
84
|
+
*/
|
|
85
|
+
deleteConversation(id: string, currentUser: UserInfo): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Updates a conversation - saves to database AND updates in-place in the array
|
|
88
|
+
* @param id The conversation ID
|
|
89
|
+
* @param updates The fields to update
|
|
90
|
+
* @param currentUser The current user context
|
|
91
|
+
* @returns True if successful
|
|
92
|
+
*/
|
|
93
|
+
saveConversation(id: string, updates: Partial<ConversationEntity>, currentUser: UserInfo): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Toggles the pinned status of a conversation
|
|
96
|
+
* @param id The conversation ID
|
|
97
|
+
* @param currentUser The current user context
|
|
98
|
+
*/
|
|
99
|
+
togglePin(id: string, currentUser: UserInfo): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Archives a conversation
|
|
102
|
+
* @param id The conversation ID
|
|
103
|
+
* @param currentUser The current user context
|
|
104
|
+
*/
|
|
105
|
+
archiveConversation(id: string, currentUser: UserInfo): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Opens a thread panel for a specific message
|
|
108
|
+
* @param messageId The parent message ID
|
|
109
|
+
*/
|
|
110
|
+
openThread(messageId: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* Closes the currently open thread panel
|
|
113
|
+
*/
|
|
114
|
+
closeThread(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Gets the currently active thread ID
|
|
117
|
+
*/
|
|
118
|
+
getActiveThreadId(): string | null;
|
|
119
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ConversationStateService, never>;
|
|
120
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ConversationStateService>;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=conversation-state.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-state.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/conversation-state.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;;AAEnE;;;;GAIG;AACH,qBAGa,wBAAwB;IAE5B,aAAa,EAAE,kBAAkB,EAAE,CAAM;IACzC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC3C,WAAW,EAAE,MAAM,CAAM;IACzB,SAAS,EAAE,OAAO,CAAS;IAC3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