mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 16:39:32 +00:00
* feat(runner): replace server-side bash sandbox with remote runner * fix(runner): address review findings for output bounds, key rotation, defaults, and generated uploads * chore(docker): remove sandbox privileges and env vars from remaining compose files * feat(cli): add runner start with bundled SRT sandboxing (#535) * refactor(agent): expose runner bash without skill gating * feat(cli): add runner start with optional SRT sandboxing * refactor(cli): remove runner Python dependency * feat(cli): bundle SRT and use platform-native runner shells * refactor(cli): delegate runner processes to Execa * chore(cli): upgrade @anthropic-ai/sandbox-runtime to 0.0.83 * feat(cli): discover Bash for Windows runners Use Pi-style Bash discovery and launch behavior, exercise the packaged CLI shell, and wait for pending ZIP metadata reads before closing cancelled downloads. * fix(runner): enforce ownership and safe reconnects Gate dispatch on reconciliation, retain cancellations across disconnects, and stop replaced clients. Guard the single-server runner topology with a database lease. Restage missing generated inputs, report signal exits, and bound generated-file cleanup. * feat(webui): add Korean translations for agent runners * feat(cli): add runner event logging and --verbose flag (#536) * feat(cli): add runner event logging and --verbose flag * fix(cli): log runner capacity rejections accurately and use monotonic duration
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import { createRequire } from 'node:module'
|
|
import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import path from 'node:path'
|
|
import {
|
|
SandboxRuntimeConfigSchema,
|
|
type SandboxRuntimeConfig,
|
|
} from '@anthropic-ai/sandbox-runtime'
|
|
import { bundledSrtVendor } from './srt-vendor'
|
|
|
|
/** Load the upstream JSON format and supply the helpers bundled with this CLI. */
|
|
export async function loadSandbox(configPath: string) {
|
|
const config = SandboxRuntimeConfigSchema.parse(JSON.parse(await readFile(configPath, 'utf8')))
|
|
const directory = await mkdtemp(path.join(tmpdir(), 'shumai-srt-'))
|
|
const cleanup = () => rm(directory, { recursive: true, force: true })
|
|
const asset = async (name: string) => {
|
|
const encoded = bundledSrtVendor?.[name]
|
|
const bytes =
|
|
encoded !== undefined
|
|
? Buffer.from(encoded, 'base64')
|
|
: await readFile(
|
|
path.join(
|
|
path.dirname(
|
|
createRequire(import.meta.url).resolve(
|
|
'@anthropic-ai/sandbox-runtime/package.json',
|
|
),
|
|
),
|
|
'vendor',
|
|
name,
|
|
),
|
|
)
|
|
const destination = path.join(directory, path.basename(name))
|
|
await writeFile(destination, bytes, { mode: 0o500 })
|
|
return destination
|
|
}
|
|
try {
|
|
if (process.platform === 'linux' && !config.seccomp?.applyPath) {
|
|
config.seccomp = {
|
|
...config.seccomp,
|
|
applyPath: await asset(`seccomp/${process.arch}/apply-seccomp`),
|
|
}
|
|
}
|
|
if (process.platform === 'win32' && !config.windows?.srtWin?.path) {
|
|
config.windows = {
|
|
...config.windows,
|
|
srtWin: {
|
|
...config.windows?.srtWin,
|
|
path: await asset(`srt-win/${process.arch}/srt-win.exe`),
|
|
},
|
|
}
|
|
}
|
|
if (!config.javaAgentJarPath)
|
|
config.javaAgentJarPath = await asset('java-proxy-agent/srt-proxy-agent.jar')
|
|
return { config: config satisfies SandboxRuntimeConfig, cleanup }
|
|
} catch (error) {
|
|
await cleanup()
|
|
throw error
|
|
}
|
|
}
|