1+ """
2+ Brief inspector for knowledge transfer status and brief information.
3+ """
4+
5+ from typing import Any , List
6+
7+ from semantic_workbench_assistant .assistant_app import (
8+ AssistantConversationInspectorStateDataModel ,
9+ ConversationContext ,
10+ )
11+
12+ from ..common import detect_assistant_role
13+ from ..conversation_share_link import ConversationKnowledgePackageManager
14+ from ..manager import KnowledgeTransferManager
15+ from ..storage_models import ConversationRole
16+
17+
18+ # Default instructional text to show when no brief has been created
19+ DEFAULT_BRIEF_INSTRUCTION = "_This knowledge brief is displayed in the side panel of all of your team members' conversations, too. Before you share links to your team, ask your assistant to update the brief with whatever details you'd like here. What will help your teammates get off to a good start as they explore the knowledge you are sharing?_"
20+
21+ class BriefInspector :
22+ """
23+ Inspector for knowledge transfer status and brief information.
24+
25+ Shows role, stage, status message, and knowledge brief content.
26+ """
27+
28+ display_name = "📋 Brief"
29+ description = "Knowledge share overview"
30+ state_id = "brief"
31+
32+ def __init__ (self , config_provider ) -> None :
33+ self .config_provider = config_provider
34+
35+ async def is_enabled (self , context : ConversationContext ) -> bool :
36+ return True
37+
38+ async def get (self , context : ConversationContext ) -> AssistantConversationInspectorStateDataModel :
39+ """Get brief and status information for display."""
40+
41+ conversation_role = await detect_assistant_role (context )
42+
43+ # Get share information
44+ share_id = await ConversationKnowledgePackageManager .get_associated_share_id (context )
45+ if not share_id :
46+ return AssistantConversationInspectorStateDataModel (
47+ data = {"content" : "No active knowledge package. Start a conversation to create one." }
48+ )
49+
50+ brief = await KnowledgeTransferManager .get_knowledge_brief (context )
51+ share_info = await KnowledgeTransferManager .get_share_info (context )
52+
53+ if conversation_role == ConversationRole .COORDINATOR :
54+ markdown = await self ._format_coordinator_brief (share_id , brief , share_info , context )
55+ else :
56+ markdown = await self ._format_team_brief (share_id , brief , share_info , context )
57+
58+ return AssistantConversationInspectorStateDataModel (data = {"content" : markdown })
59+
60+ async def _format_coordinator_brief (self , share_id : str , brief : Any , share_info : Any , context : ConversationContext ) -> str :
61+ """Format brief information for coordinator."""
62+
63+ lines : List [str ] = []
64+
65+ lines .append ("**Role:** Coordinator" )
66+
67+ # Display knowledge transfer stage
68+ stage_label = "📋 Organizing Knowledge"
69+ if share_info :
70+ stage_label = share_info .get_stage_label (for_coordinator = True )
71+ lines .append (f"**Stage:** { stage_label } " )
72+
73+ if share_info and share_info .transfer_notes :
74+ lines .append (f"**Status Message:** { share_info .transfer_notes } " )
75+
76+ lines .append ("" )
77+
78+ # Knowledge Brief section
79+
80+ if brief :
81+ title = brief .title
82+ lines .append (f"## { title } " )
83+ lines .append ("" )
84+
85+ if brief .content :
86+ lines .append (brief .content )
87+ lines .append ("" )
88+ else :
89+ lines .append ("## Knowledge Brief" )
90+ lines .append ("" )
91+ lines .append (DEFAULT_BRIEF_INSTRUCTION )
92+ lines .append ("" )
93+
94+
95+ return "\n " .join (lines )
96+
97+ async def _format_team_brief (self , share_id : str , brief : Any , share_info : Any , context : ConversationContext ) -> str :
98+ """Format brief information for team members."""
99+
100+ lines : List [str ] = []
101+
102+ lines .append ("**Role:** Team" )
103+
104+ # Display knowledge transfer stage for team members
105+ stage_label = "📚 Learning Mode"
106+ if share_info :
107+ stage_label = share_info .get_stage_label (for_coordinator = False )
108+ lines .append (f"**Stage:** { stage_label } " )
109+
110+ # Add status message if available
111+ if share_info and share_info .transfer_notes :
112+ lines .append (f"**Status Message:** { share_info .transfer_notes } " )
113+
114+ lines .append ("" )
115+
116+ # Knowledge Brief section
117+ if brief :
118+ title = brief .title
119+ lines .append (f"## { title } " )
120+ lines .append ("" )
121+
122+ if brief .content :
123+ lines .append (brief .content )
124+ lines .append ("" )
125+ else :
126+ lines .append ("## Knowledge Brief" )
127+ lines .append ("" )
128+ lines .append ("_The coordinator is still setting up the knowledge brief. Check back soon!_" )
129+ lines .append ("" )
130+
131+ return "\n " .join (lines )
0 commit comments