> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # WorkspaceSandbox **追加バージョン:** `@mastra/core@1.1.0` `WorkspaceSandbox` インターフェースは、Workspace がコマンドを実行し、バックグラウンドプロセスを管理する方法を定義します。 ## プロパティ **processes** (`SandboxProcessManager`): バックグラウンドプロセスマネージャー。実装されていない場合、プロセス管理 Tool は利用できません。SandboxProcessManager リファレンスを参照してください。 ## メソッド ### `start()` Sandbox を起動します。`workspace.init()` または最初の `executeCommand()` 呼び出しによって自動的に実行されます。 ```typescript await sandbox.start() ``` このメソッドは、コマンドを実行できるよう Sandbox を準備します。 ### `stop()` Sandbox を停止します。 ```typescript await sandbox.stop?.() ``` ### `destroy()` Sandbox のリソースを解放します。`workspace.destroy()` から呼び出されます。 ```typescript await sandbox.destroy() ``` ### `executeCommand(command, args?, options?)` シェルコマンドを実行します。 ```typescript 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`): 実行タイムアウト(ミリ秒)。 **options.cwd** (`string`): コマンドの作業ディレクトリ。 **options.env** (`Record`): 追加の環境変数。 **options.onStdout** (`(data: string) => void`): stdout ストリーミング用のコールバック。 **options.onStderr** (`(data: string) => void`): stderr ストリーミング用のコールバック。 ### `getInfo()` Sandbox のステータスとリソース情報を取得します。 ```typescript const info = await sandbox.getInfo() // { status: 'running', resources: { memoryMB: 512, cpuPercent: 5 } } ``` ### `getInstructions(opts?)` この Sandbox の動作を説明するテキストを返します。Workspace が Agent に割り当てられると、Agent のシステムメッセージに挿入されます。 ```typescript const instructions = sandbox.getInstructions?.() // 'Local command execution. Working directory: "/workspace".' ``` **パラメーター:** **opts.requestContext** (`RequestContext`): コンストラクターで instructions 関数を指定した場合、その関数に転送されます。 **戻り値:** `string` ## 関連項目 - [SandboxProcessManager リファレンス](https://mastra.zisheng.pro/ja/reference/workspace/process-manager) - [Sandbox](https://mastra.zisheng.pro/ja/docs/workspace/sandbox) - [Workspace クラス](https://mastra.zisheng.pro/ja/reference/workspace/workspace-class) - [Filesystem インターフェース](https://mastra.zisheng.pro/ja/reference/workspace/filesystem)