This repository has been archived on 2026-10-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
maestro/web/src/types.ts
T
naps62-yoloandClaude Opus 4.7 464bea2fae
ci / rust (push) Failing after 8m45s
refactor(web): rewire attach.ts to same-origin broker endpoint (NAP-241)
Browser now opens ws://{host}/api/attach/:id directly — maestro-web
reverse-proxies it to the home daemon's broker, which short-circuits to
the local PTY (NAP-243) or, once NAP-247 lands, brokers to a peer over T2.

Drops the old getConnectInfo + daemon_url path: the browser no longer
knows or cares which daemon owns a session. ConnectInfo type and the
helper are gone.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:23:21 +00:00

77 lines
1.9 KiB
TypeScript

// Mirror of `maestro-protocol` JSON shapes. Keep in sync with
// crates/maestro-protocol/src/lib.rs.
export type Uuid = string;
export type IsoTimestamp = string;
export type SessionStatus = "Running" | "Dead";
export interface Session {
id: Uuid;
daemon_id: string;
cwd: string;
command: string;
env: Record<string, string>;
metadata: Record<string, unknown>;
status: SessionStatus;
created_at: IsoTimestamp;
}
export interface DaemonInfo {
daemon_id: string;
hostname: string;
version: string;
daemon_url: string;
}
export interface WorktreeSpec {
base_repo: string;
branch: string;
cleanup_on_kill?: boolean;
}
export interface CreateSessionRequest {
daemon_id: string;
cwd: string;
command: string;
env?: Record<string, string>;
metadata?: Record<string, unknown>;
worktree?: WorktreeSpec;
}
export type RegistryEvent =
| {
type: "Snapshot";
daemons: DaemonInfo[];
sessions: Session[];
}
| { type: "DaemonAdded"; daemon: DaemonInfo }
| { type: "DaemonRemoved"; daemon_id: string }
| { type: "SessionAdded"; session: Session }
| { type: "SessionRemoved"; daemon_id: string; id: Uuid }
| { type: "SessionUpdated"; session: Session }
| { type: "Lagged"; skipped: number };
export type ClientControl =
| { type: "Resize"; cols: number; rows: number }
| { type: "Ping" }
| { type: "Pong" }
| { type: "Error"; code: string; message: string };
export interface ApiError {
error: { code: string; message: string };
}
export function sessionName(s: Session): string {
const meta = s.metadata as Record<string, unknown>;
const name = meta?.name;
if (typeof name === "string" && name.length > 0) return name;
return s.command;
}
export function sessionLabel(s: Session): string | undefined {
const meta = s.metadata as Record<string, unknown>;
const label = meta?.label;
return typeof label === "string" ? label : undefined;
}