v0.2.0
Standard Web Streams at the runtime boundary
Runtime authors can now connect code mode directly to Web-compatible streams. The bespoke ByteChannel and ByteWriter contracts are gone, so substrates no longer need to imitate code-mode-specific write and idempotent-close behavior.
For example, a runtime instance now returns standard readable and writable byte streams:
const instance: RuntimeInstance = {
channel: {
readable: runtimeOutput,
writable: runtimeInput,
},
finished,
terminate,
};Code mode acquires the writable stream's writer, serializes protocol writes, and closes it when execution finishes. Runtime implementations only need to supply the transport and retain ownership of launch, termination, and failure reporting.
Node integrations can use the platform adapter directly instead of maintaining a code-mode-specific writer:
import { Duplex } from "node:stream";
const channel = Duplex.toWeb(processPipe);The generated Node 24 bootstrap uses the same native full-duplex Web Streams conversion. This keeps host Node, sandboxed Node, and future substrates on one runtime-neutral contract without moving process lifecycle into code mode.
Migrating runtime implementations
This release intentionally changes the runtime-author API. Replace the old channel shape:
{
incoming: AsyncIterable<Uint8Array>;
outgoing: {
write(chunk: Uint8Array): Promise<void>;
close(): Promise<void>;
};
}with:
{
readable: ReadableStream<Uint8Array>;
writable: WritableStream<Uint8Array>;
}There is no compatibility layer or dual API. This makes incorrect adapters fail at compile time and leaves one clear transport contract.
Reliability
Program shutdown no longer waits behind a pending response read after an agent failure. The regression suite covers this case along with the complete host-Node and exported runtime conformance journeys.
Install this release with:
npm install @torkbot/code-mode@0.2.0