// Typed access to the existing WebSocket protocol. Request builders and id // matching live here so the app never constructs frames by hand or invents // divergent field names. Mirrors android/.../data/PipelinesRepository.kt. import { Protocol } from "./protocol.js"; import { ProtocolError } from "./client.js"; export class PipelinesRepository { #client; constructor(client) { this.#client = client; } get connectionState() { return this.#client.state; } connect(validated) { this.#client.connect(validated); } disconnect() { this.#client.disconnect(); } ping() { return this.#client.call({ type: Protocol.PING }); } async listPipelines() { return (await this.#client.call({ type: Protocol.LIST })).pipelines ?? []; } async getPipeline(id, version) { const response = await this.#client.call({ type: Protocol.GET_PIPELINE, pipeline_id: id, version, }); if (!response.detail) { throw new ProtocolError("The server returned no pipeline detail."); } return response.detail; } async listRuns() { const response = await this.#client.call({ type: Protocol.LIST_RUNS }); return { runs: response.runs ?? [], usage: response.usage ?? null }; } async getRun(id) { const response = await this.#client.call({ type: Protocol.GET_RUN, run_id: id, }); if (!response.run_detail) { throw new ProtocolError("The server returned no run detail."); } return response.run_detail; } }