MCPcopy Create free account
hub / github.com/cloudflare/computer / ShellRPCServer

Class ShellRPCServer

packages/rpc/src/server.ts:229–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227 }
228}
229class ShellRPCServer extends RpcTarget implements ShellRPC {
230 constructor(private readonly runner: RunnerLike) {
231 super();
232 trackStub(this);
233 }
234
235 [Symbol.dispose](): void {
236 untrackStub(this);
237 }
238
239 async exec(input: {
240 command: string;
241 cwd?: string;
242 id?: string;
243 timeoutMs?: number;
244 env?: Record<string, string>;
245 stdin?: Uint8Array;
246 }): Promise<{
247 id: string;
248 events: ReadableStream<ExecEvent>;
249 }> {
250 return this.runner.exec(input.command, {
251 id: input.id,
252 cwd: input.cwd,
253 timeoutMs: input.timeoutMs,
254 env: input.env,
255 stdin: input.stdin,
256 });
257 }
258
259 async getExec(input: { id: string; after?: number | "tail" }): Promise<{
260 id: string;
261 events: ReadableStream<ExecEvent>;
262 }> {
263 return this.runner.get(input.id, { after: input.after });
264 }
265
266 async killExec(input: {
267 id: string;
268 signal?: "SIGTERM" | "SIGKILL" | "SIGINT" | "SIGHUP";
269 }): Promise<void> {
270 this.runner.kill(input.id, input.signal);
271 }
272
273 async disposeExec(input: { id: string }): Promise<void> {
274 this.runner.dispose(input.id);
275 }
276}
277
278// Composite server: exposes both halves as named fields on one
279// stub. Capnweb walks the property tree on demand, so callers

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected