跳至主要內容

Mastra.getEditor()

.getEditor() 方法用於擷取已在 Mastra 實例配置的編輯器實例。編輯器提供 CRUD 命名空間,讓你以程式方式管理已儲存的 Agent、提示區塊、MCP 用戶端、評分器、Skill 及 Workspace。

使用範例
使用範例 的直接連結

import { Mastra } from '@mastra/core'
import { MastraEditor } from '@mastra/editor'

const mastra = new Mastra({
editor: new MastraEditor(),
})

const editor = mastra.getEditor()

const agent = await editor?.agent.create({
id: 'support-agent',
name: 'Support Agent',
instructions: 'Help customers with their questions.',
})

參數
參數 的直接連結

此方法不接受任何參數。

傳回值
傳回值 的直接連結

editor:

MastraEditor | undefined
已配置的編輯器實例;如未配置編輯器,則為 undefined。