feat(electrobun): multi-machine relay + OTEL telemetry

Multi-machine relay:
- relay-client.ts: WebSocket client for agor-relay with token auth,
  exponential backoff (1s-30s), TCP probe, heartbeat (15s ping)
- machines-store.svelte.ts: remote machine state tracking
- RemoteMachinesSettings.svelte: machine list, add/connect/disconnect UI
- 7 RPC types (remote.connect/disconnect/list/send/status + events)

Telemetry:
- telemetry.ts: OTEL spans + OTLP/HTTP export to Tempo,
  controlled by AGOR_OTLP_ENDPOINT env var
- telemetry-bridge.ts: tel.info/warn/error frontend convenience API
- telemetry.log RPC for frontend→Bun tracing
This commit is contained in:
Hibryda 2026-03-22 01:46:03 +01:00
parent ec30c69c3e
commit 88206205fe
11 changed files with 1458 additions and 15 deletions

View file

@ -482,6 +482,78 @@ export type PtyRPCRequests = {
params: { pluginId: string; filePath: string };
response: { ok: boolean; content: string; error?: string };
};
// ── Remote machine (relay) RPC ────────────────────────────────────────────
/** Connect to an agor-relay instance. */
"remote.connect": {
params: { url: string; token: string; label?: string };
response: { ok: boolean; machineId?: string; error?: string };
};
/** Disconnect from a relay instance. */
"remote.disconnect": {
params: { machineId: string };
response: { ok: boolean; error?: string };
};
/** List all known remote machines with connection status. */
"remote.list": {
params: Record<string, never>;
response: {
machines: Array<{
machineId: string;
label: string;
url: string;
status: "connecting" | "connected" | "disconnected" | "error";
latencyMs: number | null;
}>;
};
};
/** Send a command to a connected relay. */
"remote.send": {
params: { machineId: string; command: string; payload: Record<string, unknown> };
response: { ok: boolean; error?: string };
};
/** Get the status of a specific machine. */
"remote.status": {
params: { machineId: string };
response: {
status: "connecting" | "connected" | "disconnected" | "error";
latencyMs: number | null;
error?: string;
};
};
// ── Telemetry RPC ─────────────────────────────────────────────────────────
/** Log a telemetry event from the frontend. */
"telemetry.log": {
params: {
level: "info" | "warn" | "error";
message: string;
attributes?: Record<string, string | number | boolean>;
};
response: { ok: boolean };
};
// ── Updater RPC ──────────────────────────────────────────────────────────
/** Check GitHub Releases for a newer version. */
"updater.check": {
params: Record<string, never>;
response: {
available: boolean;
version: string;
downloadUrl: string;
releaseNotes: string;
checkedAt: number;
error?: string;
};
};
/** Get the current app version and last check timestamp. */
"updater.getVersion": {
params: Record<string, never>;
response: { version: string; lastCheck: number };
};
};
// ── Messages (Bun → WebView, fire-and-forget) ────────────────────────────────
@ -518,6 +590,22 @@ export type PtyRPCMessages = {
inputTokens: number;
outputTokens: number;
};
// ── Remote machine events (Bun → WebView) ────────────────────────────────
/** Remote relay event forwarded from a connected machine. */
"remote.event": {
machineId: string;
eventType: string;
sessionId?: string;
payload?: unknown;
};
/** Remote machine connection status change. */
"remote.statusChange": {
machineId: string;
status: "connecting" | "connected" | "disconnected" | "error";
error?: string;
};
};
// ── Combined schema ───────────────────────────────────────────────────────────