# aliyun/aliyun_assist_client architecture

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

- Interactive diagram: https://gitdiagram.com/aliyun/aliyun_assist_client
- Repository: https://github.com/aliyun/aliyun_assist_client

## Overview

1. This repository is a Go-based remote execution agent platform for Alibaba Cloud “Aliyun Assist.” Its purpose is to run commands and scripts on instances, collect host data, and report results back to a control plane.

2. The codebase is split into a few major binaries/domains:
   - the main agent/runtime in `agent/`
   - control/IPC layers in `interprocess/` and `commander/`
   - shared platform utilities in `common/`
   - plugin executables in `plugin/`
   - supporting CLI/tools in top-level commands like `main.go`, `update/`, `configurecmd.go`, and `dataencryptioncmd.go`

3. The core execution path is the task engine under `agent/taskengine/`. It receives task definitions, builds session context, dispatches work to command or shell processors, captures output, and writes results to buffers/files for later upload or reporting. This is the central “command execution” subsystem.

4. Session and transport management are separated from task execution. `agent/session/` contains session state, shell handling, retry logic, message formats, and transport channels; `agent/channel/` and `agent/websocket/` provide the actual communication mechanisms. This is the boundary between “running a task” and “talking to the server.”

5. There is a strong plugin architecture. `agent/pluginmanager/` manages local and remote plugins, while `agent/pluginmodel/` defines plugin metadata and descriptors. The `plugin/commander/container` tree is a separate plugin executable focused on container command execution across Docker and CRI runtimes.

6. Host identity and environment detection are handled by `agent/hybrid/`, `agent/checkvirt/`, `agent/checkospanic/`, `agent/checknet/`, and related packages. These determine machine ID, instance identity, virtualization state, OS health, and network conditions so the agent can report the correct runtime context and adapt behavior per platform.

7. Inventory and telemetry are another major subsystem. `agent/inventory/` gathers instance, network, service, registry, file, role, and Windows Update data; `agent/clientreport/`, `agent/heartbeat/`, `agent/metrics/`, and `agent/perfmon/` package and publish status, health, command, and performance reports. This is the “observe and report” side of the agent.

8. Configuration, desired state, and scheduled work are handled separately from ad hoc commands. `agent/statemanager/` maintains resource state and schedules, while `agent/update/` handles timed update routines and state transitions. The `common/update/` package provides update API/reporting/verification logic shared across binaries.

9. Local IPC is explicit and layered. `interprocess/commander`, `interprocess/configure`, and `interprocess/cryptdata` expose gRPC-style client/server endpoints for local coordination between CLI tools, the agent, and helper processes. `interprocess/httpserver/` and `interprocess/messagebus/` provide additional local HTTP/JSON-RPC and message-bus channels.

10. Command-line and service lifecycle support are first-class. The root command files and `agent/install/`, plus the vendored `thirdparty/service`, show that the agent is intended to run as a long-lived OS service on Windows/Linux/FreeBSD, with installer/start/stop integration and cross-platform behavior through OS-specific files.

11. Security and payload handling are addressed in dedicated utility packages. `agent/cryptdata/` and `common/update/verify_*` handle encrypted parameters and package verification, while `common/requester/`, `common/httpbase/`, and `common/apiserver/` centralize HTTP access to cloud APIs, metadata services, and regional endpoints.

12. The repository is heavily cross-platform. Many packages have `*_windows.go`, `*_linux.go`, `*_freebsd.go`, and `*_unix.go` variants, indicating that the architecture is designed around OS-adaptive subsystems rather than a single runtime target.

13. External dependencies are mostly embedded or vendored under `thirdparty/`, including logging, JSON handling, cron parsing, single-instance locking, and service wrappers. Architecturally, these support local agent execution rather than introducing separate runtime services.

14. For a diagram, the most important boundaries are:
   - cloud/control plane vs. local agent
   - task/session execution vs. transport/reporting
   - core agent vs. plugins
   - state/inventory collection vs. ad hoc command execution
   - platform-neutral logic vs. OS-specific adapters

