garage44.eu/jeroen/midas

logclone: git clone https://garage44.eu/jeroen/midas.git

.. /web/src/lib/types.ts

raw

/** What the hub answers, as far as the page reads it (`src/hub.rs`, `src/registry.rs`). */

import type {DeployRun} from '@/lib/stream'

export interface Reading {
    at: number
    load?: number | null
    /** CPUs the node may use; absent from nodes older than 2026-10-20. */
    cpus?: number | null
    mem_used?: number | null
    mem_max?: number | null
    disk_free?: number | null
    /** The work volume's size; absent from nodes older than 2026-10-20. */
    disk_total?: number | null
    target_bytes?: number | null
    sessions?: number | null
    version?: string | null
    /** What the machine's owner set the node up from (`setup::recipe`); absent from older nodes. */
    recipe?: string | null
    head?: string | null
    warm?: string | null
    warm_age_s?: number | null
    oom_kills?: number | null
    bot?: {running?: boolean; command?: string; since?: number} | null
}

export interface Node {
    id: string
    machine: string
    address: string
    gpu: boolean
    renderer?: string
    enabled: boolean
    drained?: {why: string; by: string; at: number}
    /** Its VM shut down while nobody used it (sleep.rs). */
    asleep?: {since: number}
    reading: Reading | null
}

export interface Lease {
    owner: string
    branch?: string | null
    purpose?: string | null
    intent?: string | null
    intent_until?: number | null
    yield?: boolean
    claimed_at: number
    renewed_at: number
    last_command?: string | null
    mode?: 'build' | 'bot'
}

export interface Waiter {
    since: number
    machine?: string
    node?: string | null
    purpose?: string
}

export interface LandingTurn {
    owner: string
    branch?: string | null
    granted_at: number
    renewed_at: number
    step?: string
}

export interface WorkspaceState {
    /** The hub itself: where it listens on the tunnel, its build, and its state disk's free bytes. */
    hub?: {listen: string; version: string; disk_free?: number | null}
    nodes: Node[]
    leases: Record<string, Lease>
    waiters: Record<string, Waiter>
    landing: {
        holder: LandingTurn | null
        queue: Record<string, {since: number; branch?: string | null}>
        pushed?: Record<string, {sha: string; at: number}>
    }
}

export interface Build {
    ts: string
    node: string
    machine: string | null
    actor: string
    shape: string
    seconds: number | null
    exit: number | null
    first_build_in_lease: boolean
}

export interface Take {
    ts: string
    actor: string
    waited_s: number
    gave_up?: boolean
}

export interface PoolSample {
    ts: string
    in_pool?: number
}

export interface Session {
    actor: string
    branch: string | null
    start: number
    end: number
    span_s: number
    builds: number
    failed_builds: number
    build_s: number
    takes: number
    waited_s: number
    nodes: string[]
    landing_attempts: number
    outcome: string | null
    landed_at: number | null
    gate_s: number | null
    land_wait_s: number | null
    time_to_land_s: number | null
    sha: string | null
    /** `hook`: a session hook said when it began; `workspace`: its first take, which is later. */
    start_from: 'hook' | 'workspace'
    open: boolean
    label: string | null
    link: string | null
    /** Its repository (`owner/name`), as its start said: the project it is in. */
    repo?: string | null
}

/** A session's conversation, counted (`/v1/hosted/stats`, sessions.rs `tally_of`). */
export interface Tally {
    id: string
    title: string | null
    repo: string | null
    /** Where an imported one was had (`claude.ai/code`, a machine); null for one midas ran. */
    imported: string | null
    archived: boolean
    start: number
    end: number
    /** Seconds of work: the gaps between things said or done, each at most ten minutes. */
    active_s: number
    /** When the person said something, each time. */
    said: number[]
    replies: number
    tool_calls: number
    failed: number
    /** It ran the finish-branch skill: it set out to land. */
    finished: boolean
    tools: Record<string, number>
    commands: Record<string, number>
    cargo: Record<string, number>
    skills: Record<string, number>
    files: Record<string, number>
}

