6452 Commits

Author SHA1 Message Date
YueGuobin
2dcdadf5fa docs: add mypy type checking issues todo document
Add comprehensive documentation for mypy static type checking
issues found in gns3_copilot module.

Document includes:
- 35 type errors across 9 files
- Detailed error descriptions and line numbers
- 3-phase fix strategy (High/Medium/Low priority)
- Mypy configuration recommendations
- Resource links for type hints and mypy

Related files:
- chat_sessions_repository.py (8 errors)
- context_manager.py (5 errors)
- agent_service.py (5 errors)
- gns3_topology_reader.py (2 errors)
- message_converters.py (1 error)
- connector_factory.py (1 error)

Co-Authored-By: Yue Guobin <yueguobin@outlook.com>
2026-03-10 01:20:42 +08:00
YueGuobin
71802a8064 style: remove unused List import from llm_model_configs.py
Remove unused typing.List import flagged by ruff F401.

Co-Authored-By: Yue Guobin <yueguobin@outlook.com>
2026-03-10 01:11:37 +08:00
YueGuobin
5e9ec23a45 style: remove unused imports and fix E712 comparisons in llm_model_configs.py
Remove 5 unused imports flagged by ruff F401:
- sqlalchemy.func, sqlalchemy.or_
- sqlalchemy.ext.asyncio.AsyncSession
- sqlalchemy.orm.selectinload
- json

Fix 4 E712 errors - avoid equality comparisons to True:
- Use models.LLMModelConfig.is_default instead of == True

Co-Authored-By: Yue Guobin <yueguobin@outlook.com>
2026-03-10 01:10:19 +08:00
YueGuobin
7d031a6802 style: remove unused imports and variables in project.py
Remove unused import and exception variable flagged by ruff:
- Remove unused 'sys' import (F401)
- Remove unused exception variable 'e' in except clause (F841)

Co-Authored-By: Yue Guobin <yueguobin@outlook.com>
2026-03-10 01:08:20 +08:00
YueGuobin
c0aec3f979 style: remove unused imports from llm_model_configs.py
Remove 3 unused imports that were flagged by ruff F401:
- fastapi.Response
- fastapi.security.OAuth2PasswordRequestForm
- gns3server.controller.controller_error.ControllerError

Co-Authored-By: Yue Guobin <yueguobin@outlook.com>
2026-03-10 01:07:23 +08:00
YueGuobin
7c3b832bca style: fix E501 line-too-long errors in gns3_copilot
Fix all 423 E501 line length violations across 26 files to comply with
   PEP 8 88-character line limit.

   Changes:
   - Split long f-strings across multiple lines
   - Break long docstring descriptions and parameter lists
   - Split markdown table rows and list examples
   - Break long URL construction f-strings
   - Split long logger messages and comments
   - Add noqa: E501 for SVG strings (cannot be split)

   Modified files:
   - agent/: context_manager.py, gns3_copilot.py, model_factory.py
   - gns3_client/: connector_factory.py, context_helpers.py, custom_gns3fy.py,
                   gns3_project_info.py, gns3_topology_reader.py
   - prompts/: __init__.py, lab_automation_assistant_prompt.py,
               prompt_loader.py, teaching_assistant_prompt.py
   - tools_v2/: __init__.py, config_tools_nornir.py, display_tools_nornir.py,
                gns3_create_link.py, gns3_create_node.py, gns3_get_node_temp.py,
                gns3_start_node.py, gns3_update_node_name.py,
                vpcs_tools_telnetlib3.py
   - utils/: __init__.py, command_filter.py, get_gns3_device_port.py,
             gns3_drawing_utils.py, llm_config_helper.py, message_converters.py,
             parse_tool_content.py, tool_call_stream.py

   All files now pass ruff E501 checks.

   Co-Authored-By: Yue Guobin <yueguobin@outlook.com>
