Files
pdtv26/brain/brain.nix
T
dckc 84d2816f24 feat(brain): a sandboxed language model session with an MCP channel to the box
The brain: a long-running Claude Code session, confined with bwrap to
its workspace, that hears the box through a channel and works the TV
with the box's ir and look capabilities.

- brain/channel.js: MCP on stdio to the brain (reply, say, ir_listen,
  ir_send, look, report_problem), and the ask capability, behind a
  gate, to the box
- brain/ask.js: the conversations between them; report.js: an issue on
  one repository, by a token that can do nothing else
- brain/brain.service: the session in tmux, in bwrap: a read-only
  system, an empty home but for its workspace, keys, and claude
- brain/instructions.md: how to work the TV; it imports household.md,
  who's who (an example, with no real people)
- brain/Makefile: make install, attach, status
- checks: brain-js (unit tests), brain (the package, put together)

Generated-by: Claude Opus 5.5
2026-12-02 16:29:33 -06:00

21 lines
1.3 KiB
Nix

# The brain's channel, with node, and what make install puts in place:
# bin/brain-channel HOST PORT KEYFILE [IR_URL IR_KEYFILE [REPO TOKENFILE ASSIGNEE [LOOK_URL LOOK_KEYFILE]]]
# bin/tmux the unit's tmux, to attach with: a client must match its server
# share/pdtv26-brain/pdtv26-brain.service the sandboxed session, a systemd user unit
# share/pdtv26-brain/CLAUDE.md its instructions, which name src, its own source, to read
# share/pdtv26-brain/household.md an example of who's who
{ callPackage, runCommand, nodejs-slim, tmux, bubblewrap, src }:
let
js = callPackage ./default.nix { };
in
runCommand "pdtv26-brain" { } ''
mkdir -p $out/bin $out/share/pdtv26-brain
printf '#!/bin/sh\nexec %s %s/lib/node_modules/pdtv26-brain/channel.js "$@"\n' ${nodejs-slim}/bin/node ${js} > $out/bin/brain-channel
chmod +x $out/bin/brain-channel
ln -s ${tmux}/bin/tmux $out/bin/tmux
substitute ${./brain.service} $out/share/pdtv26-brain/pdtv26-brain.service \
--subst-var-by tmux ${tmux} --subst-var-by bubblewrap ${bubblewrap} --subst-var-by src ${src}
substitute ${./instructions.md} $out/share/pdtv26-brain/CLAUDE.md --replace-fail @SRC@ ${src}
cp ${./household.md} $out/share/pdtv26-brain/household.md
''