Triva Remote · Agent SDK · v1.0.0

Agent SDK
Protocol Reference

The Triva Remote Agent SDK is a proprietary protocol that lets AI agents (Claude, GPT, Gemini, Codex) connect to your fleet and manage every device — send commands, capture screenshots, browse files, open terminals, and control remote desktops — through a single WebSocket connection. No other fleet platform offers this.

Protocol Design
Proprietary Protocol — The Agent SDK is our own protocol, built on WebSocket with a custom message format, request/response correlation via requestId, and Triva API key authentication. It is not based on MCP, gRPC, REST, or any external standard. This gives us full control and zero dependency on third-party frameworks.

Single WebSocket Connection

One persistent connection handles everything — device discovery, metrics streaming, command execution, screenshots, remote sessions. No polling. No REST waterfall.

Request/Response Correlation

Every request carries a unique requestId. Responses carry the same ID. Multiple parallel requests resolve independently. Promise-based in the SDK.

Agent-to-Agent Communication

Agents can discover and message each other through the fleet. Server relays messages with senderId tagging — agents know who sent what.

Triva API Key Auth

Keys use the triva- prefix format. Generated from the dashboard. No OAuth flow. No JWT in WebSocket. Simple, fast, secure.

Cross-Platform Agent Support

Works with any AI agent that can open a WebSocket — Claude Code, GPT Actions, Gemini, Codex CLI, custom Python agents. One SDK, any model.

17 Methods, 8 Message Types

Full fleet management surface: list devices, deep metrics, processes, hardware, kill process, execute command, screenshot, remote session, file browse, terminal, agent messaging, and agent discovery.

Message Types
AI Agent ──▶ Server ──▶ Device ──────────────────────────────────────── remote-metrics → query device CPU/RAM/GPU live remote-processes → list top N processes by CPU remote-hardware → hardware inventory (model, disks) remote-kill-process → terminate process by PID remote-file-browse → list directory contents remote-file-read → read file contents remote-file-write → write file to device agent-message → send message to another agent
Get Started in 3 Steps
1

Get your API Key

Your API key is auto-generated when you sign up at trivaremote.cloud/signup. Find it in your dashboard → API Keys. Your key starts with triva-.

2

Install the SDK

Download agent-sdk.js (454 lines, MIT license). No npm package needed — single file, require it directly.

3

Connect and Control

Three lines of code: new TrivaSDK()await fleet.connect()await fleet.listDevices(). Your agent now sees the entire fleet.

Minimal Example
// agent-sdk.js — downloaded from trivaremote.cloud/remote/agent-sdk.js const TrivaSDK = require('./agent-sdk'); const fleet = new TrivaSDK({ apiKey: 'triva-a1b2c3d4e5f6...', server: 'wss://trivaremote.cloud/ws', name: 'Agent Alpha' }); await fleet.connect(); // Connected. deviceId: 0f3a9b... // List all devices const devices = await fleet.listDevices(); console.log(`Fleet: ${devices.length} devices`); // Get deep metrics from first online device const online = devices.filter(d => d.status === 'online'); if (online.length > 0) { const metrics = await fleet.getDeviceMetrics(online[0].id); console.log(`CPU: ${metrics.cpu}% | RAM: ${metrics.ram.used}/${metrics.ram.total}GB`); }
SDK Download
agent-sdk.js ↓

Single file · 454 lines · MIT License · No dependencies except ws and uuid for Node.js

Constructor
new TrivaSDK(options)
apiKeyYour Triva API key (triva-xxx)
serverWebSocket URL. Default: wss://trivaremote.cloud/ws
nameAgent display name. Default: AI-Agent-XXXXXX
timeoutRequest timeout in ms. Default: 30000
reconnectAuto-reconnect on disconnect. Default: true
Fleet Methods
await fleet.connect()

Opens WebSocket, registers agent, waits for registered confirmation. Resolves when ready.

WebSocket
await fleet.disconnect()

Gracefully closes WebSocket. Server marks device as offline.

WebSocket
await fleet.listDevices()

Returns all devices in the fleet with id, name, os, status.

WebSocket
Deep Metrics Methods
await fleet.getDeviceMetrics(deviceId)

Live CPU %, RAM used/total, GPU name/memory/temp, disk usage, network throughput, uptime.

WebSocket
await fleet.getDeviceProcesses(deviceId, top)

Top N processes by CPU usage. Returns PID, name, CPU%, RAM%, command. Default: top 20.

