mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-18 06:11:12 +00:00
Introduce the builtin `_a0_connector` plugin that lets the host-side A0 CLI connect to Agent Zero over authenticated HTTP and `/ws`. This adds connector capability discovery, chat/context lifecycle endpoints, log streaming, and the remote text editing, code execution, and file tree bridge used by the CLI workflow.
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""POST /api/plugins/_a0_connector/v1/pause."""
|
|
from __future__ import annotations
|
|
|
|
from helpers.api import Request, Response
|
|
import plugins._a0_connector.api.v1.base as connector_base
|
|
|
|
|
|
class Pause(connector_base.ProtectedConnectorApiHandler):
|
|
async def process(self, input: dict, request: Request) -> dict | Response:
|
|
from agent import AgentContext
|
|
|
|
context_id = str(input.get("context_id", "")).strip()
|
|
raw_paused = input.get("paused", True)
|
|
if isinstance(raw_paused, str):
|
|
paused = raw_paused.strip().lower() not in {"", "0", "false", "no", "off"}
|
|
else:
|
|
paused = bool(raw_paused)
|
|
|
|
if not context_id:
|
|
return Response(
|
|
response='{"error": "context_id is required"}',
|
|
status=400,
|
|
mimetype="application/json",
|
|
)
|
|
|
|
context = AgentContext.get(context_id)
|
|
if context is None:
|
|
return Response(
|
|
response='{"error": "Context not found"}',
|
|
status=404,
|
|
mimetype="application/json",
|
|
)
|
|
|
|
if paused and not context.is_running():
|
|
return Response(
|
|
response='{"error": "Context is not currently running"}',
|
|
status=409,
|
|
mimetype="application/json",
|
|
)
|
|
|
|
context.paused = paused
|
|
return {
|
|
"ok": True,
|
|
"context_id": context_id,
|
|
"paused": paused,
|
|
"status": "paused" if paused else "running",
|
|
"message": "Agent paused." if paused else "Agent unpaused.",
|
|
}
|