createNotificationInboxTool()
新增於: @mastra/core@1.39.0
createNotificationInboxTool() 會建立一個 Mastra Tool,讓 Agent 檢查和管理目前 thread 的通知收件匣記錄。
此 Tool 適用於持久通知 signal。如要傳送通知記錄,請參閱 Agent.sendNotificationSignal()。
使用範例使用範例 的直接連結
以下範例會將收件匣 Tool 加入 Agent。
src/mastra/agents/support-agent.ts
import { Agent } from '@mastra/core/agent'
import { createNotificationInboxTool } from '@mastra/core/notifications'
const notificationsStorage = await storage.getStore('notifications')
export const supportAgent = new Agent({
id: 'support-agent',
name: 'Support Agent',
instructions: 'Help the user triage updates.',
model: 'openai/gpt-5.6-sol',
tools: {
notificationInbox: createNotificationInboxTool({ storage: notificationsStorage }),
},
})
參數參數 的直接連結
options:
object
Tool 配置。
object
storage:
NotificationsStorage
由
storage.getStore('notifications') 傳回的通知儲存空間 domain。Tool 輸入Tool 輸入 的直接連結
產生的 Tool ID 為 notification-inbox,並接受以下輸入欄位。
action:
'list' | 'read' | 'markSeen' | 'dismiss' | 'archive' | 'search'
要執行的收件匣操作。
threadId?:
string
要檢查的 thread ID。如有目前的 Agent thread,預設使用該 thread。
id?:
string
通知 ID。
markSeen、dismiss 和 archive 必須提供;read 可選填。status?:
'pending' | 'delivered' | 'seen' | 'dismissed' | 'archived' | 'discarded'
用於 list、read 或 search 操作的狀態篩選條件。
priority?:
'low' | 'medium' | 'high' | 'urgent'
用於 list、read 或 search 操作的優先級篩選條件。
source?:
string
用於 list、read 或 search 操作的來源篩選條件。
query?:
string
搜尋查詢。當
action 為 search 時必須提供。limit?:
number
傳回通知的數目上限。必須是正整數。
操作操作 的直接連結
| 操作 | 說明 |
|---|---|
list | 傳回符合條件的通知。 |
read | 以 signal 傳送可讀取的通知內容,並將已傳送的記錄標記為已查看。 |
markSeen | 將一則通知標記為已查看。 |
dismiss | 將一則通知標記為已略過。 |
archive | 將一則通知標記為已封存。 |
search | 按查詢和可選篩選條件搜尋通知。 |
當 read 找到待處理或已傳送的通知時,Tool 會以通知 signal 傳送內容,而不會將完整內容當作一般 Tool 輸出傳回。Agent 在收到 <notification-summary> signal 後,如需要摘要背後的完整記錄,可使用此操作。