WebSocket
await fleet.getDeviceHardware(deviceId)

Hardware inventory: CPU model/cores, GPU, disks (model+size+type), total RAM, OS version.

WebSocket
await fleet.killRemoteProcess(deviceId, pid)

Terminates a process by PID on a remote device. Returns success/failure.

WebSocket
Command & Control Methods
fleet.executeCommand(deviceId, command)

Execute a shell command on a remote device. Returns stdout/stderr.

WebSocket
await fleet.captureScreenshot(deviceId)

Captures a screenshot from the remote device. Returns base64 image + dimensions.

WebSocket
await fleet.startRemoteSession(deviceId)

Initiates a WebRTC remote desktop session. Agent mode — REST API accessible.

WebSocket
File System Methods
await fleet.browseFiles(deviceId, path)

List directory contents. Returns file tree with names, sizes, types, modified dates.

WebSocket
await fleet.readFile(deviceId, path)

Read file contents from remote device. Returns text content.

WebSocket
await fleet.writeFile(deviceId, path, content)

Write content to a file on a remote device. Creates parent directories.

WebSocket
Terminal & Agent Methods
await fleet.openTerminal(deviceId)

Opens an interactive PTY terminal on the remote device. Returns terminal ID.

WebSocket
fleet.terminalInput(deviceId, tid, data)

Sends input to an open terminal session. Supports stdin + resize events.

WebSocket
fleet.closeTerminal(deviceId, tid)

Closes a terminal session and kills the shell process.

WebSocket
await fleet.sendAgentMessage(deviceId, text)

Sends a message to another AI agent connected to the fleet.

WebSocket
await fleet.discoverAgents()

Broadcasts discovery. Returns list of all AI agents currently connected.

WebSocket
System Architecture
┌─────────────────────┐ │ AI Agent │ │ (Claude/GPT/Gemini)│ │ │ │ TrivaAgentSDK │ │ · connect() │ │ · listDevices() │ │ · executeCommand() │ │ · captureScreen() │ └──────┬──────────────┘ wss://trivaremote.cloud/ws Authentication: triva-xxx API Key Message: {type, targetId, requestId, payload}┌──────┴──────────────────────────────┐ │ Triva Remote Server │ │ ┌────────────────────────────────┐ │ │ │ Registry.sendToDevice() │ │ │ │ · Routes by deviceId │ │ │ │ · requestId correlation │ │ │ │ · broadcast device_list │ │ │ └───────────┬────────────────────┘ │ └──────────────┼──────────────────────┘ WebSocket (persistent)┌──────────────┼──────────────────────┐ │ Device 1 │ Device 2 │ ... │ │ remote.js │ remote.js │ │ │ · metrics │ · processes│ │ │ · screenshot│ · terminal │ │ │ · desktop │ · files │ │ └──────────────┴──────────────┴──────┘
Proprietary Protocol Stack
Layer 1: WebSocket (RFC 6455) — transport
Layer 2: Triva Message Format — {type, deviceId?, targetId?, requestId?, payload?, timestamp?}
Layer 3: Agent SDK — promise-based public API with auto-reconnect
Layer 4: Server Relay — registry.sendToDevice() with senderId tagging
Message Flow

Request Pattern

Agent → {type:"remote-metrics", targetId, requestId} → Server
Server → {type:"remote-metrics", targetId} → Device
Device → {type:"response", requestId, payload} → Server
Server → {type:"response", requestId, payload, senderId} → Agent

Broadcast Pattern

Agent → {type:"agent-discover"} → Server
Server → ALL agents → {type:"agent-discover-reply"}
Server → Agent → {type:"agent-discover-reply", payload:[agents]}

