Core EngineGo PTY Terminal

The Execution
Layer

Vextor AI's integrated terminal completely bypasses the Node.js event loop. Powered by a custom, concurrent Go backend, the Vextor terminal remains crash-proof under the heaviest I/O compiler workloads.

01. The Node.js PTY Problem

Traditional Electron editors utilize the node-pty library to bridge the UI to the underlying operating system's terminal (CMD, PowerShell, or bash). While functional for light tasks, this architecture routes all standard input/output (stdio) streams through the single-threaded Node.js V8 engine.

When a build tool or compiler rapidly prints thousands of lines of logs, the V8 engine struggles to stringify and garbage-collect the incoming buffers fast enough. This leads to dropped packets, frozen inputs, and complete editor crashes.

The Go Solution

By replacing Node.js with Go, Vextor leverages Goroutines. Go easily spawns thousands of lightweight concurrent threads. The terminal output stream is handled on an entirely separate OS thread from the input stream, ensuring your keystrokes are registered instantly, even during massive compilation dumps.

02. WebSocket Streaming

To connect the Go Execution Layer to the React Presentation Layer without introducing latency, Vextor utilizes a local WebSocket binary stream.

src/pty/server.go
func streamPTY(ws *websocket.Conn, pty *os.File) {
    // Goroutine 1: Read from PTY, Write to WebSocket (UI)
    go func() {
        buffer := make([]byte, 8192)
        for {
            n, err := pty.Read(buffer)
            if err != nil { return }
            // Push raw binary to React UI. Zero string serialization.
            ws.WriteMessage(websocket.BinaryMessage, buffer[:n])
        }
    }()

    // Goroutine 2: Read from WebSocket (UI), Write to PTY
    go func() {
        for {
            _, msg, err := ws.ReadMessage()
            if err != nil { return }
            pty.Write(msg)
        }
    }()
}

Notice the absence of JSON parsing or string serialization. Vextor reads the raw byte array from the OS terminal and fires it directly into the xterm.js WebGL canvas. This achieves near-native, zero-latency rendering.

03. Deterministic Security Interception

The Go backend is not just a blind pipe; it acts as Vextor AI's absolute security gatekeeper. Because AI models can occasionally hallucinate dangerous commands (e.g., executing a destructive git reset --hard when you asked for a soft reset), executing them blindly is a severe vulnerability.

Application-Layer Firewall

Before the Go server pipes an AI-generated command into the OS PTY, it parses the buffer against a deterministic array of destructive signatures.

BLOCKED: ["rm -rf", "git push --force", "drop table"]

If a match is found, the Go server halts execution and emits a WebSocket event back to the React UI, forcing the developer to explicitly authorize the command via a physical button click.