2026-03-10 01:05:17 +08:00
Guobin Yue
25f2d1b56b
Merge branch '3.0' into feature/ai-copilot-bridge 2026-03-09 21:50:37 +08:00
YueGuobin
7c2083d227 feat: update .gitignore to track project context and development docs
- Add exception for .claude/development.md to allow tracking development documentation
- Comment out PROJECT_CONTEXT.md exclusion to enable version control of project context file
- Create PROJECT_CONTEXT.md with comprehensive project overview for AI assistant support
- Document project structure, AI copilot data flow, SSE event types, and code standards
- Provide flake8 static analysis guidelines and common error fixes
2026-03-09 21:46:58 +08:00
grossmj
69eafda777
Merge remote-tracking branch 'origin/2.2' into 3.0
# Conflicts:
#	gns3server/version.py
2026-03-09 17:12:24 +08:00
grossmj
b658f7ff68
Make sure the node shows as stopped when the wrap console cannot be stopped. Ref https://github.com/GNS3/gns3-registry/pull/1010 2026-03-09 17:10:00 +08:00
YueGuobin
b936a52f6f docs: add LangGraph Agent and tool output serialization documentation
Added new section in ai-chat-api-design.md explaining:

- LangGraph Agent architecture and main components
- tool_node function and tool output serialization mechanism
- Why serialization happens in tool_node (not agent_service)
- Tool output data flow diagram showing SSE and history paths
- Explanation of JSON format consistency across streaming and storage

This documentation clarifies the fix for single-quotes issue in
conversation history and helps future maintenance.

Co-Authored-By: YueGuobin <yueguobin@outlook.com>
2026-03-09 15:54:44 +08:00
YueGuobin
9b85417a82 fix(copilot): serialize tool output to JSON in ToolMessage for history
Fixed tool output serialization in tool_node function to ensure
ToolMessage.content is always in JSON format, not Python str() representation.

This fixes the issue where conversation history showed tool outputs
with single quotes (Python format) instead of standard JSON.

Changes:
- Added json import to gns3_copilot.py
- Modified tool_node() to serialize observation to JSON before creating ToolMessage
- Ensures both SSE streaming and history storage use consistent JSON format

Root cause: ToolMessage was created with raw dict/list objects, which
LangChain converted to Python str() representation when saving to history.

Co-Authored-By: YueGuobin <yueguobin@outlook.com>
2026-03-09 15:50:36 +08:00
YueGuobin
8babaccd80 feat: add PROJECT_CONTEXT.md to gitignore
Add PROJECT_CONTEXT.md to the .gitignore file to prevent it from being tracked in version control. This file likely contains project-specific context or configuration that should not be committed to the repository.
2026-03-09 15:34:31 +08:00
YueGuobin
0f2d0e2859 fix(copilot): serialize tool output to standard JSON format for frontend parsing
Changed tool output serialization in AgentService._convert_event_to_chunk()
from str() to json.dumps() to ensure structured data (dict/list) is properly
formatted as standard JSON instead of Python string representation.

Changes:
- Added json import to agent_service.py
- Modified on_tool_end event handling to use json.dumps(output, ensure_ascii=False, indent=2)
- Updated ai-chat-api-design.md to document tool_output format

Benefits:
- Frontend can parse tool results with standard JSON.parse()
- Chinese and non-ASCII characters are preserved (not escaped)
- Formatted output (indent=2) improves readability

