> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # 마스트라 수업 최상위 수준 가져오기를 제한하고 직접 속성 액세스를 getter 메서드로 대체하도록 Mastra 클래스가 재구성되었습니다. ## 변경됨 ### 하위 경로 가져오기로의 최상위 가져오기 이제 기본 `@mastra/core` 인덱스 파일은 `Mastra`와 `Config`만 내보냅니다. 다른 모든 내보내기는 하위 경로 가져오기로 이동되었습니다. 이 변경으로 번들러가 사용되지 않는 코드를 제거할 수 있어 트리 셰이킹이 개선되고 번들 크기가 줄어듭니다. 마이그레이션하려면 `@mastra/core`의 모든 가져오기를 적절한 하위 경로를 사용하도록 업데이트하세요. ```diff - import { Mastra, Agent, Workflow, createTool } from '@mastra/core'; + import { Mastra, type Config } from '@mastra/core'; + import { Agent } from '@mastra/core/agent'; + import { Workflow } from '@mastra/core/workflows'; + import { createTool } from '@mastra/core/tools'; ``` :::tip\[코드모드] Mastra의 codemod CLI를 사용하여 코드를 자동으로 업데이트할 수 있습니다. ```bash npx @mastra/codemod@latest v1/mastra-core-imports . ``` ::: ### `experimental_auth`에게`auth` 실험적 인증 구성이 안정 구성으로 승격되었습니다. 이 변경 사항은 인증 API가 이제 안정적이고 프로덕션 준비가 되었음을 반영합니다. 마이그레이션하려면 Mastra 구성에서 `experimental_auth` 키의 이름을 `auth`로 변경하세요. ```diff const mastra = new Mastra({ - experimental_auth: { + auth: { provider: workos, }, }); ``` :::tip\[코드모드] Mastra의 codemod CLI를 사용하여 코드를 자동으로 업데이트할 수 있습니다. ```bash npx @mastra/codemod@latest v1/experimental-auth . ``` ::: ### 모든 Mastra 기본 요소에 필수인 `id` 매개변수 이제 모든 스토리지, 벡터 저장소, Agent, Workflow, mcpServer, 프로세서, 채점기 및 Tool은 초기화할 때 `id` 매개변수가 필요합니다. 이를 통해 표준화된 Mastra API를 지원하고 ID 충돌을 방지합니다. 이제 이러한 모든 기본 요소에는 `get`, `list`, `add` 함수도 있습니다. 마이그레이션하려면 모든 스토리지 및 벡터 저장소 인스턴스화에 `id` 매개변수를 추가하세요. 동일한 스토리지/벡터 클래스를 여러 번 사용할 때는 각 인스턴스에 고유한 ID가 있는지 확인하세요. ```diff - const storage = new LibSQLStore({ - url: ':memory:', - }); + const storage = new LibSQLStore({ + id: 'my-app-storage', + url: ':memory:', + }); - const vector = new PgVector({ - connectionString: process.env.DATABASE_URL, - }); + const vector = new PgVector({ + id: 'my-app-vector', + connectionString: process.env.DATABASE_URL, + }); ``` 다양한 목적으로 별도의 인스턴스를 사용하는 경우 설명이 포함된 고유 ID를 사용하세요. ```diff const agentMemory = new Memory({ storage: new LibSQLStore({ - url: 'file:./agent.db', + id: 'weather-agent-memory-storage', + url: 'file:./agent.db', }), }); const mastra = new Mastra({ storage: new LibSQLStore({ + id: 'mastra-storage', url: ':memory:', }), }); ``` ### 기본 요소 복수형 API를 `get`에서 `list`로 변경 기본 요소의 모든 인스턴스를 반환하는 `get*` 함수는 목적을 더 잘 나타내도록 `list*`로 이름이 변경되었습니다. ```diff - const agents = mastra.getAgents(); + const agents = mastra.listAgents(); - const vectors = mastra.getVectors(); + const vectors = mastra.listVectors(); - const workflows = mastra.getWorkflows(); + const workflows = mastra.listWorkflows(); - const scorers = mastra.getScorers(); + const scorers = mastra.listScorers(); - const mcpServers = mastra.getMCPServers(); + const mcpServers = mastra.listMCPServers(); - const logsByRunId = await mastra.getLogsByRunId({ runId: 'id', transportId: 'id' }); + const logsByRunId = await mastra.listLogsByRunId({ runId: 'id', transportId: 'id' }); - const logs = await mastra.getLogs('transportId'); + const logs = await mastra.listLogs('transportId'); ``` :::tip\[코드모드] Mastra의 codemod CLI를 사용하여 코드를 자동으로 업데이트할 수 있습니다. ```bash npx @mastra/codemod@latest v1/mastra-plural-apis . ``` ::: ### 각 기본 요소에 `getById` 및 `get` 함수 제공 ```typescript mastra.getMCPServer('myServer') // Works (registry key) mastra.getMCPServerById('my-mcp-server') // Works (intrinsic ID) ``` ### Tool 등록은 이제 고유 ID를 사용합니다. Tool이 Agent 또는 MCP 서버에서 Mastra 인스턴스로 자동 등록되면 이제 구성 객체 키 대신 Tool 고유의 `id`를 사용합니다. 이를 통해 여러 Agent/MCP 서버에 구성 키가 같은 Tool이 있을 때 발생하는 충돌을 방지합니다. 마이그레이션하려면 구성 키로 Tool을 참조하는 코드를 업데이트하여 대신 Tool의 고유 ID를 사용하세요. ```diff const agent = new Agent({ id: 'agent1', tools: { searchTool: weatherSearchTool, }, }); - mastra.getTool('searchTool'); + mastra.getTool(weatherSearchTool.id); ```