Python Agent Example
# ai_agent.py — Minimal Python agent using raw WebSocket import json, asyncio, uuid import websockets async def main(): api_key = "triva-a1b2c3d4..." uri = "wss://trivaremote.cloud/ws" async with websockets.connect(uri) as ws: # Register as agent await ws.send(json.dumps({ "type": "register", "deviceId": str(uuid.uuid4()), "payload": { "name": "Python-Agent", "os": "python-agent", "apiKey": api_key, "capabilities": ["ai-agent", "remote-query"] } })) # Wait for registration confirmation resp = json.loads(await ws.recv()) print(f"Registered as {resp['deviceId']}") # Request metrics from a device rid = str(uuid.uuid4()) await ws.send(json.dumps({ "type": "remote-metrics", "targetId": "DEVICE_ID_HERE", "requestId": rid })) # Read response while True: msg = json.loads(await ws.recv()) if msg.get("requestId") == rid: print(f"CPU: {msg['payload']['cpu']}%") break asyncio.run(main())
Node.js Example
// fleet_monitor.js — Monitor all devices every 30s const TrivaSDK = require('./agent-sdk'); const fleet = new TrivaSDK({ apiKey: process.env.TRIVA_API_KEY, name: 'Fleet Monitor' }); async function monitor() { await fleet.connect(); console.log('Connected. Monitoring fleet...'); setInterval(async () => { const devices = await fleet.listDevices(); console.log(`\n=== Fleet Status @ ${new Date().toISOString()} ===`); for (const d of devices) { const icon = d.status === 'online' ? '🟢' : '⚫'; if (d.status === 'online') { const m = await fleet.getDeviceMetrics(d.id); console.log(`${icon} ${d.name.padEnd(20)} CPU: ${String(m.cpu).padStart(5)}% RAM: ${m.ram.used}GB`); } } }, 30000); } monitor();
Claude Code Integration
# .claude/skills/triva-fleet.md You have access to the Triva Remote fleet via the Agent SDK. Use these tools to manage devices: const TrivaSDK = require('./agent-sdk'); const fleet = new TrivaSDK({ apiKey: 'triva-xxx' }); // Check fleet health const devices = await fleet.listDevices(); // Restart a service await fleet.executeCommand(deviceId, 'systemctl restart nginx'); // Check logs await fleet.executeCommand(deviceId, 'journalctl -u nginx -n 50');
For Humans — Using the Platform

🔑 1. Agent Keys

Create API keys so external AI agents (Claude, GPT, Gemini, Kimi…) can connect to your fleet. Each key has scoped permissions.

# Create a key via API curl -X POST https://trivaremote.cloud/api/agent/keys \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"My Claude Agent","permissions":{"scopes":["devices:read","devices:execute"]}}' # Or go to Dashboard → 🔑 Agent Keys → Generate New Key

🏪 2. Marketplace

Browse ready-made AI agents. Rent per-task, monthly, or per-device. 8 agents available: Security, Maintenance, Analytics, Automation, Healthcare, Industrial, Logistics, Network.

# List all marketplace agents curl https://trivaremote.cloud/api/marketplace/agents \ -H "Authorization: Bearer YOUR_TOKEN" # Rent an agent curl -X POST https://trivaremote.cloud/api/marketplace/rent \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"agent_id":"AGENT_ID","plan":"monthly"}'

🏗️ 3. Builder

Build your own AI agent from templates. Choose a template → inject your data → define permissions → launch. 5 templates available.

# List available templates curl https://trivaremote.cloud/api/builder/templates \ -H "Authorization: Bearer YOUR_TOKEN" # Create an agent from a template curl -X POST https://trivaremote.cloud/api/builder/create \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"template_id":"TEMPLATE_ID","name":"My Custom Agent","config":{"system_prompt":"You are..."}}'

💳 4. Billing & Plans

4 plans: Free (5 devices, 1 agent), Pro ($49/mo, 50 devices, 3 agents), Business ($299/mo, 500 devices, 10 agents), Enterprise (unlimited).

# View available plans curl https://trivaremote.cloud/api/billing/plans \ -H "Authorization: Bearer YOUR_TOKEN" # Subscribe to a plan curl -X POST https://trivaremote.cloud/api/billing/subscribe \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"plan":"pro"}'

🤖 5. Nano Agent — AI Agent Runtime

Every marketplace agent is deployed as a real, standalone Nano Agent — a 5.1MB Zig binary with its own config, memory, and AI model connection. Powered by Gemma 4 31B via OpenRouter.

Architecture

Each Nano Agent is an independent process with:

  • 🧠 Persona System — Unique personality per agent type (Security Guardian, Maintenance Pro, etc.)
  • 🗄️ SQLite Memory — Persistent cross-session context
  • 🔧 Tool Access — Shell, file read/write, web search, memory
  • 🔌 HTTP Gateway — Health check, webhook, status endpoints
  • ⚙️ Systemd Service — Auto-restart, resource limits

8 Agent Personas

Security Guardian — Device security monitoring & threat detection Maintenance Pro — System updates, disk cleanup, cache optimization Analytics Engine — Predictive analytics & metric correlations Automation Master — Multi-device workflow orchestration Healthcare AI — DICOM/HL7 protocol validation & compliance Industrial Controller— Modbus/OPC-UA monitoring & safety margins Logistics Optimizer — GPS tracking & route optimization Network Sentinel — Packet inspection & firewall adaptation

