Shell
Run simple shell commands like ls, cat, and rg from your server, with limits you control.
Deploys on
- Node
- Docker
- Cloudflare
server/utils/docs-shell.ts
import { createShellRuntime } from 'vite-hub/shell'
import {
createJustBashDriver,
} from 'vite-hub/shell/providers/just-bash'
import {
createReadonlyWorkspaceFs,
} from 'vite-hub/shell/workspace'
import { useWorkspace } from 'vite-hub/workspace'
// A shell that can only read the docs Workspace
export function docsShell() {
const docs = useWorkspace('docs')
return createShellRuntime({
policy: { timeout: 10_000, maxOutputLength: 5_000 },
// Bash in JavaScript: no real processes
driver: createJustBashDriver({
// The only commands it can run
commands: ['ls', 'cat', 'rg'],
fs: createReadonlyWorkspaceFs(docs.fs),
}),
})
}Choose the allowed commands
List the commands a shell can run. Network access stays off unless you turn it on.
Work on your files
Commands see Workspace files under
/workspace, read-only or writable.Limits across commands
A session shares one call limit, output cap, and timeout across many commands.