/** * Wire protocol for the control link to the master dashboard. * * Mirror of the block at the bottom of `autotrader-master/types.ts`, which is * the source of truth. The two repos deploy independently, so change both * together — and only ever by adding, since an instance and a master can be * running different versions of this file at the same time. */ export interface FirmStats { firm: string; totalAccounts: number; accountsTraded: number; inTrade: number; } export interface SchedulerState { running: boolean; action: 'Buy' | 'Sell' | 'Auto'; symbol: string; lastRun: string | null; intervalSeconds: number; stopAfterAll?: boolean; } export interface AutomationSummary { key: string; label: string; firm: string; inputs: { id: string; label: string; min: number; max: number; default: number }[]; } export interface InstanceCapabilities { symbols: string[]; automations: AutomationSummary[]; runnerOnline: boolean; } export type Command = | { kind: 'trade'; action: 'Buy' | 'Sell' | 'Auto'; symbol: string; stopAfterAll?: boolean } | { kind: 'stop-trading' } | { kind: 'autobuyer-run'; automationId: string; inputs?: Record } | { kind: 'report-now' }; export type MasterMessage = | { type: 'welcome' } | { type: 'command'; id: string; command: Command }; export type InstanceMessage = | { type: 'hello'; instance: string; capabilities: InstanceCapabilities } | { type: 'report'; firms: FirmStats[]; scheduler: SchedulerState; capabilities?: InstanceCapabilities } | { type: 'ack'; id: string; ok: boolean; result?: unknown; error?: string };