Files
AetherForge/server/web/src/context/WebSocketContext.tsx
drjones 0f9e04f5f6 Add universal forge, fusion disguise, remote deploy, and stability fixes.
Ship cross-platform spread kits and fusion ZIPs with per-OS launchers, one-liner dropper endpoints, Windows file disguise, and a large batch of wiring/bug fixes so agents connect reliably across a LAN test fleet.
2026-05-29 20:53:13 -07:00

41 lines
1.2 KiB
TypeScript

import React, { createContext, useContext } from 'react';
import type { Agent, Share, FleetAlert, PoolStatus, AIActivityEntry, WSMessage } from '../types';
import type { WSCommandResult } from '../types/ws';
/**
* WSCommandResult with a monotonic sequence number attached by the provider.
* Consumers should track `_seq` instead of array index to avoid the ring-buffer
* drop bug that occurs when `.slice(-N)` trims the array but the stored index
* remains >= N.
*/
export type SeqCommandResult = WSCommandResult & { _seq: number };
export interface WebSocketContextValue {
isConnected: boolean;
agents: Agent[];
recentShares: Share[];
fleetAlerts: FleetAlert[];
poolStatus: PoolStatus[];
aiActivity: AIActivityEntry[];
agentLogs: Record<string, string>;
commandResults: SeqCommandResult[];
/** @deprecated Use commandResults instead. */
latestMessage: WSMessage | null;
}
export const WebSocketContext = createContext<WebSocketContextValue>({
isConnected: false,
agents: [],
recentShares: [],
fleetAlerts: [],
poolStatus: [],
aiActivity: [],
agentLogs: {},
commandResults: [],
latestMessage: null,
});
export function useWebSocketContext(): WebSocketContextValue {
return useContext(WebSocketContext);
}