How aliyun/aliyun_assist_client works
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: taskengine Task Engine · main.go Main CLI · session Session Runtime · common Cloud Common
Components 19
Control Plane
Cloud-facing APIs, reporting, and transport edges
- Inventory & Reporting · Inventory collection plus heartbeat, metrics, command, update, and panic reports
agent/inventory
Agent Core
Task execution, session management, state, and plugin orchestration
- Task Engine · Core ad hoc task pipeline that builds sessions, runs processors, and persists output
agent/taskengine - Processors · Command, host, script, and file handling within task execution
agent/taskengine/commander - Task Output · Buffers, ring buffers, files, and multiwriter output sinks
agent/taskengine/taskoutput - Session Runtime · Session state, shell handling, retry logic, and message/session results
agent/session - Session Transport · WebSocket and session channel implementations used by sessions
agent/session/channel - Plugin Manager · Loads, installs, and coordinates local and remote plugins
agent/pluginmanager - Plugin Model · Plugin descriptors and metadata shared by manager and clients
agent/pluginmodel - Identity & Health · Machine identity, virtualization, OS panic, kdumps, and network checks
agent/hybrid - State & Update · Resource state management, scheduling, and timed update routines
agent/statemanager
Local Integration
IPC, CLI entrypoints, and service lifecycle
- Main CLI · Root commands and top-level binaries for the agent and helper tools
main.go - Service Setup · OS service installation and lifecycle integration
agent/install - Commander IPC · Local commander endpoint for coordination between processes
interprocess/commander - Configure IPC · Local configuration endpoint exposed to helper tools
interprocess/configure - Cryptdata IPC · Local encrypted-data endpoint for secure parameter handling
interprocess/cryptdata - Local HTTP/Bus · HTTP/JSON-RPC and message-bus channels for local coordination
interprocess/httpserver
Shared Libraries
Common utilities used across binaries and subsystems
- Cloud Common · Shared API discovery, requester, HTTP, update verification, and machine/path utilities
common - Platform Utils · 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 · Standalone commander plugin for container command execution across Docker and CRI runtimes
plugin/commander/container
Connections 22
- 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