Main entry points: [`agent/taskengine`](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/taskengine) (Task Engine), [`main.go`](https://github.com/aliyun/aliyun_assist_client/blob/release/main.go) (Main CLI), [`agent/session`](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/session) (Session Runtime), [`common`](https://github.com/aliyun/aliyun_assist_client/tree/release/common) (Cloud Common)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control_plane["Control Plane"]
  node_inventory_reporting["Inventory & Reporting<br/>telemetry"]
end

subgraph group_agent_core["Agent Core"]
  node_task_engine["Task Engine<br/>command execution"]
  node_task_processors["Processors<br/>task dispatch"]
  node_task_output["Task Output<br/>output capture"]
  node_session_runtime["Session Runtime<br/>session state"]
  node_session_transport["Session Transport<br/>transport channels"]
  node_plugin_manager["Plugin Manager<br/>plugin orchestration"]
  node_plugin_model["Plugin Model<br/>plugin metadata"]
  node_identity_health["Identity & Health<br/>host detection"]
  node_state_update["State & Update<br/>desired state"]
end

subgraph group_local_integration["Local Integration"]
  node_main_entry["Main CLI<br/>agent entrypoints<br/>[main.go]"]
  node_service_lifecycle["Service Setup<br/>service/install"]
  node_ipc_commander["Commander IPC<br/>local gRPC"]
  node_ipc_configure["Configure IPC<br/>local gRPC"]
  node_ipc_cryptdata["Cryptdata IPC<br/>local gRPC"]
  node_ipc_httpbus["Local HTTP/Bus<br/>local transport"]
end

subgraph group_shared["Shared Libraries"]
  node_cloud_common["Cloud Common<br/>api/utilities"]
  node_platform_utils["Platform Utils<br/>cross-platform"]
end

subgraph group_plugins["Plugins"]
  node_container_plugin["Container Plugin<br/>plugin executable"]
end

node_main_entry -->|"installs/runs"| node_service_lifecycle
node_main_entry -->|"opens"| node_ipc_commander
node_main_entry -->|"opens"| node_ipc_configure
node_main_entry -->|"opens"| node_ipc_cryptdata
node_ipc_commander -->|"dispatches"| node_task_engine
node_ipc_configure -->|"uses"| node_cloud_common
node_ipc_cryptdata -->|"uses"| node_platform_utils
node_ipc_httpbus -->|"coordinates"| node_session_runtime
node_task_engine -->|"dispatches"| node_task_processors
node_task_engine -->|"builds"| node_session_runtime
node_task_engine -->|"writes"| node_task_output
node_session_runtime -->|"sends/receives"| node_session_transport
node_session_runtime -->|"adapts to"| node_identity_health
node_plugin_manager -->|"describes"| node_plugin_model
node_plugin_manager -->|"launches"| node_container_plugin
node_inventory_reporting -->|"uploads via"| node_cloud_common
node_inventory_reporting -->|"reads host data"| node_identity_health
node_state_update -->|"syncs via"| node_cloud_common
node_state_update -->|"schedules"| node_task_engine
node_plugin_manager -->|"extends"| node_task_engine
node_platform_utils -->|"supports"| node_cloud_common
node_container_plugin -->|"specializes"| node_task_processors

click node_main_entry "https://github.com/aliyun/aliyun_assist_client/blob/release/main.go"
click node_service_lifecycle "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/install"
click node_ipc_commander "https://github.com/aliyun/aliyun_assist_client/tree/release/interprocess/commander"
click node_ipc_configure "https://github.com/aliyun/aliyun_assist_client/tree/release/interprocess/configure"
click node_ipc_cryptdata "https://github.com/aliyun/aliyun_assist_client/tree/release/interprocess/cryptdata"
click node_ipc_httpbus "https://github.com/aliyun/aliyun_assist_client/tree/release/interprocess/httpserver"
click node_task_engine "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/taskengine"
click node_task_processors "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/taskengine/commander"
click node_task_output "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/taskengine/taskoutput"
click node_session_runtime "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/session"
click node_session_transport "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/session/channel"
click node_plugin_manager "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/pluginmanager"
click node_plugin_model "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/pluginmodel"
click node_identity_health "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/hybrid"
click node_inventory_reporting "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/inventory"
click node_state_update "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/statemanager"
click node_cloud_common "https://github.com/aliyun/aliyun_assist_client/tree/release/common"
click node_platform_utils "https://github.com/aliyun/aliyun_assist_client/tree/release/agent/util"
click node_container_plugin "https://github.com/aliyun/aliyun_assist_client/tree/release/plugin/commander/container"

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_inventory_reporting toneBlue
class node_task_engine,node_task_processors,node_task_output,node_session_runtime,node_session_transport,node_plugin_manager,node_plugin_model,node_identity_health,node_state_update toneAmber
class node_main_entry,node_service_lifecycle,node_ipc_commander,node_ipc_configure,node_ipc_cryptdata,node_ipc_httpbus toneMint
class node_cloud_common,node_platform_utils toneRose
class node_container_plugin toneIndigo
```

## Components

### Control Plane

Cloud-facing APIs, reporting, and transport edges

- [Inventory & Reporting](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/inventory): telemetry · Inventory collection plus heartbeat, metrics, command, update, and panic reports · `agent/inventory`

### Agent Core

Task execution, session management, state, and plugin orchestration

- [Task Engine](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/taskengine): command execution · Core ad hoc task pipeline that builds sessions, runs processors, and persists output · `agent/taskengine`
- [Processors](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/taskengine/commander): task dispatch · Command, host, script, and file handling within task execution · `agent/taskengine/commander`
- [Task Output](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/taskengine/taskoutput): output capture · Buffers, ring buffers, files, and multiwriter output sinks · `agent/taskengine/taskoutput`
- [Session Runtime](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/session): session state · Session state, shell handling, retry logic, and message/session results · `agent/session`
- [Session Transport](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/session/channel): transport channels · WebSocket and session channel implementations used by sessions · `agent/session/channel`
- [Plugin Manager](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/pluginmanager): plugin orchestration · Loads, installs, and coordinates local and remote plugins · `agent/pluginmanager`
- [Plugin Model](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/pluginmodel): plugin metadata · Plugin descriptors and metadata shared by manager and clients · `agent/pluginmodel`
- [Identity & Health](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/hybrid): host detection · Machine identity, virtualization, OS panic, kdumps, and network checks · `agent/hybrid`
- [State & Update](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/statemanager): desired state · Resource state management, scheduling, and timed update routines · `agent/statemanager`

### Local Integration

IPC, CLI entrypoints, and service lifecycle

- [Main CLI](https://github.com/aliyun/aliyun_assist_client/blob/release/main.go): agent entrypoints · Root commands and top-level binaries for the agent and helper tools · `main.go`
- [Service Setup](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/install): service/install · OS service installation and lifecycle integration · `agent/install`
- [Commander IPC](https://github.com/aliyun/aliyun_assist_client/tree/release/interprocess/commander): local gRPC · Local commander endpoint for coordination between processes · `interprocess/commander`
- [Configure IPC](https://github.com/aliyun/aliyun_assist_client/tree/release/interprocess/configure): local gRPC · Local configuration endpoint exposed to helper tools · `interprocess/configure`
- [Cryptdata IPC](https://github.com/aliyun/aliyun_assist_client/tree/release/interprocess/cryptdata): local gRPC · Local encrypted-data endpoint for secure parameter handling · `interprocess/cryptdata`
- [Local HTTP/Bus](https://github.com/aliyun/aliyun_assist_client/tree/release/interprocess/httpserver): local transport · HTTP/JSON-RPC and message-bus channels for local coordination · `interprocess/httpserver`

### Shared Libraries

Common utilities used across binaries and subsystems

- [Cloud Common](https://github.com/aliyun/aliyun_assist_client/tree/release/common): api/utilities · Shared API discovery, requester, HTTP, update verification, and machine/path utilities · `common`
- [Platform Utils](https://github.com/aliyun/aliyun_assist_client/tree/release/agent/util): cross-platform · Process, encryption, filesystem, OS, service, and system helpers used across the agent · `agent/util`

### Plugins

Separate plugin executables and runtime-specific command handlers

- [Container Plugin](https://github.com/aliyun/aliyun_assist_client/tree/release/plugin/commander/container): plugin executable · Standalone commander plugin for container command execution across Docker and CRI runtimes · `plugin/commander/container`

## Connections

- Main CLI → Service Setup: installs/runs · Top-level binaries start and manage the agent as an OS service
- Main CLI → Commander IPC: opens · CLI helpers and the agent use commander IPC for local coordination
- Main CLI → Configure IPC: opens · Configuration commands connect to the local configure endpoint
- Main CLI → Cryptdata IPC: opens · Encrypted payload tools connect to the cryptdata endpoint
- Commander IPC → Task Engine: dispatches · Local commander requests become task execution work
- Configure IPC → Cloud Common: uses · Configuration helpers rely on shared HTTP/API plumbing
- Cryptdata IPC → Platform Utils: uses · Encrypted data handling depends on local crypto and OS helpers
- Local HTTP/Bus → Session Runtime: coordinates · Local HTTP and message-bus channels coordinate session state and control messages
- Task Engine → Processors: dispatches · The engine selects processors for commands, host actions, scripts, and file transfer
- Task Engine → Session Runtime: builds · Task execution creates and updates session context
- Task Engine → Task Output: writes · Execution output is buffered and persisted for upload or reporting
- Session Runtime → Session Transport: sends/receives · Sessions communicate with the server through transport channels
- Session Runtime → Identity & Health: adapts to · Session behavior is informed by host identity, virtualization, and health checks
- Plugin Manager → Plugin Model: describes · Plugin metadata and descriptors define what the manager loads and runs
- Plugin Manager → Container Plugin: launches · Managed plugins can execute as separate binaries such as the container commander plugin
- Inventory & Reporting → Cloud Common: uploads via · Inventory and telemetry use shared request, API, and update utilities
- Inventory & Reporting → Identity & Health: reads host data · Inventory collection depends on machine, OS, and network identity signals
- State & Update → Cloud Common: syncs via · State and timed update routines use shared update and API logic
- State & Update → Task Engine: schedules · Desired-state and scheduled work feed the execution engine
- Plugin Manager → Task Engine: extends · Plugins augment task execution paths and local command capabilities
- Platform Utils → Cloud Common: supports · Low-level utilities underpin cloud access, processes, encryption, and OS-specific behavior
- Container Plugin → Processors: specializes · The container plugin implements a focused command processor for Docker and CRI runtimes
