import type { ReloadBus } from './reload-bus.js'; import type { ReloadCoordinator } from './watch.js'; import type { ProjectMetadata } from '../project/context.js'; export interface EditorServerOptions { /** The project root — the directory holding `bitmagic.json`. */ root: string; /** The project's `bitmagic.json`, for the generation the HQ button runs. */ metadata: ProjectMetadata; /** The game this project owns, from `bitmagic.json`. */ gameId: string; /** What the bar calls the game — `gameName` in game.json, else the folder (project/game-name.ts). */ gameName: string; /** Which api-server this project talks to, resolved by `dev` and shown in the bar. */ environment: string; /** Port vite serves the game on; the shell iframes it. */ gamePort: number; /** Port to bind. Fails loudly if taken — the URL is meant to be stable and bookmarkable. */ port: number; /** The SSE channel every open shell listens on. */ bus: ReloadBus; /** Decides when a reload is safe to send. Told about this server's own writes, and about * `POST /api/reload`; also fed by the file watcher and `tsc --watch` in `commands/dev.ts`. */ coordinator: ReloadCoordinator; log?: (message: string) => void; } export interface EditorServer { /** The URL to open — the shell port this install's lane resolved to (port-lane.ts). */ readonly url: string; /** Where editor actions are journalled, so the startup banner can point an agent at it. */ readonly journalPath: string; /** Epoch ms when the port was bound — what the tab-reuse wait is measured from (tab-reuse.ts). */ readonly listeningAt: number; /** Is a browser tab on this server right now — an SSE subscriber, or a poll seconds ago. */ hasShellWatcher(): boolean; /** Vite answers: tell the page it may reboot the game. Until then a stale tab holds still. */ markReady(): void; close(): Promise; } /** * The command the agent should run to fulfil an HQ request. One definition, quoted for a shell, * so the journal line, the HTTP reply and the editor's own confirmation cannot drift apart. */ export declare function hqCommand(assetId: string, prompt: string): string; export declare function startEditorServer(options: EditorServerOptions): Promise;