Adds a transcript surface for a Structured-view session alongside the existing xterm attach view: a WS /api/structured/:id connection (structured.ts) mounted by ConnectionPool whenever a session's `view` is `"Structured"`, and pure per-row/rail renderers (structuredRender.ts, structuredDiff.ts) covering all eight transcript row kinds. Hierarchy follows the design reference (artifact 88ecd690): the approval is the only lifted, card-like element; a user turn is a tinted block with an accent rail; agent prose is plain text; tool calls are compact bordered rows expanding to output or a coloured, horizontally-scrolling diff computed from ACP's full old/new text. The client renders `reduced_state` and rows exactly as received, with no raw-event folding or turn tracking of its own. Extracted attach.ts's pane-header title building into paneTitle.ts and its connection interface into pane.ts (PaneConnection) so both connection kinds share one contract and one header.
83 lines
2.6 KiB
TypeScript
83 lines
2.6 KiB
TypeScript
// Mirror of `maestro-protocol::routes`. Keep in sync with
|
|
// crates/maestro-protocol/src/routes.rs.
|
|
|
|
import type { Uuid } from "./types.js";
|
|
|
|
export const API_PREFIX = "/api";
|
|
|
|
export const SESSIONS = "/api/sessions";
|
|
export const INFO = "/api/info";
|
|
export const DIRS = "/api/dirs";
|
|
export const RECENT_DIRS = "/api/recent-dirs";
|
|
export const PROJECTS = "/api/projects";
|
|
export const GITROOT = "/api/gitroot";
|
|
export const NAMES = "/api/names";
|
|
export const BRANCHES = "/api/branches";
|
|
export const EVENTS = "/api/events";
|
|
|
|
/** Name of the query parameter `DIRS` and `GITROOT` both take. */
|
|
export const PATH_QUERY = "path";
|
|
|
|
/** Name of the query parameter `DELETE /api/sessions/:id` takes (#81):
|
|
* `force=true` overrides the kill refusal over a guarded worktree. */
|
|
export const FORCE_QUERY = "force";
|
|
|
|
/** Name of the query parameter `NAMES` takes. */
|
|
export const COUNT_QUERY = "count";
|
|
|
|
export function session(id: Uuid): string {
|
|
return `${SESSIONS}/${encodeURIComponent(id)}`;
|
|
}
|
|
|
|
export function attach(id: Uuid): string {
|
|
return `${API_PREFIX}/attach/${encodeURIComponent(id)}`;
|
|
}
|
|
|
|
export function sessionFocus(id: Uuid): string {
|
|
return `${session(id)}/focus`;
|
|
}
|
|
|
|
/** `WS /api/structured/:id` — transcript/state snapshots and live deltas. */
|
|
export function structured(id: Uuid): string {
|
|
return `${API_PREFIX}/structured/${encodeURIComponent(id)}`;
|
|
}
|
|
|
|
/** `POST /api/sessions/:id/structured/prompt` — send an ACP prompt. */
|
|
export function structuredPrompt(id: Uuid): string {
|
|
return `${session(id)}/structured/prompt`;
|
|
}
|
|
|
|
/** `POST /api/sessions/:id/structured/cancel` — cancel an ACP turn. */
|
|
export function structuredCancel(id: Uuid): string {
|
|
return `${session(id)}/structured/cancel`;
|
|
}
|
|
|
|
/** `POST /api/sessions/:id/structured/approvals/:nonce` — answer a permission
|
|
* request. */
|
|
export function structuredApproval(id: Uuid, nonce: string): string {
|
|
return `${session(id)}/structured/approvals/${encodeURIComponent(nonce)}`;
|
|
}
|
|
|
|
/** Append the `path` query parameter `DIRS` and `GITROOT` accept. */
|
|
export function withPathQuery(route: string, value: string): string {
|
|
return `${route}?${PATH_QUERY}=${encodeURIComponent(value)}`;
|
|
}
|
|
|
|
/** Same-origin WebSocket base — `wss:` under TLS, `ws:` otherwise. */
|
|
export function wsBase(): string {
|
|
const proto = location.protocol === "https:" ? "wss:" : "ws:";
|
|
return `${proto}//${location.host}`;
|
|
}
|
|
|
|
export function eventsWsUrl(): string {
|
|
return `${wsBase()}${EVENTS}`;
|
|
}
|
|
|
|
export function attachWsUrl(id: Uuid): string {
|
|
return `${wsBase()}${attach(id)}`;
|
|
}
|
|
|
|
export function structuredWsUrl(id: Uuid): string {
|
|
return `${wsBase()}${structured(id)}`;
|
|
}
|