> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # StorageBrowserRef `StorageBrowserRef` 是附加至已儲存 Agent 的 inline 瀏覽器配置。`provider` id 會在 hydrate 時,根據已在 [`MastraEditor.browsers`](https://mastra.zisheng.pro/zh-HK/reference/editor/mastra-editor) 註冊的 [`BrowserProvider`](https://mastra.zisheng.pro/zh-HK/reference/editor/browser-provider) 解析。 這是 [`BuilderAgentDefaults.browser`](https://agent-builder.mastra.ai/reference/builder-agent-defaults) 及已儲存 Agent 記錄使用的類型。 ## 使用範例 ```typescript import { MastraEditor } from '@mastra/editor' import { stagehandBrowserProvider } from '@mastra/stagehand' new MastraEditor({ browsers: { [stagehandBrowserProvider.id]: stagehandBrowserProvider }, builder: { enabled: true, configuration: { agent: { browser: { type: 'inline', config: { provider: 'stagehand', headless: true, viewport: { width: 1280, height: 720 }, }, }, }, }, }, }) ``` ## 類型 ```typescript type StorageBrowserRef = { type: 'inline'; config: StorageBrowserConfig } ``` 瀏覽器不提供 `{ type: 'id' }` 變體:它們一律以 inline 方式加入。 ## 屬性 **type** (`'inline'`): 判別欄位。必須是字面值 "inline"。 **config** (`StorageBrowserConfig`): Provider id 及每個實例的瀏覽器配置。請參閱下節。 ## `StorageBrowserConfig` 嵌入 `config` 下的資料結構,定義於 `@mastra/core/storage`。 **provider** (`string`): Provider 標識符(例如 "stagehand")。必須符合已在 MastraEditor.browsers 註冊的 BrowserProvider.id。沒有內置 Provider。 **headless** (`boolean`): 以 headless 模式執行瀏覽器(不顯示 UI)。 (Default: `true`) **viewport** (`{ width: number; height: number }`): 瀏覽器 viewport 尺寸,控制視窗大小及網頁呈現方式。 **timeout** (`number`): 瀏覽器操作的預設逾時時間(毫秒)。 (Default: `10000`) **screencast** (`ScreencastOptions`): 將瀏覽器影格串流至 UI 的 screencast 選項。 **screencast.format** (`'jpeg' | 'png'`): 圖片格式。 **screencast.quality** (`number`): JPEG 品質,範圍為 0–100。 **screencast.maxWidth** (`number`): 最大闊度(像素)。 **screencast.maxHeight** (`number`): 最大高度(像素)。 **screencast.everyNthFrame** (`number`): 每隔 N 個影格擷取一次。 ## Hydrate 流程 `StorageBrowserRef` 會在 `mastra.editor.agent.getById()` 中延遲解析。Editor 會在 `MastraEditor.browsers` 查找 `config.provider`,再呼叫 `provider.createBrowser(config)`。如果 Provider 未註冊,Editor 會記錄警告並傳回 `undefined`:Agent 仍會載入,但不會有瀏覽器。 ## 相關內容 - [Browser](https://agent-builder.mastra.ai/browser):概念及完整範例。 - [BrowserProvider](https://mastra.zisheng.pro/zh-HK/reference/editor/browser-provider):供實作者使用的 Provider 介面。 - [BuilderAgentDefaults](https://agent-builder.mastra.ai/reference/builder-agent-defaults):將此類型固定為 Builder 預設值的位置。 - [StorageWorkspaceRef](https://mastra.zisheng.pro/zh-HK/reference/editor/storage-workspace-ref):Workspace 配置的同類引用類型。