Skip to content

Agent websites: proxy live web server in agent container via /site/{token} endpoint (SITE-001) #633

Closed

Description

@vybe

Summary

Agents can own and serve a public-facing website by running a standardized web server (e.g. Next.js) inside their container. Trinity's backend exposes a `/site/{token}/{path*}` endpoint that HTTP-proxies requests to the agent's web server via the internal Docker network. The agent has full ownership of its site directory, manages content autonomously, and is aware of the site's structure — no CMS or external deploy pipeline needed.

Context

Every agent should be able to have a public "face" — a real website it maintains itself (dashboards, landing pages, status pages, portfolios). The agent runs a web server on a known internal port; Trinity proxies it through the public links mechanism. A standardized stack (same framework across all webmaster-type agents) means agents have consistent knowledge of their own site structure and can edit, rebuild, and redeploy it via scheduled skills.

Architecture

Browser → Trinity /site/{token}/path
           → validate token (public_links, type=site)
           → HTTP proxy to http://trinity-agent-{name}:{SITE_PORT}/path
              (agent Docker network 172.28.0.0/16)
           → agent web server (Next.js on port 3000, standardized)
           → agent manages ~/site/ directory directly

Key points:

  • Agent runs its own web server (standardized stack) as a background process in the container
  • Proxy is live HTTP — supports routing, dynamic content, assets, SSR
  • Agent owns `~/site/` and has full structural awareness; it edits files and triggers rebuilds itself
  • No `docker get_archive` / static file extraction (that's FILES-001's domain)

Acceptance Criteria

  • New public link type `site` in `public_links` table (add `type TEXT DEFAULT 'chat'` + migration)
  • `GET /site/{token}/{path:path}` endpoint: validates token (type=site, enabled, not expired), reverse-proxies to `http://trinity-agent-{name}:{SITE_PORT}/{path}\` via httpx
  • `SITE_PORT` is a fixed convention (e.g. 3000) known to both the template and the proxy
  • 502 if agent web server is not running; 410 if link revoked/expired; 401 if token invalid
  • Existing `/chat/{token}` behavior unchanged
  • Agent owner can create/revoke site links via UI (Sharing panel, new "Website" tab or toggle)
  • External URL: `{public_chat_url}/site/{token}/`
  • Rate-limited per token; audit event `site_link_visit` logged
  • Webmaster agent template ships with: Next.js scaffold in `~/site/`, startup script that runs `npm start` on port 3000, `CLAUDE.md` with site structure documentation so the agent knows how to maintain it

Technical Notes

Backend changes:

  • `db/schema.py`: `type` column on `public_links` + versioned migration
  • `routers/public_links.py`: create/revoke for type=site
  • New `routers/site.py`: `GET /site/{token}/{path:path}` — token lookup, then `httpx.AsyncClient` reverse proxy to agent container (no timeout for streaming; forward `Content-Type`, `Cache-Control`)
  • Agent container hostname convention: `trinity-agent-{name}` (already on `172.28.0.0/16`)

Agent template (follow-on issue):

  • Standardized stack (Next.js or equivalent)
  • `~/site/` directory the agent owns
  • Startup integration (run web server alongside agent-server)
  • Scheduled skill scaffold for content refresh

Out of scope here (follow-on):

  • The webmaster agent template itself
  • SPA fallback (serve `index.html` for unknown paths)
  • Custom domain mapping
  • Build step orchestration (agent handles this itself)

Related: `routers/public_links.py`, `routers/public.py`, Docker network `172.28.0.0/16`, FILES-001

Activity

  1. added
    priority-p2
    type-feature
    on May 3, 2026
  2. changed the title [-]Agent websites: serve static sites from agent public/ via /site/{token} endpoint (SITE-001)[/-] [+]Agent websites: proxy live web server in agent container via /site/{token} endpoint (SITE-001)[/+] on May 3, 2026
  3. vybe commented on May 3, 2026

    @vybe
    ContributorAuthor

    /claim

  4. added
    status-in-progress
    on May 3, 2026
  5. github-actions commented on May 3, 2026

    @github-actions

    Claimed by @vybe. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/633-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #633
  6. added a commit that references this issue on May 3, 2026
    008f835
  7. added
    status-in-dev
    and removed
    status-in-progress
    on May 3, 2026
  8. added a commit that references this issue on Jun 1, 2026
    7b64bb4
  9. added
    complexity-medium
    theme-ui-ux
    on Jun 3, 2026
  10. removed
    status-in-dev
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-mediumpriority-p2theme-ui-uxtype-feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions