@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
56 lines • 2.03 kB
JavaScript
import { PassThrough } from "node:stream";
import { ConnectError } from "./errors.js";
/**
* A project transport resolves again at EVERY spawn, including an era probe's
* fallback restart of the same transport object. SDK private spawn parameters
* are never mutated; each start owns a newly constructed SDK transport.
*/
export class ProjectStdioTransport {
constructor(resolve, create) {
this.stderr = new PassThrough();
this.
this.
this.
}
get pid() {
return this.
}
async start() {
const epoch = this.
const spec = await this.
if (epoch !== this.
throw new ConnectError("Project MCP spawn was invalidated; retry", {
phase: "create",
retriable: true,
});
const transport = this.
this.
transport.onmessage = (message) => this.onmessage?.(message);
transport.onclose = () => this.onclose?.();
transport.onerror = (error) => this.onerror?.(error);
transport.stderr?.pipe(this.stderr, { end: false });
await transport.start();
if (epoch !== this.
await transport.close();
throw new ConnectError("Project MCP spawn was invalidated; retry", { phase: "create", retriable: true });
}
}
async send(message, _options) {
if (this.
throw new ConnectError("Project MCP transport has not started", {
phase: "send",
retriable: true,
});
// The stdio SDK transport takes only the message; send options are an HTTP concern.
await this.
}
async close() {
this.
await this.
}
}
//# sourceMappingURL=project-stdio-transport.js.map