WorkspaceSandbox
追加バージョン: @mastra/core@1.1.0
WorkspaceSandbox インターフェースは、Workspace がコマンドを実行し、バックグラウンドプロセスを管理する方法を定義します。
プロパティプロパティへの直接リンク
processes?:
SandboxProcessManager
バックグラウンドプロセスマネージャー。実装されていない場合、プロセス管理 Tool は利用できません。SandboxProcessManager リファレンスを参照してください。
メソッドメソッドへの直接リンク
start()startへの直接リンク
Sandbox を起動します。workspace.init() または最初の executeCommand() 呼び出しによって自動的に実行されます。
await sandbox.start()
このメソッドは、コマンドを実行できるよう Sandbox を準備します。
stop()stopへの直接リンク
Sandbox を停止します。
await sandbox.stop?.()
destroy()destroyへの直接リンク
Sandbox のリソースを解放します。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への直接リンク
Sandbox のステータスとリソース情報を取得します。
const info = await sandbox.getInfo()
// { status: 'running', resources: { memoryMB: 512, cpuPercent: 5 } }
getInstructions(opts?)getinstructionsoptsへの直接リンク
この Sandbox の動作を説明するテキストを返します。Workspace が Agent に割り当てられると、Agent のシステムメッセージに挿入されます。
const instructions = sandbox.getInstructions?.()
// 'Local command execution. Working directory: "/workspace".'
パラメーター:
opts.requestContext?:
RequestContext
コンストラクターで
instructions 関数を指定した場合、その関数に転送されます。戻り値: string