# huangyjie/remotex architecture

> Architecture diagram of the GitHub repository huangyjie/remotex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/huangyjie/remotex
- Repository: https://github.com/huangyjie/remotex

## Overview

RemoteX is a Windows desktop server-operations client combining direct terminal and FTP workflows with an AI agent. The primary agent workflow selects a server and conversation, sends a natural-language goal through an iterative model/tool loop, checks permissions before remote actions, and persists results for later review. The README also documents model setup, Skills, long-context handling, and remote text editing. The tree and sampled excerpts support the main orchestration and selected interactions; unsampled areas are represented only where documented, with uncertain wiring omitted.

Main entry points: [`Services/AgentEngine.cs`](https://github.com/huangyjie/remotex/blob/main/Services/AgentEngine.cs) (Agent loop), [`MainWindow.xaml.cs`](https://github.com/huangyjie/remotex/blob/main/MainWindow.xaml.cs) (Main window), [`Services/AiChatService.cs`](https://github.com/huangyjie/remotex/blob/main/Services/AiChatService.cs) (AI chat API), [`Views/AgentWorkspaceWindow.xaml.cs`](https://github.com/huangyjie/remotex/blob/main/Views/AgentWorkspaceWindow.xaml.cs) (Agent workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop workspace"]
  node_main["Main window<br/>[MainWindow.xaml.cs]"]
  node_agentui["Agent workspace"]
  node_editor["Remote editor"]
  node_app["App lifecycle<br/>[App.xaml.cs]"]
  node_approval["Approval dialogs"]
  node_user_choice["User choices"]
  node_agent_settings["Agent settings UI"]
end

subgraph group_remote["Remote access"]
  node_remote_session["SSH / Telnet<br/>[RemoteSession.cs]"]
  node_ftp_session["FTP / FTPS<br/>[FtpSession.cs]"]
  node_textfiles["Remote text files"]
end

subgraph group_agent["AI operations"]
  node_agent_engine["Agent loop<br/>[AgentEngine.cs]"]
  node_ai_chat["AI chat API<br/>[AiChatService.cs]"]
  node_tool_catalog["Tool catalog"]
  node_tool_exec["Tool executor"]
  node_permission["Permission checks"]
  node_skills["Skills registry<br/>[SkillRegistry.cs]"]
  node_skill_policy["Skill policy"]
  node_context_window["Context selection"]
  node_compression["Context compression"]
end

subgraph group_state["Settings and state"]
  node_profiles["Server profiles"]
  node_credentials["Windows credentials"]
  node_quickcmd["Quick commands"]
  node_conversation_store[("Conversation store")]
  node_history_store[("Agent history")]
  node_ai_settings["AI settings<br/>[AiSettingsStore.cs]"]
end

node_operator(("Operator"))
node_model_service["Model provider"]
node_terminal_peer["SSH / Telnet servers"]
node_ftp_peer["FTP servers"]

node_operator -->|"uses"| node_main
node_app -->|"opens"| node_main
node_main -->|"loads / saves"| node_profiles
node_main -->|"stores passwords"| node_credentials
node_main -->|"loads / saves"| node_quickcmd
node_main -->|"opens terminal"| node_remote_session
node_remote_session -->|"connects"| node_terminal_peer
node_main -->|"opens file transfer"| node_ftp_session
node_ftp_session -->|"connects"| node_ftp_peer
node_main -->|"opens editor"| node_editor
node_main -->|"reads / writes"| node_textfiles
node_textfiles -->|"transfers files"| node_ftp_session
node_operator -->|"sets goal"| node_agentui
node_agentui -->|"runs task"| node_agent_engine
node_agentui -->|"loads / manages"| node_conversation_store
node_agent_engine -->|"loads / persists"| node_conversation_store
node_agent_engine -->|"records history"| node_history_store
node_agent_engine -->|"selects context"| node_context_window
node_agent_engine -->|"compresses history"| node_compression
node_agent_engine -->|"builds prompt"| node_skills
node_skills -->|"checks enablement"| node_skill_policy
node_agent_engine -->|"requests model turn"| node_ai_chat
node_ai_chat -->|"sends chat request"| node_model_service
node_model_service -->|"streams response"| node_ai_chat
node_ai_chat -->|"returns tool calls"| node_agent_engine
node_agent_engine -->|"uses tool definitions"| node_tool_catalog
node_agent_engine -->|"authorizes call"| node_permission
node_permission -->|"requests approval"| node_approval
node_approval -->|"asks permission"| node_operator
node_approval -->|"returns decision"| node_permission
node_agent_engine -->|"presents options"| node_user_choice
node_user_choice -->|"asks choice"| node_operator
node_agent_engine -->|"executes approved call"| node_tool_exec
node_tool_exec -->|"runs remote actions"| node_remote_session
node_operator -->|"configures agent"| node_agent_settings
node_agent_settings -->|"loads / saves models"| node_ai_settings
node_ai_settings -->|"supplies configuration"| node_ai_chat

click node_main "https://github.com/huangyjie/remotex/blob/main/MainWindow.xaml.cs"
click node_agentui "https://github.com/huangyjie/remotex/blob/main/Views/AgentWorkspaceWindow.xaml.cs"
click node_editor "https://github.com/huangyjie/remotex/blob/main/Views/RemoteFileEditorDialog.xaml.cs"
click node_app "https://github.com/huangyjie/remotex/blob/main/App.xaml.cs"
click node_profiles "https://github.com/huangyjie/remotex/blob/main/Services/ServerProfileStore.cs"
click node_credentials "https://github.com/huangyjie/remotex/blob/main/Services/WindowsUserVerificationService.cs"
click node_quickcmd "https://github.com/huangyjie/remotex/blob/main/Services/QuickCommandStore.cs"
click node_remote_session "https://github.com/huangyjie/remotex/blob/main/Services/RemoteSession.cs"
click node_ftp_session "https://github.com/huangyjie/remotex/blob/main/Services/FtpSession.cs"
click node_textfiles "https://github.com/huangyjie/remotex/blob/main/Services/RemoteTextFileService.cs"
click node_agent_engine "https://github.com/huangyjie/remotex/blob/main/Services/AgentEngine.cs"
click node_ai_chat "https://github.com/huangyjie/remotex/blob/main/Services/AiChatService.cs"
click node_tool_catalog "https://github.com/huangyjie/remotex/blob/main/Services/AgentToolCatalog.cs"
click node_tool_exec "https://github.com/huangyjie/remotex/blob/main/Services/AgentToolExecutor.cs"
click node_permission "https://github.com/huangyjie/remotex/blob/main/Services/AgentPermissionService.cs"
click node_approval "https://github.com/huangyjie/remotex/blob/main/Views/AgentApprovalDialog.xaml.cs"
click node_user_choice "https://github.com/huangyjie/remotex/blob/main/Views/AgentUserChoiceDialog.xaml.cs"
click node_skills "https://github.com/huangyjie/remotex/blob/main/Services/SkillRegistry.cs"
click node_skill_policy "https://github.com/huangyjie/remotex/blob/main/Services/SkillPolicyService.cs"
click node_context_window "https://github.com/huangyjie/remotex/blob/main/Services/AgentContextWindowService.cs"
click node_compression "https://github.com/huangyjie/remotex/blob/main/Services/AgentContextCompressionService.cs"
click node_conversation_store "https://github.com/huangyjie/remotex/blob/main/Services/AgentConversationStore.cs"
click node_history_store "https://github.com/huangyjie/remotex/blob/main/Services/AgentHistoryStore.cs"
click node_ai_settings "https://github.com/huangyjie/remotex/blob/main/Services/AiSettingsStore.cs"
click node_agent_settings "https://github.com/huangyjie/remotex/blob/main/Views/AgentSettingsWindow.xaml.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_agentui,node_editor,node_app,node_approval,node_user_choice,node_agent_settings toneBlue
class node_remote_session,node_ftp_session,node_textfiles toneAmber
class node_agent_engine,node_ai_chat,node_tool_catalog,node_tool_exec,node_permission,node_skills,node_skill_policy,node_context_window,node_compression,node_terminal_peer,node_ftp_peer toneMint
class node_profiles,node_credentials,node_quickcmd,node_conversation_store,node_history_store,node_ai_settings toneRose
class node_operator,node_model_service toneIndigo
```

## Components

### Desktop workspace

- [Main window](https://github.com/huangyjie/remotex/blob/main/MainWindow.xaml.cs): `MainWindow.xaml.cs`
- [Agent workspace](https://github.com/huangyjie/remotex/blob/main/Views/AgentWorkspaceWindow.xaml.cs): `Views/AgentWorkspaceWindow.xaml.cs`
- [Remote editor](https://github.com/huangyjie/remotex/blob/main/Views/RemoteFileEditorDialog.xaml.cs): `Views/RemoteFileEditorDialog.xaml.cs`
- [App lifecycle](https://github.com/huangyjie/remotex/blob/main/App.xaml.cs): `App.xaml.cs`
- [Approval dialogs](https://github.com/huangyjie/remotex/blob/main/Views/AgentApprovalDialog.xaml.cs): `Views/AgentApprovalDialog.xaml.cs`
- [User choices](https://github.com/huangyjie/remotex/blob/main/Views/AgentUserChoiceDialog.xaml.cs): `Views/AgentUserChoiceDialog.xaml.cs`
- [Agent settings UI](https://github.com/huangyjie/remotex/blob/main/Views/AgentSettingsWindow.xaml.cs): `Views/AgentSettingsWindow.xaml.cs`

### Remote access

- [SSH / Telnet](https://github.com/huangyjie/remotex/blob/main/Services/RemoteSession.cs): `Services/RemoteSession.cs`
- [FTP / FTPS](https://github.com/huangyjie/remotex/blob/main/Services/FtpSession.cs): `Services/FtpSession.cs`
- [Remote text files](https://github.com/huangyjie/remotex/blob/main/Services/RemoteTextFileService.cs): `Services/RemoteTextFileService.cs`

### AI operations

- [Agent loop](https://github.com/huangyjie/remotex/blob/main/Services/AgentEngine.cs): `Services/AgentEngine.cs`
- [AI chat API](https://github.com/huangyjie/remotex/blob/main/Services/AiChatService.cs): `Services/AiChatService.cs`
- [Tool catalog](https://github.com/huangyjie/remotex/blob/main/Services/AgentToolCatalog.cs): `Services/AgentToolCatalog.cs`
- [Tool executor](https://github.com/huangyjie/remotex/blob/main/Services/AgentToolExecutor.cs): `Services/AgentToolExecutor.cs`
- [Permission checks](https://github.com/huangyjie/remotex/blob/main/Services/AgentPermissionService.cs): `Services/AgentPermissionService.cs`
- [Skills registry](https://github.com/huangyjie/remotex/blob/main/Services/SkillRegistry.cs): `Services/SkillRegistry.cs`
- [Skill policy](https://github.com/huangyjie/remotex/blob/main/Services/SkillPolicyService.cs): `Services/SkillPolicyService.cs`
- [Context selection](https://github.com/huangyjie/remotex/blob/main/Services/AgentContextWindowService.cs): `Services/AgentContextWindowService.cs`
- [Context compression](https://github.com/huangyjie/remotex/blob/main/Services/AgentContextCompressionService.cs): `Services/AgentContextCompressionService.cs`

### Settings and state

- [Server profiles](https://github.com/huangyjie/remotex/blob/main/Services/ServerProfileStore.cs): `Services/ServerProfileStore.cs`
- [Windows credentials](https://github.com/huangyjie/remotex/blob/main/Services/WindowsUserVerificationService.cs): `Services/WindowsUserVerificationService.cs`
- [Quick commands](https://github.com/huangyjie/remotex/blob/main/Services/QuickCommandStore.cs): `Services/QuickCommandStore.cs`
- [Conversation store](https://github.com/huangyjie/remotex/blob/main/Services/AgentConversationStore.cs): `Services/AgentConversationStore.cs`
- [Agent history](https://github.com/huangyjie/remotex/blob/main/Services/AgentHistoryStore.cs): `Services/AgentHistoryStore.cs`
- [AI settings](https://github.com/huangyjie/remotex/blob/main/Services/AiSettingsStore.cs): `Services/AiSettingsStore.cs`

### Other components

- **Operator**
- **Model provider**
- **SSH / Telnet servers**
- **FTP servers**

## Connections

- Operator → Main window: uses
- App lifecycle → Main window: opens
- Main window → Server profiles: loads / saves
- Main window → Windows credentials: stores passwords
- Main window → Quick commands: loads / saves
- Main window → SSH / Telnet: opens terminal
- SSH / Telnet → SSH / Telnet servers: connects
- Main window → FTP / FTPS: opens file transfer
- FTP / FTPS → FTP servers: connects
- Main window → Remote editor: opens editor
- Main window → Remote text files: reads / writes
- Remote text files → FTP / FTPS: transfers files
- Operator → Agent workspace: sets goal
- Agent workspace → Agent loop: runs task
- Agent workspace → Conversation store: loads / manages
- Agent loop → Conversation store: loads / persists
- Agent loop → Agent history: records history
- Agent loop → Context selection: selects context
- Agent loop → Context compression: compresses history
- Agent loop → Skills registry: builds prompt
- Skills registry → Skill policy: checks enablement
- Agent loop → AI chat API: requests model turn
- AI chat API → Model provider: sends chat request
- Model provider → AI chat API: streams response
- AI chat API → Agent loop: returns tool calls
- Agent loop → Tool catalog: uses tool definitions
- Agent loop → Permission checks: authorizes call
- Permission checks → Approval dialogs: requests approval
- Approval dialogs → Operator: asks permission
- Approval dialogs → Permission checks: returns decision
- Agent loop → User choices: presents options
- User choices → Operator: asks choice
- Agent loop → Tool executor: executes approved call
- Tool executor → SSH / Telnet: runs remote actions
- Operator → Agent settings UI: configures agent
- Agent settings UI → AI settings: loads / saves models
- AI settings → AI chat API: supplies configuration
