feat(code-runtime): execute Node programs through confined processes
This commit is contained in:
1 parent
f95f7ec8dc
commit
75ed8da3e0
54 files changed
+1933
-2277
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { Context } from '@deepseek-ai/cordis'
|
||||
import FileSystem from '@deepseek-ai/dsh-fs-local'
|
||||
import Subprocess from '@deepseek-ai/dsh-subprocess-local'
|
||||
import Sandbox from '@deepseek-ai/dsh-sandbox-local'
|
||||
import SandboxPolicy from '@deepseek-ai/dsh-sandbox-policy'
|
||||
import SessionProjections from '@deepseek-ai/dsh-session-projection'
|
||||
import type { SandboxMode } from '@deepseek-ai/dsh-sandbox'
|
||||
import NodeRuntime from '../src/index.ts'
|
||||
import type { Config } from '../src/index.ts'
|
||||
|
||||
export async function mountRuntime(ctx: Context, config: Config = {}, policy: { mode?: SandboxMode; workspaceRoot?: string } = {}) {
|
||||
if (!ctx.get('fs')) await ctx.plugin(FileSystem)
|
||||
if (!ctx.get('subprocess')) await ctx.plugin(Subprocess)
|
||||
if (!ctx.get('sandbox')) await ctx.plugin(Sandbox, {})
|
||||
if (!ctx.get('sessionProjections')) await ctx.plugin(SessionProjections)
|
||||
if (!ctx.get('sandboxPolicy')) await ctx.plugin(SandboxPolicy, { mode: 'danger-full-access', ...policy })
|
||||
await ctx.plugin(NodeRuntime, config)
|
||||
return ctx.codeRuntime as NodeRuntime
|
||||
}
|
||||
Reference in new issue
Block a user