Co-Authored-By: YueGuobin <yueguobin@outlook.com>
2026-03-09 15:15:50 +08:00
YueGuobin
13a032ea2c chore: update author name and copyright headers
Updated the author name and copyright statements across the
gns3_copilot module. The name has been standardized from
"Guobin Yue" to "Yue Guobin (岳国宾)" to reflect the correct
author attribution including Chinese characters.
2026-03-09 11:46:28 +08:00
Guobin Yue
d7e5fe065e
Merge branch '3.0' into feature/ai-copilot-bridge 2026-03-08 13:20:27 +08:00
YueGuobin
9ba02e9436 feat(docs): enhance AI chat API documentation with examples and details
- Improve POST /chat endpoint documentation with request/response examples
- Add session ID management flow explanation
- Enhance GET /sessions endpoint with query parameters and response example
- Update GET /sessions/{session_id}/history with detailed response structure
- Format parameters as tables for better readability
- Clarify session ID usage in streaming conversations
2026-03-08 02:27:48 +08:00
YueGuobin
fd34ef494f feat: add .claude directory to gitignore for API key security
Add .claude/ directory to .gitignore to prevent accidental
commit of Claude Code settings which may contain sensitive
API keys. This ensures development environment configuration
files with potential credentials are excluded from version
control.
2026-03-07 23:52:16 +08:00
grossmj
73ffb22aa2
Bundle web-ui v3.1.0.dev1 2026-03-07 17:47:44 +08:00
Jeremy Grossmann
f81ab0cfbe
Merge branch '3.0' into feature/ai-copilot-bridge 2026-03-07 13:00:39 +08:00
Jeremy Grossmann
0cedab1742
Merge pull request #2632 from GNS3/drop-python3.9
Drop support for Python 3.9
2026-03-07 11:19:03 +08:00
Guobin Yue
1cc48c1fb0
Merge branch '3.0' into feature/ai-copilot-bridge 2026-03-07 01:57:08 +08:00
YueGuobin
23b073a7bc docs: add troubleshooting guide for datetime timezone issue
Add comprehensive documentation for handling datetime timezone discrepancies between backend and frontend. The issue arises when backend returns naive datetime strings without timezone suffixes, causing JavaScript to parse them as local time instead of UTC. The guide includes problem description, root cause analysis, three frontend solutions (dayjs UTC parsing, manual 'Z' suffix addition, and global Axios interceptor), backend context, and testing checklist.
2026-03-07 01:42:18 +08:00
grossmj
679c690903
Drop support for Python 3.9 2026-03-06 19:03:53 +08:00
Jeremy Grossmann
5755a48fa3
Merge pull request #2630 from UmmmAGoodName/3.0
Fixed the path traversal check
2026-03-06 18:05:57 +08:00
YueGuobin
3a287de8c1 docs: add ACL Web UI implementation guide for frontend developers
Add comprehensive implementation guide for ACL management feature in GNS3 Web UI. The guide includes:

- Feature overview with core functionality and user flow
- Detailed API endpoint specifications for ACE CRUD operations
- Data structures and relationships
- Frontend implementation guide with component architecture
- UI/UX design recommendations and wireframes
- Common usage scenarios and error handling patterns
- Example code with React components and API service layer

This document serves as a reference for frontend developers implementing ACL management interface, covering everything from API integration to user interface design.
2026-03-06 14:19:19 +08:00
YueGuobin
8660e9c8db feat(docs): add RBAC + ACL implementation guide for GNS3 Server
Add comprehensive documentation for the two-tier permission control system combining RBAC and ACL features. The guide covers system overview, core concepts, data model, permission check flow, usage examples, best practices, and common issues. This documentation is applicable for GNS3 Server v3.0+ and provides implementation details for administrators managing user permissions.
2026-03-06 13:07:15 +08:00
YueGuobin
3d781236c6 delete depreacted dir 2026-03-06 11:08:35 +08:00
YueGuobin
0f61a06557 feat(docs): clarify API key visibility for group configurations
Add detailed section explaining that plaintext API keys for group configurations are never exposed through the application API, even to super admins. This clarifies the security design where group configs are intended for inheritance only, not manual viewing, while maintaining internal decryption for inheritance functionality.
2026-03-06 11:06:18 +08:00
YueGuobin
903e48aecc feat(docs): clarify API key visibility rules and encryption details
Update the LLM model configs API documentation to provide clearer explanations of API key visibility controls and encryption behavior. The changes include:

- Enhanced visibility table with more specific scenarios and encryption states
- Added detailed rules explaining when API keys are visible as plaintext, hidden (null), or shown encrypted
- Clarified super admin capabilities and database-level access
- Updated JSON examples to reflect actual encrypted values and null placeholders
- Added important notes about Fernet encryption, on-the-fly decryption, and group config behavior

