-
Notifications
You must be signed in to change notification settings - Fork 457
Feat/webui code genesis #847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9514bdc
feat: webui_code_gengesis
vinci-grape ee8ab3a
fix bug
vinci-grape f13c185
remove package.json
vinci-grape e5fa939
remove .npm-cache
vinci-grape 190fba7
remove package-lock.json
vinci-grape 84f0c49
webui beautification
vinci-grape eae9879
feat: implement ms-agent ui command to run webui
vinci-grape 4d4ebc4
fix bugs in webui
vinci-grape 6acdf41
fix bugs in webui
vinci-grape 6d4f6af
Fix post-build bugs
vinci-grape 1f458b5
Temporarily hide pending projects
vinci-grape 2045a25
Merge branch 'main' into feat/webui_code_genesis
vinci-grape 5adc836
fix bugs in webui_mcp
vinci-grape File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -408,6 +408,20 @@ async def _read_output(self): | |
| if self._waiting_for_input: | ||
| # Check if process is still alive | ||
| if self.process.returncode is None: | ||
| # Flush any pending chat response before waiting | ||
| if self._is_chat_mode: | ||
| self._flush_chat_response() | ||
| # Send waiting_input message to enable frontend input | ||
| if self.on_output and not self._waiting_input_sent: | ||
| self.on_output({ | ||
| 'type': 'waiting_input', | ||
| 'content': '', | ||
| 'role': 'system', | ||
| 'metadata': { | ||
| 'waiting': True | ||
| } | ||
| }) | ||
| self._waiting_input_sent = True | ||
|
Comment on lines
+411
to
+424
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| # Process is still alive, continue waiting | ||
| continue | ||
| else: | ||
|
|
@@ -440,6 +454,20 @@ async def _read_output(self): | |
| if self._waiting_for_input: | ||
| # Check if process is still alive | ||
| if self.process.returncode is None: | ||
| # Flush any pending chat response before waiting | ||
| if self._is_chat_mode: | ||
| self._flush_chat_response() | ||
| # Send waiting_input message to enable frontend input | ||
| if self.on_output and not self._waiting_input_sent: | ||
| self.on_output({ | ||
| 'type': 'waiting_input', | ||
| 'content': '', | ||
| 'role': 'system', | ||
| 'metadata': { | ||
| 'waiting': True | ||
| } | ||
| }) | ||
| self._waiting_input_sent = True | ||
| print( | ||
| '[Runner] Agent is waiting for user input, keeping process alive...' | ||
| ) | ||
|
|
@@ -609,35 +637,91 @@ def _clean_log_prefix(text: str) -> str: | |
| return text.strip() | ||
|
|
||
| async def _process_chat_line(self, line: str): | ||
| """Simple chat mode - send response and wait for next input""" | ||
| # Detect [assistant]: marker - next lines will be the response | ||
| """Simple chat mode - handle assistant output, tool calls, and tool results""" | ||
| cleaned = self._clean_log_prefix(line) | ||
|
|
||
| # Detect [tool_calling]: marker - flush assistant output and start collecting tool call | ||
| if '[tool_calling]:' in line: | ||
| self._flush_chat_response() | ||
| self._collecting_tool_call = True | ||
| self._tool_call_json_buffer = '' | ||
| return | ||
|
|
||
| # Collect tool call JSON | ||
| if self._collecting_tool_call: | ||
| if cleaned: | ||
| if self._tool_call_json_buffer: | ||
| self._tool_call_json_buffer += '\n' + cleaned | ||
| else: | ||
| self._tool_call_json_buffer = cleaned | ||
| # Check if we have a complete JSON object | ||
| if cleaned == '}' and self._tool_call_json_buffer.strip( | ||
| ).startswith('{'): | ||
| self._flush_tool_call() | ||
| return | ||
|
|
||
| # Detect tool execution result (success or error) | ||
| if 'execute tool call' in line: | ||
| if self.on_output: | ||
| is_error = 'error' in line.lower() | ||
| self.on_output({ | ||
| 'type': 'tool_result', | ||
| 'content': cleaned, | ||
| 'role': 'assistant', | ||
| 'metadata': { | ||
| 'is_error': is_error | ||
| } | ||
| }) | ||
| return | ||
|
|
||
| # Detect [assistant]: marker - start collecting | ||
| if '[assistant]:' in line: | ||
| self._flush_chat_response() | ||
| self._collecting_assistant_output = True | ||
| self._chat_response_buffer = '' | ||
| return | ||
|
|
||
| # If collecting, send content immediately as complete | ||
| # Detect end markers - flush assistant output | ||
| end_markers = ['[user]:'] | ||
| for marker in end_markers: | ||
| if marker in line: | ||
| self._flush_chat_response() | ||
| return | ||
|
|
||
| # If collecting assistant output, accumulate the content | ||
| if self._collecting_assistant_output: | ||
| cleaned = self._clean_log_prefix(line) | ||
| if cleaned: | ||
| if self._chat_response_buffer: | ||
| self._chat_response_buffer += '\n' + cleaned | ||
| else: | ||
| self._chat_response_buffer = cleaned | ||
| # Send immediately with done=true (non-streaming mode) | ||
| print( | ||
| f'[Runner] Chat response: {len(self._chat_response_buffer)} chars' | ||
| ) | ||
| if self.on_output: | ||
| self.on_output({ | ||
| 'type': 'stream', | ||
| 'content': self._chat_response_buffer, | ||
| 'role': 'assistant', | ||
| 'done': True | ||
| }) | ||
| # Mark as waiting for input - process is still running | ||
| self._waiting_for_input = True | ||
|
|
||
| def _flush_tool_call(self): | ||
| """Send tool call information to frontend""" | ||
| if self._is_chat_mode and self._tool_call_json_buffer.strip( | ||
| ) and self.on_output: | ||
| try: | ||
| import json | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| tool_data = json.loads(self._tool_call_json_buffer) | ||
| tool_name = tool_data.get('tool_name', 'unknown') | ||
| print(f'[Runner] Tool call: {tool_name}') | ||
| self.on_output({ | ||
| 'type': 'tool_call', | ||
| 'content': '', | ||
| 'role': 'assistant', | ||
| 'metadata': { | ||
| 'tool_name': tool_name, | ||
| 'arguments': tool_data.get('arguments', {}), | ||
| 'id': tool_data.get('id', '') | ||
| } | ||
| }) | ||
| except json.JSONDecodeError: | ||
| print('[Runner] Failed to parse tool call JSON') | ||
| self._tool_call_json_buffer = '' | ||
| self._collecting_tool_call = False | ||
|
|
||
| def _flush_chat_response(self): | ||
| """Send final chat response with done=True""" | ||
| if self._is_chat_mode and self._chat_response_buffer.strip( | ||
|
|
@@ -652,7 +736,8 @@ def _flush_chat_response(self): | |
| 'done': True | ||
| }) | ||
| self._chat_response_buffer = '' | ||
| self._collecting_assistant_output = False | ||
| # Don't reset _collecting_assistant_output here - more content may come | ||
| # It will be reset when we see [tool_calling]: or [user]: or process exits | ||
|
|
||
| async def _process_line(self, line: str): | ||
| """Process a line of output""" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,9 @@ | |
| class ProjectDiscovery: | ||
| """Discovers and manages projects from the ms-agent projects directory""" | ||
|
|
||
| # Whitelist of projects to show in the UI | ||
| VISIBLE_PROJECTS = {'code_genesis', 'singularity_cinema'} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| def __init__(self, projects_dir: str): | ||
| self.projects_dir = projects_dir | ||
| self._projects_cache: Optional[List[Dict[str, Any]]] = None | ||
|
|
@@ -28,7 +31,9 @@ def discover_projects(self, | |
|
|
||
| for item in os.listdir(self.projects_dir): | ||
| item_path = os.path.join(self.projects_dir, item) | ||
| if os.path.isdir(item_path) and not item.startswith('.'): | ||
| # Only show projects in the whitelist | ||
| if os.path.isdir(item_path) and not item.startswith( | ||
| '.') and item in self.VISIBLE_PROJECTS: | ||
| project_info = self._analyze_project(item, item_path) | ||
| if project_info: | ||
| projects.append(project_info) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for converting
temperatureandmax_tokensfrom strings is helpful. However, thisif/elifstructure can become cumbersome to maintain as more type-specific conversions are needed. Consider using a dictionary to map keys to their conversion functions for a more scalable and maintainable approach.