forked from boxlite-ai/boxlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractivebox.js
More file actions
43 lines (35 loc) · 843 Bytes
/
Copy pathinteractivebox.js
File metadata and controls
43 lines (35 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* InteractiveBox Example - Interactive terminal session
*
* Demonstrates:
* - Creating an interactive shell
* - PTY terminal forwarding
* - Real-time I/O
*/
import { InteractiveBox } from '@boxlite-ai/boxlite';
async function main() {
console.log('=== InteractiveBox Example ===\n');
console.log('Starting interactive shell...');
console.log('(Type "exit" to close the session)\n');
const box = new InteractiveBox({
image: 'alpine:latest',
shell: '/bin/sh',
tty: true,
memoryMib: 512,
cpus: 1
});
try {
await box.start();
// Wait for shell to exit
await box.wait();
console.log('\nShell exited.');
} finally {
await box.stop();
console.log('Box cleaned up.');
}
}
// Run the example
main().catch(error => {
console.error('Error:', error);
process.exit(1);
});