Plugin Runtime Helpers
在註冊期間注入每個外掛的 api.runtime 物件的參考。使用這些輔助函式,而不是直接 import 主機內部。
Runtime namespace
api.runtime.agent
Agent 身分、目錄與工作階段管理。
Session store 輔助函式 在 api.runtime.agent.session 下:
api.runtime.agent.defaults
預設模型與 provider 常數:
api.runtime.subagent
啟動與管理背景 subagent 執行。
模型覆蓋(provider/model)需要操作者透過 config 中的 plugins.entries.<id>.subagent.allowModelOverride: true 選擇加入。不受信任的外掛仍可執行 subagent,但覆蓋請求會被拒絕。
api.runtime.tts
文字轉語音合成。
使用核心 messages.tts 設定與 provider 選擇。傳回 PCM audio buffer + sample rate。
影像、音訊與影片分析。
當無產出時傳回 { text: undefined }(例如跳過的輸入)。
api.runtime.stt.transcribeAudioFile(...) 作為相容別名保留,對應 api.runtime.mediaUnderstanding.transcribeAudioFile(...)。
api.runtime.imageGeneration
影像生成。
api.runtime.webSearch
網路搜尋。
低階 media 工具。
api.runtime.config
Config 載入與寫入。
api.runtime.system
系統級工具。
api.runtime.events
Event 訂閱。
api.runtime.logging
記錄。
api.runtime.modelAuth
模型與 provider auth 解析。
api.runtime.state
State 目錄解析。
Memory tool factories 與 CLI。
api.runtime.channel
Channel 特定 runtime 輔助函式(當 channel 外掛載入時可用)。
儲存 runtime 參考
使用 createPluginRuntimeStore 來儲存 runtime 參考,供 register 回調外使用:
其他頂層 api 欄位
除了 api.runtime,API 物件也提供: