mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 07:38:43 +00:00
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
This commit is contained in:
@@ -6,6 +6,7 @@ import { parseArgs } from 'node:util'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { version } from '../package.json'
|
||||
import { version as cliVersion } from '../apps/cli/package.json'
|
||||
import { srtBundlePlugin } from './srt-bundle'
|
||||
|
||||
export const cliTargets = {
|
||||
'darwin-arm64': 'bun-darwin-arm64',
|
||||
@@ -90,6 +91,7 @@ export async function buildCliRelease(outdir: string, targets = cliTargetNames)
|
||||
entrypoints: [join(repoRoot, 'apps/cli/src/index.ts')],
|
||||
target: 'bun',
|
||||
minify: true,
|
||||
plugins: [srtBundlePlugin(...target.split('-'))],
|
||||
compile: {
|
||||
target: cliTargets[target],
|
||||
outfile: binary,
|
||||
|
||||
@@ -2,6 +2,7 @@ import tailwindPlugin from 'bun-plugin-tailwind'
|
||||
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
||||
import { cp, mkdir, readdir, rm, writeFile } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { srtBundlePlugin } from './srt-bundle'
|
||||
|
||||
console.log('\n🚀 Starting NPM packaging build process for all applications...\n')
|
||||
|
||||
@@ -521,6 +522,7 @@ async function buildCliPackage() {
|
||||
outdir: binOutDir,
|
||||
minify: true,
|
||||
naming: 'shumai-cli.js',
|
||||
plugins: [srtBundlePlugin()],
|
||||
external: [],
|
||||
define: {
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { createRequire } from 'node:module'
|
||||
import path from 'node:path'
|
||||
|
||||
/** Keep SRT's native helpers available in both standalone binaries and the Node bundle. */
|
||||
export function srtBundlePlugin(platform?: string, arch?: string): Bun.BunPlugin {
|
||||
return {
|
||||
name: 'srt-vendor',
|
||||
setup(build) {
|
||||
build.onLoad({ filter: /[/\\]runner[/\\]srt-vendor\.ts$/ }, async () => {
|
||||
const packageJson = createRequire(
|
||||
new URL('../apps/cli/package.json', import.meta.url),
|
||||
).resolve('@anthropic-ai/sandbox-runtime/package.json')
|
||||
const names = ['java-proxy-agent/srt-proxy-agent.jar']
|
||||
for (const cpu of arch ? [arch] : ['x64', 'arm64']) {
|
||||
if (!platform || platform === 'linux') names.push(`seccomp/${cpu}/apply-seccomp`)
|
||||
if (!platform || platform === 'windows') names.push(`srt-win/${cpu}/srt-win.exe`)
|
||||
}
|
||||
const assets = Object.fromEntries(
|
||||
await Promise.all(
|
||||
names.map(async (name) => [
|
||||
name,
|
||||
(await readFile(path.join(path.dirname(packageJson), 'vendor', name))).toString(
|
||||
'base64',
|
||||
),
|
||||
]),
|
||||
),
|
||||
)
|
||||
return {
|
||||
contents: `export const bundledSrtVendor = ${JSON.stringify(assets)}`,
|
||||
loader: 'js',
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user