<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Bun on Nick Liu - Software Engineer</title>
    <link>https://nick-liu.com/tags/bun/</link>
    <description>Recent content in Bun on Nick Liu - Software Engineer</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <managingEditor>nickboy@users.noreply.github.com (Nick Liu)</managingEditor>
    <webMaster>nickboy@users.noreply.github.com (Nick Liu)</webMaster>
    <copyright>2026 Nick Liu</copyright>
    <lastBuildDate>Fri, 10 Jul 2026 20:05:23 -0700</lastBuildDate><atom:link href="https://nick-liu.com/tags/bun/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>I split my daemon in two so a Node subprocess could own the PTY</title>
      <link>https://nick-liu.com/posts/pty-wrap-migration/</link>
      <pubDate>Sun, 10 May 2026 00:00:00 +0000</pubDate>
      <author>nickboy@users.noreply.github.com (Nick Liu)</author>
      <guid>https://nick-liu.com/posts/pty-wrap-migration/</guid>
      <description>&lt;div class=&#34;lead text-neutral-500 dark:text-neutral-400 !mb-9 text-xl&#34;&gt;&#xA;  &#xA;I built a Claude Code permission gate that holds an HTTP response open until a Stream Deck key is pressed. Then I needed to inject a keystroke into Claude Code&#39;s own TTY so a key press could write `1\r` straight into Claude&#39;s stdin. Bun can hold HTTP open all day. Bun cannot reliably wrap a child PTY through `node-pty` and capture the parent shell&#39;s PID. So I split my daemon: HTTP and WebSocket stay on Bun, and a Node CommonJS subprocess owns the PTY that runs Claude.&#xA;&#xA;&lt;/div&gt;&#xA;&#xA;&lt;nav class=&#34;series-progress&#34; aria-label=&#34;Series progress&#34;&gt;&#xA;    &lt;span class=&#34;series-progress-label&#34;&gt;Building ClaudeDeck · Part 7 of 10&lt;/span&gt;&#xA;    &lt;ol class=&#34;series-progress-dots&#34;&gt;&lt;li class=&#34;series-progress-dot is-done&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/claude-code-hooks-reality/&#34; title=&#34;The Claude Code hooks docs are wrong. Here&amp;#39;s what&amp;#39;s actually on the wire.&#34;&gt;1&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot is-done&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/streamdeck-sdk-quirks/&#34; title=&#34;Two Stream Deck SDK quirks that cost me a weekend&#34;&gt;2&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot is-done&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/lru-session-eviction/&#34; title=&#34;Five Stream Deck keys, N Claude sessions: LRU that keeps the order I see&#34;&gt;3&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot is-done&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/statusline-side-channel/&#34; title=&#34;The Claude Code statusline is a per-turn telemetry side channel&#34;&gt;4&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot is-done&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/plan-usage-statusline-pivot/&#34; title=&#34;I polled an undocumented endpoint for 18 hours. The data was on stdin.&#34;&gt;5&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot is-done&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/permission-round-trip/&#34; title=&#34;Holding HTTP open for 590 seconds so a Stream Deck key can approve a tool call&#34;&gt;6&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot is-current&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/pty-wrap-migration/&#34; title=&#34;I split my daemon in two so a Node subprocess could own the PTY&#34; aria-current=&#34;step&#34;&gt;7&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/tcc-cdhash-trap/&#34; title=&#34;TCC pins your Accessibility grant to a cdhash. Every rebuild breaks it.&#34;&gt;8&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/tahoe-hotkey-dead-end/&#34; title=&#34;What replaced CGEventPost in my Stream Deck daemon&#34;&gt;9&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;li class=&#34;series-progress-dot&#34;&gt;&#xA;          &lt;a href=&#34;https://nick-liu.com/posts/launchd-bootstrap-debugging/&#34; title=&#34;launchctl unload returned 0. The daemon was still running. KeepAlive raced.&#34;&gt;10&lt;/a&gt;&#xA;        &lt;/li&gt;&lt;/ol&gt;&#xA;  &lt;/nav&gt;&#xA;&lt;div class=&#34;tested-with&#34; role=&#34;note&#34;&gt;&#xA;  &lt;span class=&#34;tested-with-icon&#34; aria-hidden=&#34;true&#34;&gt;🧪&lt;/span&gt;&#xA;  &lt;span&gt;Tested with &lt;strong&gt;Claude Code&lt;/strong&gt; &lt;code&gt;2.1.x&lt;/code&gt; · macOS&lt;/span&gt;&#xA;&lt;/div&gt;&#xA;&#xA;&lt;p&gt;(Quick grounding before the story: a &lt;em&gt;PTY&lt;/em&gt; (pseudo-terminal) is the kernel object every interactive shell talks to. It&amp;rsquo;s a pair of file descriptors, master and slave; the program reads/writes the slave end as if it were a real terminal, and anything you write to the master end looks to that program like a human typing. The &lt;em&gt;TTY&lt;/em&gt; is the slave end seen from the child&amp;rsquo;s side. &lt;code&gt;node-pty&lt;/code&gt; is Microsoft&amp;rsquo;s library that gives a JavaScript parent process a writable handle to the master. &lt;em&gt;Bun&lt;/em&gt; is a JavaScript runtime, Node&amp;rsquo;s faster sibling, and &lt;em&gt;Node CommonJS&lt;/em&gt; is plain old &lt;code&gt;require()&lt;/code&gt;-based Node, no transpile step. The story below is about which runtime owns the PTY.)&lt;/p&gt;</description>
      
    </item>
    
  </channel>
</rss>
