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

Function transform

packages/computer/src/shell.ts:345–366  ·  view source on GitHub ↗
(event, controller)

Source from the content-addressed store, hash-verified

343 return source.pipeThrough(
344 new TransformStream<ExecEvent, WorkspaceExecEvent<E>>({
345 transform(event, controller) {
346 if (event.name === "stdout") {
347 stdoutMeta = { id: event.id, seq: event.seq };
348 enqueue(controller, {
349 id: event.id,
350 seq: event.seq,
351 name: "stdout",
352 value: stdoutDec.decode(event.value, { stream: true }) as Chunk<E>,
353 });
354 } else if (event.name === "stderr") {
355 stderrMeta = { id: event.id, seq: event.seq };
356 enqueue(controller, {
357 id: event.id,
358 seq: event.seq,
359 name: "stderr",
360 value: stderrDec.decode(event.value, { stream: true }) as Chunk<E>,
361 });
362 } else {
363 flushPending(controller, event.seq);
364 enqueue(controller, event as WorkspaceExecEvent<E>);
365 }
366 },
367 flush: flushPending,
368 }),
369 );

Callers

nothing calls this directly

Calls 2

enqueueFunction · 0.70
flushPendingFunction · 0.70

Tested by

no test coverage detected