Skip to content

Repository files navigation

ACP - Agent Control Panel

A lightweight monitoring and observability sidecar for AI agents. Provides real-time tracking of agent activities, token usage, shell commands, and task management through a web UI and REST API.

made-with-Markdown

image

Quick Start

# Minimal version (single file, ~400 lines)
python acp-minimal.py
# Full version (production ready)
python VTSTech-GLMACP.py
# Open http://localhost:8766 (default: admin/secret)

What ACP Does

ACP acts as a "dashboard" for AI agents, allowing them to:

  • Report Activities - Log what they're doing (reading files, running commands, etc.)
  • Track Token Usage - Monitor context window consumption
  • Shell History - Record terminal commands executed
  • Task Management - Sync TODO lists and track progress
  • Stop/Resume - Allow humans to pause agent activity
  • Context Recovery - Preserve session state across context compressions

Versions

Minimal (acp-minimal.py) - Reference Implementation

  • ~400 lines of pure Python (no dependencies)
  • Single file, drop-in solution
  • Basic web UI included
  • Core API endpoints only
  • Perfect for learning the protocol or simple integrations

Full Version (VTSTech-GLMACP.py) - Production Ready

The full implementation includes everything in minimal plus:

FeatureDescription
File BrowserView and browse files the agent has accessed
Syntax HighlightingCode highlighting for 50+ languages
Line NumbersOptional line numbers in file viewer
Activity FiltersFilter by action type, status, date range
SearchFull-text search across activities
Changelog UIVersion history and release notes
Optional CSRFSecurity hardening (disabled by default)
Rate LimitingPrevent API abuse
Better Token EstimationImproved token counting heuristics
Configurable Context WindowEnvironment variable GLMACP_CONTEXT_WINDOW
File Token DeduplicationDon't double-count re-read files
Seamless RestartsSO_REUSEPORT for zero-downtime reload
v1.0.1 Activity Priorityhigh | medium | low priority field
v1.0.1 Activity MetadataArbitrary key-value pairs with agent_name support
v1.0.1 Content SizeAccurate token tracking for native tools
v1.0.1 Activity LookupGET /api/activity/{id} endpoint
v1.0.1 Activity HintsContextual hints in /api/action response
v1.0.1 CHAT Action TypeTrack conversational/cognitive work
v1.0.1 whoami EndpointGET /api/whoami for agent self-awareness
v1.0.2 Nudge APIHuman guidance via synchronous message delivery
v1.0.2 Orphan DetectionWarning when starting tasks with running activities
v1.0.2 Nudge Prioritynormal | high | urgent priority levels
v1.0.2 TODO/Shell Metadataagent_name, tool, skill attribution
v1.0.3 Per-Agent Tokensprimary_agent, agent_tokens{} for context isolation
v1.0.3 Context IsolationSession tokens reflect only primary agent context
v1.0.3 File DeduplicationREAD skips tokens for already-read files
v1.0.3 Duration StatisticsGET /api/stats/duration for performance analysis
v1.0.3 Batch OperationsPOST /api/activity/batch for bulk activities
v1.0.3 Cloudflared TunnelBuilt-in tunnel support via GLMACP_TUNNEL=auto
v1.0.4 Agent RegistryRegister agents, track online status, capabilities
v1.0.4 A2A MessagingInter-agent communication via message queue
v1.0.4 A2A HintsNotification of pending messages in activity response
v1.0.4 JSON-RPC 2.0A2A protocol compliance via /jsonrpc, /a2a endpoints
v1.0.4 Agent Card/.well-known/agent-card.json for A2A discovery
v1.0.5 Primary Agent in whoamiprimary_agent field in /api/whoami response
v1.0.5 Nudge DeliveryNudges delivered only to primary agent
v1.0.5 Context IsolationSecondary agents receive nudge: null
v1.0.6 TODO TogglePOST /api/todos/toggle endpoint
v1.0.6 Nudge PollingGET /api/nudge check pending without logging
v1.0.6 CORS SupportCORS headers and OPTIONS preflight handling

API Reference

Core Endpoints

MethodEndpointDescription
GET/api/statusGet current state (running, history, tokens, stop_flag)
GET/api/allCombined status + running + history in one call
POST/api/actionCombined log/complete workflow (recommended)
POST/api/startStart a new activity
POST/api/completeComplete an activity
POST/api/stopSet stop flag, cancel running activities
POST/api/resumeClear stop flag
POST/api/shutdownv1.0.2 Gracefully end session with summary export
GET/api/runningList currently running activities
GET/api/historyGet activity history
GET/api/activity/{id}v1.0.1 Get single activity by ID
GET/api/whoamiv1.0.1 Agent self-awareness and identity hint
GET/api/csrf-tokenGet CSRF token (if enabled)
POST/api/clear_historyClear activity history
POST/api/reset_sessionReset session tokens to startup value
POST/api/resetv1.0.4 Full session reset including agents and A2A messages
POST/api/nudgev1.0.2 Send guidance to agent
GET/api/nudgev1.0.2 Check pending nudge
POST/api/nudge/ackv1.0.2 Acknowledge nudge
GET/api/stats/durationv1.0.3 Activity duration statistics
POST/api/activity/batchv1.0.3 Batch activity operations
GET/api/agentsv1.0.4 List all registered agents
GET/api/agents/{name}v1.0.4 Get specific agent details
POST/api/agents/registerv1.0.4 Register agent with capabilities
POST/api/agents/unregisterv1.0.4 Unregister an agent
POST/api/a2a/sendv1.0.4 Send message to another agent
GET/api/a2a/historyv1.0.4 Get A2A message history
GET/.well-known/agent-card.jsonv1.0.4 A2A Agent Card discovery
POST/jsonrpc/a2a/api/jsonrpcv1.0.4 JSON-RPC 2.0 endpoint

Extended Endpoints (Full Version)

MethodEndpointDescription
GET/api/files/listList directory contents
GET/api/files/viewView file content with token count
GET/api/files/downloadDownload file (binary safe)
POST/api/files/uploadUpload file
POST/api/files/saveSave edited file
POST/api/files/deleteDelete file or directory
POST/api/files/mkdirCreate directory
POST/api/files/extractExtract archive
POST/api/files/compressCreate zip archive
GET/api/systemCPU, RAM, disk statistics
GET/api/sessionSession info and timeout
POST/api/session/refreshExtend session timeout
POST/api/restartRestart the ACP server
GET/api/summaryGet session summary for context recovery
GET/api/summary/exportExport summary to persistent markdown file
GET/api/notesGet all saved notes
POST/api/notes/addAdd note for context recovery
POST/api/notes/clearClear all AI notes
GET/api/todosGet current TODO list
POST/api/todos/updateReplace entire TODO list
POST/api/todos/addAdd single TODO item
POST/api/todos/clearClear completed TODOs
GET/api/shellGet shell command history
POST/api/shell/addAdd shell command to history
POST/api/shell/clearClear shell history

Action Parameters (v1.0.1)

ParameterTypeDescription
actionstringAction type (required)
targetstringFile path, command, or resource (required)
detailsstringHuman-readable description
content_sizeintegerCharacter count for accurate token tracking
prioritystringhigh | medium | low (default: medium)
metadataobjectArbitrary key-value pairs (e.g., {"agent_name": "Super Z"})

Action Types

ActionTarget ExampleDetails
READ/path/to/file.pyFile being read
WRITE/path/to/output.mdFile being written
EDIT/path/to/file.pyFile being modified
BASHnpm installShell command
SEARCHpatternSearch operation
SKILLimage-generationSkill invocation
APIPOST https://api.example.comExternal API call
TODOtask-id-123TODO update
CHATdiscussion topicv1.0.1 Conversational/cognitive work
A2AAgentA → AgentBv1.0.4 Agent-to-agent communication

Integration Pattern

Agents should follow this workflow:

0. SESSION START (mandatory)
GET /api/whoami → Establish identity (use agent_name in metadata)
POST /api/agents/register → Register with Agent Registry (v1.0.4)
GET /api/todos → Restore TODO state
POST /api/action → Log bootstrap activity (CHAT, "Session bootstrap")
1. CHECK STATUS → GET /api/status (check stop_flag)
2. LOG ACTION → POST /api/action (with action, target, details, metadata)
3. EXECUTE → Do the actual work
4. COMPLETE → POST /api/action (with complete_id, result)

Example: Reading a File

