Phase 11: remote UX & network attach (0.11.0)

- Live remote-stack logs over a WebSocket proxied through the central app to
  the agent (/ws/agent-logs/{agent}/{stack}); agent gains a WS log endpoint.
- Deploy to a remote host from the UI: host selector in the New Stack editor
  and template dialog; templates instantiate onto an agent via the proxy.
- Network attach/detach: expandable inspect view per network with
  connect/disconnect + container picker; GET /{id}/containers, POST connect/disconnect.
- Remove dead pages/Placeholder.tsx.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
menzelj
2026-06-08 07:49:20 +00:00
co-authored by Claude Opus 4.8
parent ec7e3e706f
commit 1931500c24
18 changed files with 492 additions and 67 deletions
+27 -4
View File
@@ -8,10 +8,12 @@ from sqlmodel import Session
from auth import get_current_user, require_admin
from database import get_session
from models.agent import Agent
from models.stack import Stack
from models.template import TemplateInstantiateRequest, TemplateSaveRequest
from models.user import User
from services import audit_service, compose_service, template_service
from services import agent_service, audit_service, compose_service, template_service
from services.agent_service import AgentError
router = APIRouter(prefix="/api/templates", tags=["templates"])
@@ -72,7 +74,7 @@ def delete_template(
@router.post("/{template_id}/instantiate", status_code=201)
def instantiate(
async def instantiate(
template_id: str,
body: TemplateInstantiateRequest,
request: Request,
@@ -83,11 +85,32 @@ def instantiate(
if not tpl:
raise HTTPException(status_code=404, detail="Template not found")
rendered = template_service.render(tpl["yaml"], body.values)
if body.agent_id is not None:
agent = session.get(Agent, body.agent_id)
if not agent:
raise HTTPException(status_code=404, detail=f"Agent {body.agent_id} not found")
try:
result = await agent_service.call(
session, agent, "POST", "/agent/stacks",
json={"name": body.name, "yaml": rendered, "env": None},
)
except AgentError as exc:
raise HTTPException(
status_code=exc.status if exc.status >= 400 else 502,
detail={"error": exc.error, "detail": exc.detail},
)
audit_service.record(
session, user=user.username, action="template.instantiate",
target=f"{agent.name}/{result.get('id')}", detail=template_id, ip=_ip(request),
)
return {"id": result.get("id"), "name": body.name, "agent_id": agent.id}
stack_id = compose_service.slugify(body.name)
if session.get(Stack, stack_id) or os.path.isdir(compose_service.stack_dir(stack_id)):
raise HTTPException(status_code=409, detail=f"Stack '{stack_id}' already exists")
rendered = template_service.render(tpl["yaml"], body.values)
compose_service.write_compose(stack_id, rendered)
stack = Stack(id=stack_id, name=body.name, description=tpl.get("description"))
session.add(stack)
@@ -96,4 +119,4 @@ def instantiate(
session, user=user.username, action="template.instantiate",
target=stack_id, detail=template_id, ip=_ip(request),
)
return {"id": stack_id, "name": body.name}
return {"id": stack_id, "name": body.name, "agent_id": None}