- Rename container-runtime.ts → jail-ops.ts, container-runner.ts → jail-runner.ts - Rename all types: ContainerInput→JailInput, ContainerOutput→JailOutput, VolumeMount→JailMount - Rename all functions: runContainerAgent→runJailAgent, stopContainer→stopJail, ensureContainerRuntimeRunning→ensureJailRunning, cleanupOrphans→cleanupStaleJails - Rename config constants: CONTAINER_TIMEOUT→JAIL_TIMEOUT, CONTAINER_MAX_OUTPUT_SIZE→JAIL_MAX_OUTPUT_SIZE, MAX_CONCURRENT_CONTAINERS→MAX_CONCURRENT_JAILS - Remove Docker/Apple Container runtime detection, CONTAINER_IMAGE, CONTAINER_RUNTIME_BIN - Add jail-ops.ts: pure FreeBSD jail runtime (nullfs mounts, jexec, jls cleanup) - Add jail-runner.ts: agent runner using jexec instead of docker run - Add FreeBSD jail implementation docs and JAIL-CLEANUP-MODEL - Add AGENT.md, AGENTS.md, groups/*/AGENT.md for Clawdie context - Add mount-allowlist.example.json Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
#!/usr/bin/env tsx
|
||
/**
|
||
* Test jail runtime behavior and cleanup logic
|
||
* Run: tsx scripts/test-jail-runtime.ts
|
||
*/
|
||
|
||
import {
|
||
detectRuntime,
|
||
cleanupOrphans,
|
||
RuntimeType,
|
||
} from '../src/container-runtime.js';
|
||
|
||
console.log('=== Jail Runtime Test ===\n');
|
||
|
||
// 1. Detect runtime
|
||
const runtime = detectRuntime();
|
||
console.log(`Detected runtime: ${runtime || 'none'}`);
|
||
|
||
if (runtime !== 'jail') {
|
||
console.log('\n⚠️ Not running on FreeBSD with jail support');
|
||
console.log(' This is expected on macOS/Linux\n');
|
||
process.exit(0);
|
||
}
|
||
|
||
// 2. Check if we're in a jail
|
||
import { JailRuntime } from '../src/jail-runtime.js';
|
||
const jailRuntime = JailRuntime.getInstance();
|
||
|
||
if (jailRuntime.isInJail()) {
|
||
const info = jailRuntime.getJailInfo();
|
||
console.log('\n✅ Running inside jail:');
|
||
console.log(` Name: ${info?.name}`);
|
||
console.log(` JID: ${info?.jid}`);
|
||
console.log(` Hostname: ${info?.hostname}`);
|
||
console.log(` IP: ${info?.ip}`);
|
||
console.log(` Path: ${info?.path}`);
|
||
} else {
|
||
console.log('\n✅ Running on FreeBSD host (not in jail)');
|
||
}
|
||
|
||
// 3. Test orphan cleanup
|
||
console.log('\n=== Testing Orphan Cleanup ===');
|
||
cleanupOrphans();
|
||
console.log('✅ Orphan cleanup completed\n');
|
||
|
||
// 4. Check for stale mounts
|
||
import { execSync } from 'child_process';
|
||
|
||
console.log('=== Checking for Stale Mounts ===');
|
||
try {
|
||
const mounts = execSync('mount | grep clawdie-cp || echo "No stale mounts"', {
|
||
encoding: 'utf-8',
|
||
});
|
||
console.log(mounts);
|
||
} catch {
|
||
console.log('No stale mounts found');
|
||
}
|
||
|
||
console.log('\n✅ Test complete!');
|