These updates provide better transparency about security measures and help users understand what to expect when viewing different types of configurations.
2026-03-06 10:05:17 +08:00
YueGuobin
4941dc13d8 feat(api): enhance /me endpoint with groups, pools, and ACEs
Add comprehensive user context to the `/me` endpoint by including group memberships, accessible resource pools, and access control entries (ACEs). This enables users to view inherited configurations, available resources, and their permissions directly from the API.

Key additions:
- Group membership details with inherited configs
- Resource pool access information
- ACE visibility for permission transparency
- Support for user-selectable group default configurations

The enhancement addresses user needs for better visibility into permissions and accessible resources within the system.
2026-03-06 09:50:34 +08:00
YueGuobin
eb7a72f5e2 feat(docs): update copilot_mode value in LLM model configs API example
Changed the example value of `copilot_mode` from "lab_assistant" to "lab_automation_assistant" in the API documentation to reflect the correct mode name used in the system.
2026-03-06 02:00:02 +08:00
YueGuobin
77ef87f468 feat(prompts): rename prompt modules for clarity and consistency
Rename base_prompt.py to teaching_assistant_prompt.py and lab_assistant_prompt.py to lab_automation_assistant_prompt.py to better reflect their purposes. Update all imports and references accordingly to maintain consistency across the codebase. This improves code readability and aligns naming with the actual functionality of each prompt module.
2026-03-06 01:58:54 +08:00
YueGuobin
dd3b06bd75 feat(docs): remove reference tool command from model configs API documentation
The `python scripts/show_model_context_limits.py` command was removed from the documentation as it is no longer necessary or relevant for users configuring model context limits. The remaining content still provides clear guidance on calculating context limits in K tokens.
2026-03-06 01:55:46 +08:00
Guobin Yue
87f8f22524
Merge branch '3.0' into feature/ai-copilot-bridge 2026-03-06 01:42:47 +08:00
YueGuobin
216b3d7219 docs: translate AI chat API design document to English
Translate the GNS3 Copilot Agent Chat API design document from Chinese to English to improve accessibility for international contributors and align with project documentation standards. The translation covers all sections including overview, core features, architecture design, API endpoints, and response formats.
2026-03-06 01:14:52 +08:00
YueGuobin
8fa6d6810a feat: add multi-user concurrency control design document
Add comprehensive design document outlining the race condition issue when multiple users simultaneously operate on the same network device via GNS3-Copilot Agent. The document details the problem statement, affected components, and proposes two solutions: device-level mutex lock (recommended) and connection pooling with session isolation. It includes implementation details, API changes, and UI considerations to ensure safe concurrent operations.
2026-03-06 01:08:45 +08:00
YueGuobin
af6d87426b feat(agent): add runtime control parameters for agent behavior
Add support for runtime control parameters `max_iterations` and `max_tool_calls` in the chat API to allow users to dynamically adjust agent behavior per request. This addresses current limitations where iteration limits and tool call constraints are hardcoded, providing flexibility for complex tasks and cost control.
2026-03-06 00:54:33 +08:00
YueGuobin
c317932f1a feat(security): add forbidden command filtering for device configurations
- Import filter_forbidden_commands utility from command_filter module
- Add _filter_forbidden_commands_from_device_configs method to filter out restricted commands before execution
- Store blocked commands information and log filtered commands for audit purposes
- Update _process_task_results to include blocked commands info in response
- Prevent execution of potentially dangerous commands while maintaining transparency about filtered content
2026-03-06 00:30:17 +08:00
YueGuobin
f1b496df49 docs: add troubleshooting guide for force kill residual processes
Add comprehensive documentation for troubleshooting issues caused by using `kill -9` on gns3server processes. The guide explains the root cause where SIGKILL prevents proper cleanup of child processes like dynamips and vpcs, leading to port conflicts and resource allocation errors when restarting. It provides multiple solutions including manual process cleanup, proper shutdown procedures, and preventive measures with example scripts. This documentation helps users resolve common issues with Dynamips VM creation failures, undefined project_id errors, and TCP port warnings.
2026-03-05 23:39:59 +08:00
UmmmAGoodName
6ff4d46838 Fixed the path traversal check 2026-03-05 16:38:55 +01:00
YueGuobin
aaba2d6181 docs: update node name from generate_title to title_generator_node
Updated references to the title generation node in both documentation and code:
- Changed node name from `generate_title` to `title_generator_node` in API design documentation
- Updated filtering logic in agent service to exclude `title_generator_node` from LLM call statistics, token counting, and frontend streaming events
- Maintains same functionality while using more descriptive node name for clarity
2026-03-05 23:19:20 +08:00
YueGuobin
a7bc68d6e1 feat(docs): reorganize documentation and add orphan tool calls recovery plan
- Move command-security.md and hitl-implementation-plan.md to todo/ directory
- Add new documentation for orphan tool calls recovery with detailed problem analysis and implementation plan
- Document scenarios causing orphan tool calls and propose fix strategy using LangGraph API
2026-03-05 23:07:02 +08:00
YueGuobin
b8cb0bdcb0 feat(agent): exclude generate_title node from LLM call and token statistics
Filter out internal LangGraph 'generate_title' node from LLM call counting and token usage tracking to avoid inflating statistics with internal operations. This ensures metrics only reflect user-facing AI interactions.
2026-03-05 23:01:41 +08:00
YueGuobin
511b155da8 feat(ai-chat-api): implement streaming tool calls with incremental parameter accumulation
- Update API documentation to reflect new streaming tool call mechanism
- Add `message_id` optional field to content and tool_call events
- Change tool_call structure from array to single object with incremental updates
- Add `tool_call_id` to tool_start events for better event correlation
- Implement ToolCallStreamAccumulator class to handle parameter accumulation
- Provide frontend example code for handling streaming tool calls
- Maintain backward compatibility with existing session_id tracking
2026-03-05 22:29:01 +08:00
YueGuobin
1de7d00db3 feat(agent): update SSE event schema and handle tool calls from LLM
- Update AI chat API documentation with revised SSE event schema
- Add support for multiple tool calls in `tool_call` events
- Include `session_id` in all event types for better session tracking
- Implement `on_chat_model_end` handler to process LLM tool call decisions
- Update example JSON payloads to reflect new schema structure
2026-03-05 22:03:27 +08:00
YueGuobin
54775faaf4 feat(copilot): rename copilot modes for clarity and add mode-specific tools
- Rename "teaching" mode to "teaching_assistant" for better clarity
- Rename "lab_assistant" mode to "lab_automation_assistant" to reflect expanded capabilities
- Implement mode-specific tool sets: teaching_assistant gets read-only diagnostic tools only, while lab_automation_assistant gets full diagnostic and configuration tools
- Update API documentation examples to reflect new mode names
- Maintain backward compatibility with default tool set initialization
2026-03-05 21:44:36 +08:00
YueGuobin
28f2fe03e6 feat: suppress nornir INFO logs to reduce console verbosity
Set logging level for nornir.core and nornir loggers to WARNING in config_tools_nornir.py and display_tools_nornir.py. This prevents nornir from logging task execution at INFO level to the console, as the logging={"enabled": False} parameter in InitNornir only disables plugin internal logs.
2026-03-05 21:04:46 +08:00
YueGuobin
2485bfec46 docs: add temperature parameter documentation and code formatting improvements
- Added `temperature` parameter to Chat API documentation with implementation notes
- Improved code formatting in context_manager.py with consistent string quotes and line breaks
- Added section on future runtime LLM parameter override capabilities
- Updated API schemas to include temperature parameter (currently unused but reserved for future implementation)
2026-03-05 20:58:14 +08:00
YueGuobin
7f8364fbf5 refactor: move context helpers to separate module for better organization
- Extract context variable management functions from connector_factory.py to new context_helpers.py module
- Update imports in gns3_copilot.py, agent_service.py, and __init__.py to use new module
- Remove inline imports and ensure consistent access to context helpers
- Improves code organization and maintainability by separating concerns
2026-03-05 20:40:16 +08:00