chore: snapshot working tree - pty_exited notifications + in-flight inference WIP
feat(booterm): structured pty_exited WS notifications. Plan-validated, impl-validated, code-reviewed green (contracts build clean, contracts test 29/29, booterm + web typecheck clean). wip: in-progress inference/provider refactor (agents.ts, provider.ts, new llama-providers.ts, removed llama-args-validator), plus arena, dispatcher, compaction, schema changes. openspec: pty-exit-notifications complete; x-agent-flags planned (not yet implemented).
This commit is contained in:
89
apps/control/src/services/fleet-state.ts
Normal file
89
apps/control/src/services/fleet-state.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
export interface HostConfig {
|
||||
providerId: string;
|
||||
baseUrl: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface FleetState {
|
||||
hosts: Map<string, HostState>;
|
||||
}
|
||||
|
||||
export interface HostState {
|
||||
providerId: string;
|
||||
liveness: 'connected' | 'reconnecting' | 'down';
|
||||
lastSeenAt: Date | null;
|
||||
seq: number;
|
||||
/** Host-level inflight total (the fork's SSE publishes only a total, not per-model). */
|
||||
inflightTotal: number;
|
||||
models: Map<string, ModelState>;
|
||||
}
|
||||
|
||||
export interface ModelState {
|
||||
model: string;
|
||||
state: string;
|
||||
ts: Date;
|
||||
ttlDeadline: Date | null;
|
||||
inflight: number;
|
||||
}
|
||||
|
||||
export interface SnapshotData {
|
||||
hosts: Array<{
|
||||
providerId: string;
|
||||
liveness: 'connected' | 'reconnecting' | 'down';
|
||||
lastSeenAt: string | null;
|
||||
seq: number;
|
||||
models: Array<{
|
||||
model: string;
|
||||
state: string;
|
||||
ts: string;
|
||||
ttlDeadline: string | null;
|
||||
inflight: number;
|
||||
}>;
|
||||
}>;
|
||||
requests?: Array<{
|
||||
id: number;
|
||||
providerId: string;
|
||||
ts: string;
|
||||
model: string | null;
|
||||
reqPath: string | null;
|
||||
statusCode: number | null;
|
||||
durationMs: number | null;
|
||||
}>;
|
||||
perfSamples?: Array<{
|
||||
providerId: string;
|
||||
ts: string;
|
||||
gpu: unknown;
|
||||
sys: unknown;
|
||||
}>;
|
||||
}
|
||||
|
||||
// ─── helpers for tests ──────────────────────────────────────────────────────
|
||||
|
||||
export function createFleetState(): FleetState {
|
||||
return { hosts: new Map() };
|
||||
}
|
||||
|
||||
export function ensureHostState(fleet: FleetState, providerId: string): HostState {
|
||||
let state = fleet.hosts.get(providerId);
|
||||
if (!state) {
|
||||
state = {
|
||||
providerId,
|
||||
liveness: 'down',
|
||||
lastSeenAt: null,
|
||||
seq: 0,
|
||||
inflightTotal: 0,
|
||||
models: new Map(),
|
||||
};
|
||||
fleet.hosts.set(providerId, state);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
export function stampLastSeen(state: HostState): void {
|
||||
state.lastSeenAt = new Date();
|
||||
}
|
||||
|
||||
export function incrementSeq(state: HostState): number {
|
||||
state.seq += 1;
|
||||
return state.seq;
|
||||
}
|
||||
Reference in New Issue
Block a user