Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: peer apps display + remote agent streaming on Instances page

Adam Eivy6a78f9675af8
diff --git a/.changelog/v0.25.x.md b/.changelog/v0.25.x.md
new file mode 100644
index 0000000000..5a85ed5e5f
--- /dev/null
+++ b/.changelog/v0.25.x.md
@@ -0,0 +1,23 @@
+# Release v0.25.x - Changelog
+
+Released: YYYY-MM-DD
+
+## Overview
+
+Peer apps display and remote agent streaming on the Instances page — see what's running on federated peers at a glance.
+
+## Features
+
+### Peer apps + remote agent streaming on Instances page
+- **Remote apps display** — each peer card now shows the peer's apps at a glance (icon, name, port, status badge) fetched during the 30s probe cycle
+- **Live remote agent cards** — running CoS agents on peers stream their output in real-time via Socket.IO relay, using the same AgentCard component as the local CoS page
+- **Socket.IO peer relay** — local server connects as a Socket.IO client to each online peer, subscribes to agent events, and forwards them to the Instances page
+- **AgentCard remote mode** — `remote` prop disables local-only features (process stats polling, full output fetch, feedback, kill/delete buttons) and shows a peer name badge
+
+## Improvements
+
+## Fixes
+
+## Removed
+
+- **QueryPanel** — the JSON query panel on peer cards is replaced by the richer apps list and agent streaming views
diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsx
index b1764c0f22..da5ad6ff00 100644
--- a/client/src/components/cos/tabs/AgentCard.jsx
+++ b/client/src/components/cos/tabs/AgentCard.jsx
@@ -91,7 +91,7 @@ function OutputBlocks({ output }) {
);
}
-export default function AgentCard({ agent, onKill, onDelete, onResume, completed, liveOutput, durations, onFeedbackChange }) {
+export default function AgentCard({ agent, onKill, onDelete, onResume, completed, liveOutput, durations, onFeedbackChange, remote, peerName }) {
const [expanded, setExpanded] = useState(false);
const [now, setNow] = useState(Date.now());
const [fullOutput, setFullOutput] = useState(null);
@@ -142,9 +142,9 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
return () => clearInterval(interval);
}, [completed]);
- // Fetch process stats for running agents
+ // Fetch process stats for running agents (skip for remote peers)
useEffect(() => {
- if (completed) return;
+ if (completed || remote) return;
const fetchStats = async () => {
const stats = await api.getCosAgentStats(agent.id).catch(() => null);
@@ -163,9 +163,9 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
setKilling(false);
};
- // Fetch full output when expanded for completed agents
+ // Fetch full output when expanded for completed agents (skip for remote)
useEffect(() => {
- if (expanded && completed && !fullOutput && !loadingOutput) {
+ if (expanded && completed && !fullOutput && !loadingOutput && !remote) {
setLoadingOutput(true);
api.getCosAgent(agent.id)
.then(data => {
@@ -274,6 +274,11 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
<div className="flex items-center gap-2 flex-wrap min-w-0 flex-1">
<Cpu size={16} aria-hidden="true" className={`flex-shrink-0 ${completed ? 'text-gray-500' : 'text-port-accent animate-pulse'}`} />
<span className="font-mono text-sm text-gray-400 truncate">{agent.id}</span>
+ {remote && peerName && (
+ <span className="px-1.5 py-0.5 text-xs bg-port-accent/20 text-port-accent rounded flex-shrink-0" title={`Remote agent on ${peerName}`}>
+ {peerName}
+ </span>
+ )}
{agent.metadata?.taskApp && (agent.metadata.taskAppName || agent.metadata.workspaceName) && !/^[0-9a-f]{8}-[0-9a-f]{4}-/.test(agent.metadata.taskAppName || agent.metadata.workspaceName) && (
<span className="px-1.5 py-0.5 text-xs bg-cyan-500/20 text-cyan-400 rounded flex-shrink-0" title={agent.metadata.workspacePath || agent.metadata.taskApp}>
{agent.metadata.taskAppName || agent.metadata.workspaceName}
@@ -510,8 +515,8 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
</div>
)}
- {/* Feedback section - shown for completed non-system agents */}
- {completed && !isSystemAgent && (
+ {/* Feedback section - shown for completed non-system local agents */}
+ {completed && !isSystemAgent && !remote && (
<div className="mt-3 pt-3 border-t border-port-border/50">
<div className="flex items-center gap-3 flex-wrap">
<span className="text-xs text-gray-500">Was this helpful?</span>
diff --git a/client/src/components/instances/PeerAgentsSection.jsx b/client/src/components/instances/PeerAgentsSection.jsx
new file mode 100644
index 0000000000..3256025cc4
--- /dev/null
+++ b/client/src/components/instances/PeerAgentsSection.jsx
@@ -0,0 +1,93 @@
+import { useState, useEffect, useCallback } from 'react';
+import socket from '../../services/socket';
+import AgentCard from '../cos/tabs/AgentCard';
+
+const MAX_OUTPUT_LINES = 200;
+
+export default function PeerAgentsSection({ peerId, peerName }) {
+ const [agents, setAgents] = useState([]);
+ const [liveOutputs, setLiveOutputs] = useState({});
+
+ // Handle agents list update
+ const handleAgentsUpdated = useCallback((data) => {
+ if (data.peerId !== peerId) return;
+ setAgents(data.agents || []);
+ }, [peerId]);
+
+ // Handle agent spawned
+ const handleAgentSpawned = useCallback((data) => {
+ if (data.peerId !== peerId) return;
+ setAgents(prev => {
+ if (prev.some(a => a.id === data.agent.id)) return prev;
+ return [...prev, data.agent];
+ });
+ }, [peerId]);
+
+ // Handle agent updated
+ const handleAgentUpdated = useCallback((data) => {
+ if (data.peerId !== peerId) return;
+ setAgents(prev => prev.map(a => a.id === data.agent.id ? { ...a, ...data.agent } : a));
+ }, [peerId]);
+
+ // Handle agent output (streaming)
+ const handleAgentOutput = useCallback((data) => {
+ if (data.peerId !== peerId) return;
+ const { agentId, line, timestamp } = data;
+ setLiveOutputs(prev => {
+ const existing = prev[agentId] || [];
+ const updated = [...existing, { line, timestamp }];
+ // Cap to prevent unbounded growth
+ if (updated.length > MAX_OUTPUT_LINES) {
+ return { ...prev, [agentId]: updated.slice(-MAX_OUTPUT_LINES) };
+ }
+ return { ...prev, [agentId]: updated };
+ });
+ }, [peerId]);
+
+ // Handle agent completed
+ const handleAgentCompleted = useCallback((data) => {
+ if (data.peerId !== peerId) return;
+ setAgents(prev => prev.filter(a => a.id !== data.agent.id));
+ setLiveOutputs(prev => {
+ const next = { ...prev };
+ delete next[data.agent.id];
+ return next;
+ });
+ }, [peerId]);
+
+ useEffect(() => {
+ socket.on('instances:peer:agents:updated', handleAgentsUpdated);
+ socket.on('instances:peer:agent:spawned', handleAgentSpawned);
+ socket.on('instances:peer:agent:updated', handleAgentUpdated);
+ socket.on('instances:peer:agent:output', handleAgentOutput);
+ socket.on('instances:peer:agent:completed', handleAgentCompleted);
+
+ return () => {
+ socket.off('instances:peer:agents:updated', handleAgentsUpdated);
+ socket.off('instances:peer:agent:spawned', handleAgentSpawned);
+ socket.off('instances:peer:agent:updated', handleAgentUpdated);
+ socket.off('instances:peer:agent:output', handleAgentOutput);
+ socket.off('instances:peer:agent:completed', handleAgentCompleted);
+ };
+ }, [handleAgentsUpdated, handleAgentSpawned, handleAgentUpdated, handleAgentOutput, handleAgentCompleted]);
+
+ if (agents.length === 0) return null;
+
+ return (
+ <div className="mt-3 border-t border-port-border pt-3">
+ <div className="text-xs text-gray-500 mb-2">Active Agents ({agents.length})</div>
+ <div className="space-y-2">
+ {agents.map(agent => (
+ <AgentCard
+ key={agent.id}
+ agent={agent}
+ completed={false}
+ liveOutput={liveOutputs[agent.id] || []}
+ remote
+ peerName={peerName}
+ />
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/components/instances/PeerAppsList.jsx b/client/src/components/instances/PeerAppsList.jsx
new file mode 100644
index 0000000000..2e3416abdd
--- /dev/null
+++ b/client/src/components/instances/PeerAppsList.jsx
@@ -0,0 +1,36 @@
+import AppIcon from '../AppIcon';
+import StatusBadge from '../StatusBadge';
+
+export default function PeerAppsList({ apps, peerAddress }) {
+ if (!apps || apps.length === 0) return null;
+
+ return (
+ <div className="mt-3 border-t border-port-border pt-3">
+ <div className="text-xs text-gray-500 mb-1.5">Apps ({apps.length})</div>
+ <div className="space-y-1">
+ {apps.map(app => (
+ <div key={app.id} className="flex items-center gap-2 text-xs">
+ <AppIcon icon={app.icon || 'package'} size={14} className="text-gray-400 flex-shrink-0" />
+ {app.uiPort && app.overallStatus === 'online' ? (
+ <a
+ href={`http://${peerAddress}:${app.uiPort}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-port-accent hover:underline truncate"
+ title={`Open ${app.name} on ${peerAddress}:${app.uiPort}`}
+ >
+ {app.name}
+ </a>
+ ) : (
+ <span className="text-gray-300 truncate">{app.name}</span>
+ )}
+ {app.apiPort && (
+ <span className="text-gray-600 font-mono flex-shrink-0">:{app.apiPort}</span>
+ )}
+ <StatusBadge status={app.overallStatus || 'unknown'} size="sm" />
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/pages/Instances.jsx b/client/src/pages/Instances.jsx
index 1bd14df44e..3f72b12d5d 100644
--- a/client/src/pages/Instances.jsx
+++ b/client/src/pages/Instances.jsx
@@ -1,16 +1,18 @@
import { useState, useEffect, useCallback } from 'react';
import {
Network, Plus, Trash2, RefreshCw, Edit3, Check, X,
- Wifi, WifiOff, CircleDot, ChevronDown, ChevronRight,
- Cpu, HardDrive, Activity, Bot, MonitorSmartphone, Search,
+ Wifi, WifiOff, CircleDot,
+ Cpu, HardDrive, Activity, Bot, MonitorSmartphone,
ArrowUpRight, ArrowDownLeft, ArrowLeftRight
} from 'lucide-react';
import toast from 'react-hot-toast';
import socket from '../services/socket';
import {
getInstances, updateSelfInstance, addPeer, updatePeer,
- removePeer, connectPeer, probePeer, queryPeer
+ removePeer, connectPeer, probePeer
} from '../services/api';
+import PeerAppsList from '../components/instances/PeerAppsList';
+import PeerAgentsSection from '../components/instances/PeerAgentsSection';
const STATUS_COLORS = {
online: 'text-port-success',
@@ -24,13 +26,6 @@ const STATUS_ICONS = {
unknown: CircleDot
};
-const QUERY_PRESETS = [
- { label: 'Health', path: '/api/health/system' },
- { label: 'Apps', path: '/api/apps' },
- { label: 'CoS Status', path: '/api/cos/status' },
- { label: 'Processes', path: '/api/health' }
-];
-
function formatBytes(bytes) {
if (!bytes) return '—';
const gb = bytes / (1024 * 1024 * 1024);
@@ -203,76 +198,6 @@ function AddPeerForm({ onAdd }) {
);
}
-function QueryPanel({ peerId }) {
- const [expanded, setExpanded] = useState(false);
- const [selectedPreset, setSelectedPreset] = useState(0);
- const [customPath, setCustomPath] = useState('');
- const [result, setResult] = useState(null);
- const [loading, setLoading] = useState(false);
-
- const runQuery = async () => {
- const path = customPath.trim() || QUERY_PRESETS[selectedPreset].path;
- if (!path.startsWith('/api/')) {
- toast.error('Path must start with /api/');
- return;
- }
- setLoading(true);
- setResult(null);
- const data = await queryPeer(peerId, path).catch(err => ({ _error: err.message }));
- setResult(data);
- setLoading(false);
- };
-
- return (
- <div className="mt-3 border-t border-port-border pt-3">
- <button
- onClick={() => setExpanded(!expanded)}
- className="flex items-center gap-1.5 text-xs text-gray-500 hover:text-white transition-colors"
- >
- <Search size={12} />
- <span>Query</span>
- {expanded ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
- </button>
- {expanded && (
- <div className="mt-2 space-y-2">
- <div className="flex gap-2">
- <select
- value={selectedPreset}
- onChange={e => { setSelectedPreset(Number(e.target.value)); setCustomPath(''); }}
- className="bg-port-bg border border-port-border rounded px-2 py-1 text-xs text-white focus:outline-none focus:border-port-accent"
- >
- {QUERY_PRESETS.map((p, i) => (
- <option key={i} value={i}>{p.label}</option>
- ))}
- </select>
- <input
- value={customPath}
- onChange={e => setCustomPath(e.target.value)}
- placeholder="or custom /api/..."
- className="flex-1 bg-port-bg border border-port-border rounded px-2 py-1 text-xs text-white placeholder-gray-600 focus:outline-none focus:border-port-accent"
- />
- <button
- onClick={runQuery}
- disabled={loading}
- className="bg-port-accent/20 hover:bg-port-accent/30 text-port-accent px-2 py-1 rounded text-xs transition-colors disabled:opacity-50"
- >
- {loading ? '...' : 'Run'}
- </button>
- </div>
- {result && (
- <pre className="bg-port-bg rounded p-2 text-xs text-gray-300 overflow-auto max-h-64 whitespace-pre-wrap">
- {result._error
- ? <span className="text-port-error">{result._error}</span>
- : JSON.stringify(result, null, 2)
- }
- </pre>
- )}
- </div>
- )}
- </div>
- );
-}
-
function DirectionBadge({ directions = [] }) {
const hasInbound = directions.includes('inbound');
const hasOutbound = directions.includes('outbound');
@@ -428,7 +353,10 @@ function PeerCard({ peer, onRefresh }) {
Last seen: {timeAgo(peer.lastSeen)}
</div>
- <QueryPanel peerId={peer.id} />
+ <PeerAppsList apps={peer.lastApps} peerAddress={peer.address} />
+ {peer.status === 'online' && (
+ <PeerAgentsSection peerId={peer.id} peerName={peer.name} />
+ )}
</div>
);
}
diff --git a/package-lock.json b/package-lock.json
index 7afb24f0d2..8e08db0c5c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "0.24.0",
+ "version": "0.25.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "0.24.0",
+ "version": "0.25.0",
"license": "MIT",
"workspaces": [
"packages/*",
diff --git a/package.json b/package.json
index 35d636c021..c067dc0226 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "0.24.0",
+ "version": "0.25.0",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/services/instances.js b/server/services/instances.js
index 89acc3d700..95662368e2 100644
--- a/server/services/instances.js
+++ b/server/services/instances.js
@@ -11,6 +11,7 @@ import crypto from 'crypto';
import { dataPath, readJSONFile, ensureDir, PATHS } from '../lib/fileUtils.js';
import { createMutex } from '../lib/asyncMutex.js';
import { instanceEvents } from './instanceEvents.js';
+import { connectToPeer, disconnectFromPeer } from './peerSocketRelay.js';
const INSTANCES_FILE = dataPath('instances.json');
const PROBE_TIMEOUT_MS = 5000;
@@ -110,6 +111,7 @@ export async function addPeer({ address, port = 5554, name }) {
}
export async function removePeer(id) {
+ disconnectFromPeer(id);
return withData(async (data) => {
const idx = data.peers.findIndex(p => p.id === id);
if (idx === -1) return null;
@@ -121,6 +123,7 @@ export async function removePeer(id) {
}
export async function updatePeer(id, updates) {
+ if (updates.enabled === false) disconnectFromPeer(id);
return withData(async (data) => {
const peer = data.peers.find(p => p.id === id);
if (!peer) return null;
@@ -138,7 +141,7 @@ export async function probePeer(peer) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), PROBE_TIMEOUT_MS);
- let status, lastHealth, lastSeen, remoteInstanceId;
+ let status, lastHealth, lastSeen, remoteInstanceId, remoteApps;
try {
const res = await fetch(url, { signal: controller.signal });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
@@ -147,6 +150,18 @@ export async function probePeer(peer) {
lastHealth = json;
lastSeen = new Date().toISOString();
remoteInstanceId = json.instanceId ?? null;
+
+ // Fetch apps from the peer (piggybacks on probe cycle)
+ const appsUrl = `http://${peer.address}:${peer.port}/api/apps`;
+ const appsRes = await fetch(appsUrl, { signal: controller.signal }).catch(() => null);
+ if (appsRes?.ok) {
+ const appsJson = await appsRes.json().catch(() => null);
+ const appsList = Array.isArray(appsJson) ? appsJson : appsJson?.apps;
+ remoteApps = appsList?.map(a => ({
+ id: a.id, name: a.name, icon: a.icon,
+ overallStatus: a.overallStatus, uiPort: a.uiPort, apiPort: a.apiPort, type: a.type
+ })) ?? null;
+ }
} catch {
status = 'offline';
lastHealth = peer.lastHealth; // preserve last known
@@ -161,10 +176,18 @@ export async function probePeer(peer) {
entry.status = status;
entry.lastSeen = lastSeen;
entry.lastHealth = lastHealth;
+ entry.lastApps = remoteApps ?? entry.lastApps ?? null;
if (remoteInstanceId) entry.instanceId = remoteInstanceId;
return entry;
});
+ // Manage peer socket relay based on status
+ if (status === 'online') {
+ connectToPeer(peer);
+ } else {
+ disconnectFromPeer(peer.id);
+ }
+
// Announce ourselves on successful probe (fire-and-forget)
if (status === 'online') {
announceSelf(peer.address, peer.port);
diff --git a/server/services/peerSocketRelay.js b/server/services/peerSocketRelay.js
new file mode 100644
index 0000000000..6a24f02e8a
--- /dev/null
+++ b/server/services/peerSocketRelay.js
@@ -0,0 +1,152 @@
+/**
+ * Peer Socket Relay
+ *
+ * Connects as a Socket.IO client to each online peer, subscribes to cos:agent:*
+ * events, and re-emits them locally through instanceEvents for the client UI.
+ */
+
+import { io } from 'socket.io-client';
+import { instanceEvents } from './instanceEvents.js';
+
+// Map<peerId, { socket, agents: Map<agentId, agent>, peer }>
+const peerConnections = new Map();
+
+const CONNECT_TIMEOUT_MS = 5000;
+
+/**
+ * Connect to a peer's Socket.IO server and subscribe to agent events
+ */
+export function connectToPeer(peer) {
+ if (peerConnections.has(peer.id)) return;
+
+ const url = `http://${peer.address}:${peer.port}`;
+ const socket = io(url, {
+ reconnection: true,
+ reconnectionAttempts: 5,
+ reconnectionDelay: 5000,
+ timeout: CONNECT_TIMEOUT_MS
+ });
+
+ const conn = {
+ socket,
+ agents: new Map(),
+ peer: { id: peer.id, name: peer.name, address: peer.address, port: peer.port }
+ };
+
+ peerConnections.set(peer.id, conn);
+
+ socket.on('connect', () => {
+ console.log(`🔗 Peer relay connected: ${peer.name} (${peer.address}:${peer.port})`);
+ socket.emit('cos:subscribe');
+
+ // Fetch initial agent state via HTTP
+ fetchPeerAgents(conn);
+ });
+
+ socket.on('disconnect', () => {
+ console.log(`🔗 Peer relay disconnected: ${peer.name}`);
+ conn.agents.clear();
+ instanceEvents.emit('peer:agents:updated', { peerId: peer.id, agents: [] });
+ });
+
+ // Agent spawned
+ socket.on('cos:agent:spawned', (data) => {
+ const agent = data.agent || data;
+ conn.agents.set(agent.id, agent);
+ instanceEvents.emit('peer:agent:spawned', { peerId: peer.id, agent });
+ instanceEvents.emit('peer:agents:updated', {
+ peerId: peer.id,
+ agents: Array.from(conn.agents.values())
+ });
+ });
+
+ // Agent updated
+ socket.on('cos:agent:updated', (data) => {
+ const agent = data.agent || data;
+ const existing = conn.agents.get(agent.id);
+ if (existing) {
+ Object.assign(existing, agent);
+ } else {
+ conn.agents.set(agent.id, agent);
+ }
+ instanceEvents.emit('peer:agent:updated', { peerId: peer.id, agent: conn.agents.get(agent.id) });
+ });
+
+ // Agent output (streaming)
+ socket.on('cos:agent:output', (data) => {
+ instanceEvents.emit('peer:agent:output', { peerId: peer.id, ...data });
+ });
+
+ // Agent completed
+ socket.on('cos:agent:completed', (data) => {
+ const agent = data.agent || data;
+ conn.agents.delete(agent.id);
+ instanceEvents.emit('peer:agent:completed', { peerId: peer.id, agent });
+ instanceEvents.emit('peer:agents:updated', {
+ peerId: peer.id,
+ agents: Array.from(conn.agents.values())
+ });
+ });
+}
+
+/**
+ * Fetch current agents from peer via HTTP and populate initial state
+ */
+async function fetchPeerAgents(conn) {
+ const { peer } = conn;
+ const url = `http://${peer.address}:${peer.port}/api/cos/agents`;
+ const controller = new AbortController();
+ const timeout = setTimeout(() => controller.abort(), CONNECT_TIMEOUT_MS);
+
+ try {
+ const res = await fetch(url, { signal: controller.signal });
+ if (!res.ok) return;
+ const data = await res.json();
+ const agents = data.running || data.agents || [];
+ conn.agents.clear();
+ for (const agent of agents) {
+ conn.agents.set(agent.id, agent);
+ }
+ instanceEvents.emit('peer:agents:updated', {
+ peerId: peer.id,
+ agents: Array.from(conn.agents.values())
+ });
+ console.log(`🔗 Peer ${peer.name}: ${agents.length} active agent(s)`);
+ } catch {
+ // Silent — agents will populate via socket events
+ } finally {
+ clearTimeout(timeout);
+ }
+}
+
+/**
+ * Disconnect from a peer and clean up
+ */
+export function disconnectFromPeer(peerId) {
+ const conn = peerConnections.get(peerId);
+ if (!conn) return;
+
+ conn.socket.disconnect();
+ conn.agents.clear();
+ peerConnections.delete(peerId);
+ instanceEvents.emit('peer:agents:updated', { peerId, agents: [] });
+ console.log(`🔗 Peer relay cleaned up: ${conn.peer.name}`);
+}
+
+/**
+ * Get current agent snapshot for a peer
+ */
+export function getPeerAgents(peerId) {
+ const conn = peerConnections.get(peerId);
+ if (!conn) return [];
+ return Array.from(conn.agents.values());
+}
+
+/**
+ * Disconnect all peer relays (for shutdown)
+ */
+export function disconnectAll() {
+ for (const [peerId] of peerConnections) {
+ disconnectFromPeer(peerId);
+ }
+}
diff --git a/server/services/socket.js b/server/services/socket.js
index 525e9f3ca7..93105c1805 100644
--- a/server/services/socket.js
+++ b/server/services/socket.js
@@ -350,6 +350,9 @@ export function initSocket(io) {
// Set up instance event forwarding
setupInstanceEventForwarding();
+
+ // Set up peer agent event forwarding
+ setupPeerAgentEventForwarding();
}
function cleanupStream(socketId) {
@@ -530,3 +533,12 @@ function broadcastToInstances(event, data) {
function setupInstanceEventForwarding() {
instanceEvents.on('peers:updated', (data) => broadcastToInstances('instances:peers:updated', data));
}
+
+// Set up peer agent event forwarding (remote agent streaming)
+function setupPeerAgentEventForwarding() {
+ instanceEvents.on('peer:agents:updated', (data) => broadcastToInstances('instances:peer:agents:updated', data));
+ instanceEvents.on('peer:agent:spawned', (data) => broadcastToInstances('instances:peer:agent:spawned', data));
+ instanceEvents.on('peer:agent:updated', (data) => broadcastToInstances('instances:peer:agent:updated', data));
+ instanceEvents.on('peer:agent:output', (data) => broadcastToInstances('instances:peer:agent:output', data));
+ instanceEvents.on('peer:agent:completed', (data) => broadcastToInstances('instances:peer:agent:completed', data));
+}