Feat : Streamer watch list
This commit is contained in:
@@ -8,10 +8,11 @@ import type {
|
||||
LogLevel,
|
||||
ServerToAgent,
|
||||
ServerToDashboard,
|
||||
WatchTarget,
|
||||
} from '@stream-control/shared';
|
||||
import { emptyStatus } from '@stream-control/shared';
|
||||
import { config } from './config.ts';
|
||||
import { agentsRepo, logsRepo, type AgentRecord } from './db.ts';
|
||||
import { agentsRepo, logsRepo, targetsRepo, type AgentRecord } from './db.ts';
|
||||
|
||||
interface PendingCommand {
|
||||
resolve: (value: unknown) => void;
|
||||
@@ -190,6 +191,7 @@ class Hub {
|
||||
type: 'snapshot',
|
||||
agents: this.views(),
|
||||
logs: logsRepo.recent(200),
|
||||
targets: targetsRepo.list(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -211,6 +213,21 @@ class Hub {
|
||||
this.broadcast({ type: 'agent.removed', agentId });
|
||||
}
|
||||
|
||||
// --- Profils surveillés -------------------------------------------------
|
||||
|
||||
publishTarget(target: WatchTarget): void {
|
||||
this.broadcast({ type: 'target', target });
|
||||
}
|
||||
|
||||
publishTargetRemoval(targetId: string): void {
|
||||
this.broadcast({ type: 'target.removed', targetId });
|
||||
}
|
||||
|
||||
/** Passage en direct : le dashboard en fait une notification. */
|
||||
publishTargetLive(target: WatchTarget): void {
|
||||
this.broadcast({ type: 'target.live', target });
|
||||
}
|
||||
|
||||
/** Journalise un évènement : persistance + diffusion temps réel. */
|
||||
log(agentId: string | null, level: LogLevel, message: string, ts = Date.now()): LogEntry {
|
||||
const entry = logsRepo.append(agentId, level, message, ts);
|
||||
|
||||
Reference in New Issue
Block a user