작업공간샌드박스
추가된 항목: @mastra/core@1.1.0
WorkspaceSandbox 인터페이스는 Workspace가 명령을 실행하고 백그라운드 프로세스를 관리하는 방식을 정의합니다.
속성속성에 대한 직접 링크
processes?:
SandboxProcessManager
백그라운드 프로세스 관리자입니다. 구현하지 않으면 프로세스 관리 Tool을 사용할 수 없습니다. SandboxProcessManager 레퍼런스를 참조하세요.
행동 양식행동 양식에 대한 직접 링크
start()start에 대한 직접 링크
Sandbox를 시작합니다. workspace.init() 또는 첫 번째 executeCommand() 호출 시 자동으로 호출됩니다.
await sandbox.start()
이 메서드는 명령 실행을 위해 샌드박스를 준비합니다.
stop()stop에 대한 직접 링크
샌드박스를 중지합니다.
await sandbox.stop?.()
destroy()destroy에 대한 직접 링크
샌드박스 리소스를 정리합니다. 호출자workspace.destroy().
await sandbox.destroy()
executeCommand(command, args?, options?)executecommandcommand-args-options에 대한 직접 링크
쉘 명령을 실행합니다.
const result = await sandbox.executeCommand('ls', ['-la', '/docs'])
const result = await sandbox.executeCommand('npm', ['install', 'lodash'])
매개변수:
command:
string
실행할 명령
args?:
string[]
명령 인수
options?:
Options
구성 옵션입니다.
Options
timeout?:
number
실행 제한 시간(밀리초)
cwd?:
string
명령의 작업 디렉터리
env?:
Record<string, string>
추가 환경 변수
onStdout?:
(data: string) => void
stdout 스트리밍 콜백
onStderr?:
(data: string) => void
stderr 스트리밍 콜백
getInfo()getinfo에 대한 직접 링크
샌드박스 상태 및 리소스 정보를 가져옵니다.
const info = await sandbox.getInfo()
// { status: 'running', resources: { memoryMB: 512, cpuPercent: 5 } }
getInstructions(opts?)getinstructionsopts에 대한 직접 링크
이 샌드박스의 작동 방식에 대한 설명을 반환합니다. 작업 영역이 Agent에 할당될 때 Agent의 시스템 메시지에 삽입됩니다.
const instructions = sandbox.getInstructions?.()
// 'Local command execution. Working directory: "/workspace".'
매개변수:
opts.requestContext?:
RequestContext
생성자에서
instructions 함수를 제공한 경우 해당 함수로 전달됩니다.보고: string