feat(worker): run terminals and agent turns as the box user

This commit is contained in:
Gabriel Brown
2026-07-13 10:04:14 -04:00
parent a956d63e16
commit 58bd101793
13 changed files with 263 additions and 22 deletions
@@ -22,6 +22,20 @@ describe('box registry', () => {
vi.clearAllMocks();
});
test('passes an onCreated hook so a fresh box gets its user initialized', async () => {
const module = await load();
const docker = await import('../../src/runtime/docker');
await module.acquireUserBox({
username: 'ada',
workdir: '/w',
containerHome: '/home/ada',
});
const call = vi.mocked(docker.ensureUserContainer).mock.calls[0]?.[0] as {
onCreated?: unknown;
};
expect(call.onCreated).toBeTypeOf('function');
});
test('re-ensures the container on every acquire so an externally removed box self-heals', async () => {
const module = await load();
const docker = await import('../../src/runtime/docker');