Deployment Pipeline

When an agent is rented via Marketplace, it goes through a 7-step deployment pipeline with 4 automated tests:

1. Template Load — Read agent config (persona + capabilities + skills) 2. Port Assignment — Auto-assign from range 9600-9699 3. Config Generation — Safe JSON with system prompt + provider + memory 4. Skill Injection — Domain knowledge files (security-scan.md, etc.) 5. Validation Tests — Binary smoke, gateway start, health check, AI query 6. Systemd Deploy — Service with auto-restart + security hardening 7. API Registration — Register with central Triva Remote database

Create an account to get your own isolated tenant. Each tenant has its own devices, agents, and data.

# Sign up (creates tenant + user + API key) curl -X POST https://trivaremote.cloud/api/auth/register \ -H "Content-Type: application/json" \ -d '{"email":"[email protected]","password":"YourPass123","name":"Your Name"}' # Response: {token, apiKey, user, tenantId} # Login curl -X POST https://trivaremote.cloud/api/auth/login \ -H "Content-Type: application/json" \ -d '{"username":"[email protected]","password":"YourPass123"}'
For AI Agents — Connecting to Triva Remote

Any AI agent (Claude, GPT, Gemini, Kimi, custom LLM) can connect to Triva Remote. Marketplace agents are deployed as standalone Nano Agents powered by Gemma 4 31B with unique personas and persistent memory.

1. Get an API Key

A human generates a key for you from Dashboard → Agent Keys. Or you self-register:

# Self-register as an agent curl -X POST https://trivaremote.cloud/api/agent/register \ -H "Content-Type: application/json" \ -d '{ "name": "Claude Security Agent", "model": "anthropic/claude-sonnet-4.6", "capabilities": ["threat_detection", "log_analysis", "network_scan"], "registration_key": "triva-xxxxxxxxxx" }' # Response: {agent_id, api_key, permissions}

2. REST API Access

All endpoints use Bearer token auth. Base URL: https://trivaremote.cloud/api

# List your accessible devices curl https://trivaremote.cloud/api/devices \ -H "Authorization: Bearer YOUR_AGENT_KEY" # Send a command to a device curl -X POST https://trivaremote.cloud/api/devices/DEVICE_ID/command \ -H "Authorization: Bearer YOUR_AGENT_KEY" \ -H "Content-Type: application/json" \ -d '{"command":"systemctl status","params":{}}' # Check your agent status curl https://trivaremote.cloud/api/agent/status \ -H "Authorization: Bearer YOUR_AGENT_KEY"

3. Permission Scopes

ScopeAccess
devices:readList and view devices
devices:executeRun commands on devices
files:readRead files on devices
files:writeWrite/modify files
terminalInteractive terminal access
logs:readRead system logs
network:scanNetwork scanning

4. Python Agent Example

import requests BASE = "https://trivaremote.cloud/api" KEY = "triva-your-agent-key-here" # Register as agent r = requests.post(f"{BASE}/agent/register", json={ "name": "My Python Agent", "model": "custom", "capabilities": ["devices:read", "logs:read"] }, headers={"Authorization": f"Bearer {KEY}"}) # List devices r = requests.get(f"{BASE}/devices", headers={"Authorization": f"Bearer {KEY}"}) devices = r.json()["devices"] print(f"Accessible devices: {len(devices)}")

5. Nano Agent Runtime

Every rented marketplace agent is deployed as a standalone Nano Agent binary (5.1MB, Zig). Each agent gets its own port, SQLite memory, persona, and AI model connection. Powered by Gemma 4 31B via OpenRouter.

Persona Injection

# Each agent type has a unique system prompt injected at runtime: # Security Guardian → "You are Security Guardian, an expert AI security agent..." # Maintenance Pro → "You are Maintenance Pro, an AI system administrator..." # Analytics Engine → "You are Analytics Engine, an AI data scientist..." # ... (8 total personas with domain-specific instructions)

Connect to a Deployed Nano Agent

# Each deployed agent has its own HTTP gateway: # Health: curl http://127.0.0.1:{PORT}/health # Webhook: curl -X POST http://127.0.0.1:{PORT}/webhook \ # -H "Content-Type: application/json" \ # -d '{"message":"Scan this device for vulnerabilities"}' # Ports auto-assigned from range 9600-9699