AgenShield HTTP daemon server with embedded UI
npm install @agenshield/daemonAgenShield daemon is a Fastify-based HTTP service that exposes the management API and (optionally) serves the embedded UI. It is separate from the broker: this daemon focuses on control-plane operations, status, and UI interactions.
src/main.ts - Entry point, PID file handling, and server startup.src/server.ts - Fastify server setup + static UI serving.src/routes/* - HTTP endpoints and SSE routes.src/auth/* - Passcode hashing, session manager, auth middleware.src/config/* - Config loader and defaults.src/state/* - Persistent state file management.src/vault/* - Encrypted vault for tokens/secrets.src/watchers/* - Background watchers (security status).src/events/* - Event emitter feeding SSE./api (see @agenshield/ipc constants).Core endpoints:
- GET /api/health - Health check.
- GET /api/status - Daemon status + version.
- GET /api/config - Current config.
- PUT /api/config - Update config.
- GET /api/security - Security status snapshot.
Wrappers:
- GET /api/wrappers - List available wrappers.
- GET /api/wrappers/:name - Wrapper details + generated content.
- GET /api/wrappers/status - Installed status.
- POST /api/wrappers/install - Install wrappers.
- DELETE /api/wrappers/:name - Uninstall wrapper.
- PUT /api/wrappers/:name - Update wrapper.
- POST /api/wrappers/custom - Add a custom wrapper.
- DELETE /api/wrappers/custom/:name - Remove a custom wrapper.
- POST /api/wrappers/sync - Sync wrapper set based on policy.
- POST /api/wrappers/regenerate - Regenerate installed wrappers.
Auth:
- GET /api/auth/status
- POST /api/auth/setup
- POST /api/auth/unlock
- POST /api/auth/lock
- POST /api/auth/change
- POST /api/auth/refresh
- POST /api/auth/enable
- POST /api/auth/disable
AgenCo:
- POST /api/agenco/auth/start
- POST /api/agenco/auth/callback
- GET /api/agenco/auth/status
- POST /api/agenco/auth/logout
- POST /api/agenco/tool/run
- GET /api/agenco/tool/list
- GET /api/agenco/tool/search
- GET /api/agenco/integrations
- GET /api/agenco/integrations/connected
- POST /api/agenco/integrations/connect
SSE:
- GET /sse/events?token=...
- GET /sse/events/:filter?token=...
Authorization: Bearer or ?token=... for SSE.~/.agenshield/config.json~/.agenshield/state.json~/.agenshield/vault.enc (encrypted with machine-bound key)Defaults are defined in @agenshield/ipc and src/config/defaults.ts.
@agenshield/sandbox (macOS-specific)./Users/clawagent/bin./health.bash
Run directly
npx tsx libs/shield-daemon/src/main.tsBuild
npx nx build shield-daemon
`Contribution Guide
- Add new routes in src/routes/ and register in src/routes/index.ts.
- Update src/auth/middleware.ts if new endpoints need protection.
- Keep response shapes aligned with @agenshield/ipc types.
- Emit SSE events through src/events/emitter.ts for UI reactivity.Agent Notes
- startServer() starts the security watcher; remember to stop it on shutdown.
- The UI assets are served from ui-assets (prod) or dist/apps/shield-ui (dev).
- AgenCo tokens are stored in the vault; expect network calls to the MCP gateway.
- Config updates are persisted via src/config/loader.ts` (JSON + Zod).