export interface WorkspaceEvent {
    ts: string
    kind: string
    actor?: string
    node?: string
    [field: string]: unknown
}

export interface Deploys {
    /** Every target, each with its project (`owner/name`). */
    targets: {target: string; repo: string; machine: string; after_landing: boolean; publishes: string[]}[]
    recent: WorkspaceEvent[]
    /** What follows landings (ship.rs), one per project deployed after them: its main's tip, a hold, and each target's next deploy. */
    ships?: Ship[]
    /** The deploys going now, whoever asked, each step by step. */
    running?: DeployRun[]
}

export interface Ship {
    tip?: string
    /** The project these deploys follow (`owner/name`): a landing in another one is not theirs. */
    repo?: string | null
    landed_at?: number
    held?: {by: string; why: string | null; at: number} | null
    max_wait_s?: number
    /** `goes_at`: when its deploy of the tip starts, in unix seconds, where the hub can say (ship.rs `goes_at`); for one waiting on landings, the latest. */
    targets: {target: string; state: 'live' | 'deploying' | 'failed' | 'waiting' | 'held' | 'ungated' | 'go' | 'announce' | 'announced' | 'deferred' | 'skip' | 'unpicked'; words: string; asked: string | null; published: string | null; goes_at?: number | null}[]
}

export interface Landing {
    ts: string
    actor: string
    branch: string | null
    outcome: string | null
    sha: string | null
    held_s: number | null
    waited_s: number | null
}

/** What to call a session (`/v1/names`). */
export interface SessionName {
    label: string | null
    branch: string | null
    /** The session on claude.ai, when the worktree is a Remote Control one. */
    link: string | null
    files?: number
    /** The files it changes, as the hub has them from its edits. */
    changed?: string[]
    overlaps?: {with: string; files: string[]}[]
    /** When it was last heard from, and when it ended, if it did. */
    last?: number | null
    ended?: number | null
    notes?: number
}

export type Reservations = Record<string, {last: number; by: Record<string, {owner: string; at: number; why: string | null}>}>

/** A choice put to the person steering the sessions (`/v1/decisions`). */
export interface Decision {
    id: string
    question: string
    options: string[]
    by: string
    with: string[]
    at: number
    answer?: string | null
    answered_by?: string | null
    answered_at?: number | null
    note?: string | null
}

/** A session asking for root on the hub's machine (`/v1/admin`, admin.rs). */
export interface AdminRequest {
    id: string
    session: string
    reason: string
    minutes: number
    at: number
    /** asked, signed (root is checking), open, refused, declined, closed, expired, replaced, dropped. */
    state: string
    why?: string
    until?: number
}

/** Admin windows as they stand: the machine's setup (null before `admin-setup`), requests, the open one. */
export interface AdminState {
    setup: {user: string; rp_id: string; max_minutes: number; keys: {id: string; label: string; added: number}[]} | null
    requests: AdminRequest[]
    window: {id: string; session: string; reason: string; opened: number; until: number} | null
}

/** Work left for the next session on a machine (`/v1/todos`). */
export interface Todo {
    id: string
    text: string
    for: string
    by: string
    at: number
    claimed_by?: string | null
    claimed_at?: number | null
    done_at?: number | null
    done_by?: string | null
    done_note?: string | null
}

/** One file a session's branch changes (sessions.rs `report_files`). */
export interface FileRow {
    path: string
    /** A added, D deleted, M changed. */
    status: string
    add: number
    del: number
    binary?: boolean
    /** New and not added to git yet. */
    untracked?: boolean
    /** A piece of its diff, from its first hunk; not every file has one. */
    patch?: string
}

export interface FilesReport {
    files: FileRow[]
    commits: number
    base?: string
    at?: number
}