Files
openshell_controller/app/api/sandbox/[sandboxId]/config/route.ts
T
Mark McKeen 35532aba05 feat: align sandbox config with OpenShell policy schema
- replace generic config UI with OpenShell policy editor
- add sandbox config API route using policy-shaped data
- fix combined telemetry route to avoid broken upstream fetch
2026-03-29 08:38:57 -06:00

53 lines
1.5 KiB
TypeScript

import { NextResponse } from 'next/server'
const defaultPolicy = {
version: 1,
filesystem_policy: {
include_workdir: true,
read_only: ['/usr', '/lib', '/etc', '/proc', '/dev/urandom'],
read_write: ['/sandbox', '/tmp', '/dev/null'],
},
landlock: {
compatibility: 'best_effort',
},
process: {
run_as_user: 'sandbox',
run_as_group: 'sandbox',
},
network_policies: {},
}
export async function GET(
_request: Request,
{ params }: { params: Promise<{ sandboxId: string }> }
) {
try {
const { sandboxId } = await params
return NextResponse.json({ sandboxId, currentConfig: defaultPolicy })
} catch (error) {
console.error('Error fetching sandbox configuration:', error)
return NextResponse.json({ error: 'Failed to fetch configuration' }, { status: 500 })
}
}
export async function POST(
request: Request,
{ params }: { params: Promise<{ sandboxId: string }> }
) {
try {
const { sandboxId } = await params
const body = await request.json()
const policy = body?.policy || defaultPolicy
return NextResponse.json({
success: true,
sandboxId,
policy,
appliedAt: new Date().toISOString(),
note: 'OpenShell-aligned policy accepted. Dynamic network_policies are live-updatable; static sections require sandbox recreation.',
})
} catch (error) {
console.error('Error updating sandbox configuration:', error)
return NextResponse.json({ error: 'Failed to update configuration' }, { status: 500 })
}
}