Skip to main content

Plugin Runtime Helpers

在註冊期間注入每個外掛的 api.runtime 物件的參考。使用這些輔助函式,而不是直接 import 主機內部。
在找實作指南? 參考 Channel 外掛Provider 外掛,他們有逐步指南,展示這些輔助函式的實際使用。

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。

api.runtime.mediaUnderstanding

影像、音訊與影片分析。
當無產出時傳回 { text: undefined }(例如跳過的輸入)。
api.runtime.stt.transcribeAudioFile(...) 作為相容別名保留,對應 api.runtime.mediaUnderstanding.transcribeAudioFile(...)

api.runtime.imageGeneration

影像生成。

api.runtime.webSearch

網路搜尋。

api.runtime.media

低階 media 工具。

api.runtime.config

Config 載入與寫入。

api.runtime.system

系統級工具。

api.runtime.events

Event 訂閱。

api.runtime.logging

記錄。

api.runtime.modelAuth

模型與 provider auth 解析。

api.runtime.state

State 目錄解析。

api.runtime.tools

Memory tool factories 與 CLI。

api.runtime.channel

Channel 特定 runtime 輔助函式(當 channel 外掛載入時可用)。

儲存 runtime 參考

使用 createPluginRuntimeStore 來儲存 runtime 參考,供 register 回調外使用:

其他頂層 api 欄位

除了 api.runtime,API 物件也提供:

相關