Feat : Control streamer
Some checks failed
release / build (push) Successful in 27s
release / verify-windows (push) Failing after 56s

This commit is contained in:
jeanotx32
2026-08-11 21:11:04 +02:00
parent 6916ff4be3
commit 37e0c73ab5
10 changed files with 386 additions and 11 deletions

View File

@@ -7,12 +7,15 @@ import type {
ObsSettings,
Platform,
StreamState,
BrowserSettings,
WatchSettings,
WatchTarget,
} from '@stream-control/shared';
import {
DEFAULT_BROWSER_SETTINGS,
DEFAULT_OBS_SETTINGS,
DEFAULT_WATCH_SETTINGS,
normalizeBrowserSettings,
normalizeWatchSettings,
safeJsonParse,
stripchatProfileUrl,
@@ -86,6 +89,7 @@ function addColumnIfMissing(table: string, column: string, definition: string):
// Surveillance du stream source : stockée en JSON, le schéma évolue plus vite
// que la table (nouveaux fournisseurs, nouveaux statuts).
addColumnIfMissing('agents', 'watch_json', 'TEXT');
addColumnIfMissing('agents', 'browser_json', 'TEXT');
// Enrichissement des profils surveillés : photo et historique de diffusion.
addColumnIfMissing('watch_targets', 'avatar_url', 'TEXT');
@@ -105,6 +109,7 @@ export interface AgentRow {
obs_password: string;
auto_connect: number;
watch_json: string | null;
browser_json: string | null;
notes: string | null;
created_at: number;
last_seen_at: number | null;
@@ -120,6 +125,7 @@ export interface AgentRecord {
obs: ObsSettings;
autoConnectObs: boolean;
watch: WatchSettings;
browser: BrowserSettings;
notes: string | null;
createdAt: number;
lastSeenAt: number | null;
@@ -142,6 +148,9 @@ function toRecord(row: AgentRow): AgentRecord {
watch: normalizeWatchSettings(
row.watch_json ? safeJsonParse<WatchSettings>(row.watch_json) : DEFAULT_WATCH_SETTINGS,
),
browser: normalizeBrowserSettings(
row.browser_json ? safeJsonParse<BrowserSettings>(row.browser_json) : DEFAULT_BROWSER_SETTINGS,
),
notes: row.notes,
createdAt: Number(row.created_at),
lastSeenAt: row.last_seen_at === null ? null : Number(row.last_seen_at),
@@ -155,8 +164,8 @@ const stmts = {
insertAgent: db.prepare(`
INSERT INTO agents (id, name, hostname, platform, agent_version, token_hash,
obs_host, obs_port, obs_password, auto_connect, watch_json,
notes, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
browser_json, notes, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`),
updateIdentity: db.prepare(`
UPDATE agents SET hostname = ?, platform = ?, agent_version = ?, last_seen_at = ?
@@ -164,7 +173,7 @@ const stmts = {
`),
updateSettings: db.prepare(`
UPDATE agents SET name = ?, obs_host = ?, obs_port = ?, obs_password = ?,
auto_connect = ?, watch_json = ?, notes = ?
auto_connect = ?, watch_json = ?, browser_json = ?, notes = ?
WHERE id = ?
`),
touchAgent: db.prepare('UPDATE agents SET last_seen_at = ? WHERE id = ?'),
@@ -207,6 +216,7 @@ export const agentsRepo = {
obs?: Partial<ObsSettings>;
autoConnectObs?: boolean;
watch?: WatchSettings;
browser?: BrowserSettings;
notes?: string | null;
}): AgentRecord {
const obs = { ...DEFAULT_OBS_SETTINGS, ...input.obs };
@@ -222,6 +232,7 @@ export const agentsRepo = {
obs.password,
input.autoConnectObs === false ? 0 : 1,
JSON.stringify(normalizeWatchSettings(input.watch ?? DEFAULT_WATCH_SETTINGS)),
JSON.stringify(normalizeBrowserSettings(input.browser ?? DEFAULT_BROWSER_SETTINGS)),
input.notes ?? null,
Date.now(),
);
@@ -250,6 +261,7 @@ export const agentsRepo = {
obs: ObsSettings;
autoConnectObs: boolean;
watch: WatchSettings;
browser: BrowserSettings;
notes: string | null;
},
): void {
@@ -260,6 +272,7 @@ export const agentsRepo = {
settings.obs.password,
settings.autoConnectObs ? 1 : 0,
JSON.stringify(normalizeWatchSettings(settings.watch)),
JSON.stringify(normalizeBrowserSettings(settings.browser)),
settings.notes,
id,
);