feat(copilot): surface console, snapshot, capture and marker tools per mode

The bridge made 49 project-scoped MCP tools available, but the mode
tables still mirrored the old copilot capability set. Expand them:

- lab_automation_assistant: node_console_exec (raw console for nodes
  without a device_type tag), node_list, snapshot_list/create/delete/
  restore
- teaching_assistant: node_list/node_get, link_list, link_marker
  (read-only diagnostics plus traffic-insight markers)
- troubleshooting_injection: link_capture_start/stop/download and
  marker_definition (inject -> capture -> verify loop)

Also fix the tools_by_name registry: it was built from the lab and
injection tables only, which worked while teaching was a strict subset
of lab. Teaching-only tools would have raised KeyError in tool_node
when the LLM called them; the registry now unions all three mode
tables. A new test pins each mode's exact toolset, checks that no
administration tool leaks in, and asserts every referenced name is
resolvable.
This commit is contained in:
YueGuobin committed 2026-11-03 22:57:09 +08:00
1 parent 6a4cbe39c1
commit e8462507a5
4 files changed
+180 -39

No files matched your search

@@ -101,21 +101,29 @@ sequenceDiagram
| Tool | teaching_assistant | lab_automation_assistant | troubleshooting_injection |
|---|---|---|---|
| `template_list` get templates | ✓ | ✓ | |
| `template_list` / `template_get` templates | ✓ | ✓ | |
| `node_create` create nodes | ✓ | ✓ | |
| `link_create` create links (native) | ✓ | ✓ | |
| `node_start` start nodes | ✓ | ✓ | |
| `node_list` / `node_get` inspect nodes | ✓ | ✓ | |
| `node_update` rename | ✓ | ✓ | |
| `node_stop` stop nodes | | ✓ | |
| `node_suspend` suspend nodes | | ✓ | |
| `node_start` start nodes | ✓ | ✓ | |
| `node_stop` / `node_suspend` stop/suspend | | ✓ | |
| `node_console_exec` raw console access | | ✓ | |
| `link_create` create links (native, port names) | ✓ | ✓ | |
| `link_list` inspect links | ✓ | | |
| `link_marker` traffic-insight markers | ✓ | | |
| `drawing_create_*` canvas annotations | ✓ | ✓ | |
| `device_show_run` read-only commands | ✓ | ✓ | ✓ |
| `device_config_send` config commands | | ✓ | ✓ |
| `vpcs_config_set` VPCS commands | | ✓ | |
| `device_skill_get` device skills | ✓ | ✓ | |
| `snapshot_list` / `snapshot_create` / `snapshot_delete` / `snapshot_restore` snapshots | | ✓ | |
| `link_update` / `link_available_filters` fault filters | | | ✓ |
| `link_capture_start` / `link_capture_stop` / `link_capture_download` capture | | | ✓ |
| `marker_definition` project-wide markers | | | ✓ |
| `injection_skill_get` fault injection skills | | | ✓ |
| `wait_seconds` boot wait (native) | ✓ | ✓ | |
| `packet_analysis` live packet analysis (native) | ✓ | ✓ | |
| `packet_analysis_skills` protocol knowledge (native) | ✓ | ✓ | |
| `device_skill_get` device skills | ✓ | ✓ | |
| `link_update` link filters | | | ✓ |
| `injection_skill_get` fault injection skills | | | ✓ |
| `gns3_topology_reader` topology info (native) | | | ✓ |
The mode is selected in the `llm_call` node via `copilot_mode`, which picks the corresponding tool list and binds it to the LLM model instance through `create_base_model_with_tools(mode_tools, llm_config)`.
@@ -618,43 +618,51 @@ Note: These special node types are filtered out by template_list and won't appea
### Teaching Assistant Mode
**Tools Available:**
- `template_list` - List available device templates 🆕
- `node_create` - Create nodes in topology 🆕
- `GNS3LinkTool` - Create links between nodes 🆕
- `node_update` - Rename nodes 🆕
- `template_list` / `template_get` - List and inspect device templates
- `node_create` - Create nodes in topology
- `node_list` / `node_get` - Inspect nodes (field projection keeps responses small)
- `node_update` - Rename nodes
- `node_start` - For diagnostics requiring started nodes
- `link_create` - Create links between nodes (native: port-name resolution)
- `link_list` - Inspect links
- `link_marker` - Traffic-insight markers (highlight matching packets)
- `drawing_create_*` - Canvas annotations (text, rectangle, ellipse)
- `device_show_run` - Execute show/display/debug commands (READ-ONLY)
- `PacketCaptureTool` - Analyze packets from active capture
- `DeviceSkillsTool` - Get device-specific skills and command knowledge
- `device_skill_get` - Get device-specific skills and command knowledge
- `wait_seconds` - Boot wait timer
- `packet_analysis` / `packet_analysis_skills` - Analyze packets and query protocol knowledge
**Capabilities:**
- READ-ONLY diagnostic tools
- Can create and manage topology (nodes, links, names)
- READ-ONLY device diagnostics
- Can create and manage topology (nodes, links, names, annotations)
- Traffic-insight markers for teaching scenarios
- Cannot stop or suspend nodes (prevents disruption of active labs)
- Cannot execute configuration commands
### Lab Automation Assistant Mode
**Tools Available:**
- `template_list` - List available device templates 🆕
- `node_create` - Create nodes in topology 🆕
- `GNS3LinkTool` - Create links between nodes 🆕
- `node_update` - Rename nodes 🆕
- `node_start` - Full lab deployment
- `node_stop` - Full lab shutdown
- `node_suspend` - Lab pause with state preservation
- `template_list` / `template_get` - List and inspect device templates
- `node_create` / `node_update` / `node_list` - Create, rename, inspect nodes
- `node_start` / `node_stop` / `node_suspend` - Full lifecycle control
- `node_console_exec` - Raw console access (works without a device_type tag)
- `link_create` - Create links between nodes (native: port-name resolution)
- `drawing_create_*` - Canvas annotations (text, rectangle, ellipse)
- `device_show_run` - Execute show/display/debug commands (READ-ONLY)
- `device_config_send` - Execute configuration commands
- `device_config_send` - Execute configuration commands (Jinja2 templates supported)
- `vpcs_config_set` - Execute VPCS commands using Netmiko
- `PacketCaptureTool` - Analyze packets from active capture
- `DeviceSkillsTool` - Get device-specific skills and command knowledge
- `device_skill_get` - Get device-specific skills and command knowledge
- `snapshot_list` / `snapshot_create` / `snapshot_delete` / `snapshot_restore` - Project snapshots
- `wait_seconds` - Boot wait timer
- `packet_analysis` / `packet_analysis_skills` - Analyze packets and query protocol knowledge
**Capabilities:**
- Full diagnostic and configuration tools
- Complete topology and lifecycle management (create, connect, start/stop/suspend)
- Device configuration via Nornir/Netmiko
- Device configuration via Nornir/Netmiko (Jinja2 template batch mode)
- Generic console access for Docker/Linux/VPCS nodes
- Automated workflows with state preservation
- Lab snapshot capabilities for later resumption
- Project snapshot save/restore
## Usage Examples