跳到主要内容

Mastra.getEditor()

.getEditor() 方法用于获取 Mastra 实例中已配置的 Editor 实例。Editor 提供 CRUD 命名空间,可通过编程方式管理已存储的 Agent、prompt block、MCP client、Scorer、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
已配置的 editor 实例;如果未配置 editor,则为 undefined。