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
This commit is contained in:
1 parent
190600a696
commit
5cbea49349
16 files changed
+927
-1
No files matched your search
@@ -0,0 +1,40 @@
|
||||
// Tests for report_problem, with a fake GitHub: no network.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { makeReporter, makeGitHubPost, MAX_TITLE_CHARS } from './report.js';
|
||||
|
||||
test('a report opens an issue assigned to whoever looks after the box', async () => {
|
||||
const calls = [];
|
||||
const report = makeReporter(async (path, body) => {
|
||||
calls.push([path, body]);
|
||||
return { status: 201, json: { number: 7, html_url: 'https://github.com/o/r/issues/7' } };
|
||||
}, 'o/r', 'keeper');
|
||||
assert.equal(await report(' Input menu closes ', 'Tried 3 presses.'), 'reported as #7: https://github.com/o/r/issues/7');
|
||||
assert.deepEqual(calls, [['/repos/o/r/issues', {
|
||||
title: 'Input menu closes', body: 'Tried 3 presses.\n\n— reported by the agent at the TV', assignees: ['keeper'],
|
||||
}]]);
|
||||
});
|
||||
|
||||
test('GitHub refusing is a failure, with its reason', async () => {
|
||||
const report = makeReporter(async () => ({ status: 403, json: { message: 'Resource not accessible' } }), 'o/r', 'keeper');
|
||||
await assert.rejects(report('t', 'd'), /403: Resource not accessible/);
|
||||
});
|
||||
|
||||
test('a report needs a title, and not a novel', async () => {
|
||||
const report = makeReporter(async () => assert.fail('no post'), 'o/r', 'keeper');
|
||||
await assert.rejects(report('', 'd'), /title/);
|
||||
await assert.rejects(report('x'.repeat(MAX_TITLE_CHARS + 1), 'd'), /title over/);
|
||||
await assert.rejects(report('t', undefined), /details/);
|
||||
});
|
||||
|
||||
test('the post carries the token and names the client', async () => {
|
||||
let seen;
|
||||
const post = makeGitHubPost(async (url, init) => {
|
||||
seen = { url, ...init };
|
||||
return { status: 201, json: async () => ({ number: 1 }) };
|
||||
}, 's3cret');
|
||||
assert.deepEqual(await post('/repos/o/r/issues', { title: 't' }), { status: 201, json: { number: 1 } });
|
||||
assert.equal(seen.url, 'https://api.github.com/repos/o/r/issues');
|
||||
assert.equal(seen.headers.authorization, 'Bearer s3cret');
|
||||
assert.match(seen.headers['user-agent'], /pdtv26-brain/);
|
||||
});
|
||||
Reference in new issue
Block a user