feat(box): the box's NixOS system as a module, and lib.mkBox from a few names
check / check (push) Canceled after 0s

The box within reach of the couch: a Raspberry Pi 3B with the AIY Voice
HAT, from the first household's configuration, made generic.

- box/body: the button service, in Python: press and talk, turns by
  voice, a press interrupts; the look signal
- box/*.js: the ir and look capabilities, behind gates, for the brain;
  the ask client, the box's side of a conversation
- box/module.nix: the services, each confined to the devices and
  addresses it needs; the private network as an option (a tailnet by
  default); the Pico found by its USB IDs, as /dev/pdtv26-ir
- box/voicehat.nix: the Voice HAT's device tree overlay and ALSA setup
- lib.mkBox: a box's whole system from its name, the home server's,
  the Wi-Fi network's, and who looks after it
- checks: box-js, box-py (doctests and pyflakes), and box-system (an
  example box's system evaluates)

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-12-02 16:18:17 -06:00
1 parent 2e7156dc36
commit 521998b666
35 files changed
+2165 -3

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
// Tests for the look capability, with a fake camera and a fake button service.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { Look } from './look.js';
const fakes = ({ signalFails = false, grabFails = false } = {}) => {
const log = [];
const signal = async () => {
if (signalFails) throw new Error('the button service is not listening');
log.push('flash');
return () => log.push('stop');
};
const grab = async () => {
log.push('grab');
if (grabFails) throw new Error('camera: 401');
return new Uint8Array([0xff, 0xd8, 0xff]);
};
return { log, look: new Look(signal, grab) };
};
test('a look is shown before the frame is taken, and stops after', async () => {
const { log, look } = fakes();
assert.equal(await look.look(), '/9j/');
assert.deepEqual(log, ['flash', 'grab', 'stop']);
});
test('no indication, no look', async () => {
const { log, look } = fakes({ signalFails: true });
await assert.rejects(look.look(), /not listening/);
assert.deepEqual(log, []);
});
test('the indication stops even when the camera fails', async () => {
const { log, look } = fakes({ grabFails: true });
await assert.rejects(look.look(), /401/);
assert.deepEqual(log, ['flash', 'grab', 'stop']);
});
test('one look at a time', async () => {
const { log, look } = fakes();
await Promise.all([look.look(), look.look()]);
assert.deepEqual(log, ['flash', 'grab', 'stop', 'flash', 'grab', 'stop']);
});