importrequestsACP_URL="http://localhost:8766"AUTH= ("admin", "secret")
# 0. Session start - establish identitywhoami=requests.get(f"{ACP_URL}/api/whoami", auth=AUTH).json()
agent_name="MyAgent"# Use this in all activity metadata# Register with agent registry (v1.0.4)requests.post(f"{ACP_URL}/api/agents/register", auth=AUTH, json={
"agent_name": agent_name,
"capabilities": ["file-reading", "code-analysis"]
})
# 1. Check if we should stopstatus=requests.get(f"{ACP_URL}/api/status", auth=AUTH).json()
ifstatus["stop_flag"]:
print(f"Stop requested: {status['stop_reason']}")
exit(1)
# 2. Log action start (include content_size, priority, metadata)resp=requests.post(f"{ACP_URL}/api/action", auth=AUTH, json={
"action": "READ",
"target": "/home/user/project/main.py",
"details": "Reading source file",
"priority": "high",
"metadata": {"agent_name": agent_name, "source": "user_request"}
})
activity_id=resp.json()["activity_id"]
# Check A2A hints for pending messages (v1.0.4)hints=resp.json().get("hints", {})
ifhints.get("a2a", {}).get("pending_count", 0) >0:
messages=requests.get(f"{ACP_URL}/api/a2a/history?to={agent_name}", auth=AUTH).json()
# process messages...# 3. Executecontent=open("/home/user/project/main.py").read()
# 4. Complete (include content_size for accurate token tracking)requests.post(f"{ACP_URL}/api/action", auth=AUTH, json={
"complete_id": activity_id,
"result": f"Read {len(content)} bytes",
"complete_content_size": len(content),
"complete_metadata": {"lines": content.count(chr(10))}
})

Environment Variables

VariableDefaultDescription
GLMACP_PORT8766Server port
GLMACP_USERadminHTTP Basic Auth username
GLMACP_PASSsecretHTTP Basic Auth password
GLMACP_DATA_FILE./agent_activity.jsonSession state storage file path
GLMACP_FILES_DIR(script parent)Base directory for file manager
GLMACP_SUMMARY_FILE./acp_session_summary.mdContext recovery summary file path
GLMACP_QUIETfalseSuppress server log output
GLMACP_CSRF_ENABLEDfalseEnable CSRF protection (recommended for production)
GLMACP_CONTEXT_WINDOW200000Token limit for progress bar
GLMACP_STARTUP_TOKENS3000Initial token overhead estimate
GLMACP_SESSION_TIMEOUT86400Session timeout in seconds
GLMACP_MAX_UPLOAD_SIZE104857600Max upload size (100MB)
GLMACP_MAX_FILE_VIEW_SIZE10485760Max file view size (10MB)
GLMACP_TUNNELfalsev1.0.3 Auto-start cloudflared tunnel (auto, true, yes)
GLMACP_TUNNEL_URL(none)v1.0.3 Reuse an existing tunnel URL

Documentation

Architecture

┌─────────────────────────────────────────────────────────┐
│ AI Agent │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ File Ops │ │ Shell Exec │ │ LLM Calls │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └────────────────┼────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────────┐ │
│ │ ACP Client Library │ │
│ │ log_action() | check_stop() | complete() │ │
│ └───────────────────────┬───────────────────────┘ │
└──────────────────────────┼──────────────────────────────┘
│ HTTP REST / JSON-RPC 2.0
▼
┌─────────────────────────────────────────────────────────┐
│ ACP Server │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ REST API │ │ Web UI │ │ Storage │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ A2A/JSON- │ │ Agent │ (v1.0.4) │
│ │ RPC Layer │ │ Registry │ │
│ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────┘
│
▼
Human Operator
(Browser/Dashboard)

Use Cases

  1. Development Agents - Monitor what files your coding agent is touching
  2. Research Agents - Track web searches and LLM interactions
  3. Task Automation - See progress of long-running automation tasks
  4. Safety/Control - Intervene when agents go off-track
  5. Multi-Agent Systems - Coordinate and observe multiple agents sharing one session

License

MIT

Author

VTSTech

About

A lightweight monitoring and observability sidecar for AI agents. Provides real-time tracking of agent activities, token usage, shell commands, and task management through a web UI and REST API.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages