> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # VercelServerlessSandbox コマンドを [Vercel](https://vercel.com) サーバーレス関数として実行します。自動スケーリングに対応した、グローバル分散型のインフラ管理不要な実行環境を提供します。インターフェースの詳細は、[WorkspaceSandbox インターフェース](https://mastra.zisheng.pro/ja/reference/workspace/sandbox)を参照してください。 > **警告:** VercelServerlessSandbox はステートレスです。永続 Filesystem、対話型シェル、長時間実行するバックグラウンドプロセスは提供しません。書き込み可能なのは `/tmp` のみで、その内容は呼び出し間で保持されません。 > **注記:** 永続 Filesystem、`sudo` アクセス、公開ポート、バックグラウンドプロセスを備えた完全な Linux MicroVM が必要な場合は、[`VercelSandbox`](https://mastra.zisheng.pro/ja/reference/workspace/vercel-sandbox) を使用してください。これは [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox) 製品を基盤とします。 ## インストール **npm**: ```bash npm install @mastra/vercel ``` **pnpm**: ```bash pnpm add @mastra/vercel ``` **Yarn**: ```bash yarn add @mastra/vercel ``` **Bun**: ```bash bun add @mastra/vercel ``` ## 使用方法 Workspace に `VercelServerlessSandbox` を追加して Agent に割り当てます。 ```typescript import { Agent } from '@mastra/core/agent' import { Workspace } from '@mastra/core/workspace' import { VercelServerlessSandbox } from '@mastra/vercel' const workspace = new Workspace({ sandbox: new VercelServerlessSandbox({ token: process.env.VERCEL_TOKEN, }), }) const agent = new Agent({ id: 'dev-agent', name: 'dev-agent', instructions: 'You are a coding assistant working in this workspace.', model: 'anthropic/claude-sonnet-4-6', workspace, }) ``` ### カスタムリソースを使用したチームスコープのデプロイ ```typescript const workspace = new Workspace({ sandbox: new VercelServerlessSandbox({ token: process.env.VERCEL_TOKEN, teamId: 'team_abc123', regions: ['iad1', 'sfo1'], maxDuration: 120, memory: 3008, env: { NODE_ENV: 'production', }, }), }) ``` ## コンストラクターパラメーター **token** (`string`): Vercel API トークン。未指定の場合は環境変数 VERCEL\_TOKEN を使用します。 **teamId** (`string`): チームスコープのデプロイに使用する Vercel チーム ID。 **projectName** (`string`): 既存の Vercel プロジェクト名。省略すると自動生成されます。 **regions** (`string[]`): デプロイ先のリージョン。 (Default: `['iad1']`) **maxDuration** (`number`): 関数の最大実行時間(秒)。 (Default: `60`) **memory** (`number`): 関数のメモリ容量(MB)。 (Default: `1024`) **env** (`Record`): デプロイする関数のソースに組み込む環境変数。動的に設定されるのではなく、デプロイ時に埋め込まれます。 **commandTimeout** (`number`): 呼び出しごとのコマンドタイムアウト(ミリ秒)。 (Default: `55000`) **instructions** (`string | ((opts) => string)`): getInstructions() が返すデフォルトの指示を上書きするカスタム指示。完全に置き換えるには文字列を、デフォルトを拡張するには関数を渡します。 **onStart** (`SandboxLifecycleHook`): Sandbox が running ステータスになった後に呼び出されるライフサイクルフック。 **onStop** (`SandboxLifecycleHook`): Sandbox が停止する前に呼び出されるライフサイクルフック。 **onDestroy** (`SandboxLifecycleHook`): Sandbox が破棄される前に呼び出されるライフサイクルフック。 ## プロパティ **id** (`string`): この Sandbox インスタンスの一意な識別子。 **name** (`'VercelServerlessSandbox'`): 人が読みやすい名前。 **provider** (`'vercel-serverless'`): Provider の種類を表す識別子。 **status** (`ProviderStatus`): 現在のライフサイクルステータス:'pending'、'starting'、'running'、'stopping'、'stopped'、'destroying'、'destroyed'、'error'。 ## 制限事項 VercelServerlessSandbox は内部でサーバーレス関数を使用するため、次の制限があります。 - **永続 Filesystem なし**:`/tmp` に書き込まれたファイルは一時的なもので、呼び出し間で消去されます。 - **対話型シェルなし**:コマンドは `/bin/sh -c` で実行され、stdin ストリーミングはありません。 - **バックグラウンドプロセスなし**:プロセスマネージャー、PID、長時間実行タスクは利用できません。 - **マウントなし**:クラウドストレージ(S3、GCS)のマウントには対応していません。 - **タイムアウト制限**:最大実行時間は `maxDuration`(デフォルト60秒)によって制限されます。 ## 関連項目 - [WorkspaceSandbox インターフェース](https://mastra.zisheng.pro/ja/reference/workspace/sandbox) - [Workspace クラス](https://mastra.zisheng.pro/ja/reference/workspace/workspace-class) - [E2BSandbox](https://mastra.zisheng.pro/ja/reference/workspace/e2b-sandbox):永続 Filesystem とプロセス管理を備えた高機能なクラウド Sandbox