importtype{Context}from'@deepseek-ai/cordis'exportfunctionapply(ctx: Context){ctx.effect(()=>{consttimer=setInterval(()=>{console.log('heartbeat')},5000)// The returned function runs when the plugin unloads.
return()=>clearInterval(timer)})}
声明依赖
如果你的插件需要使用其他服务(如 tools、llm),需要声明 inject:
importtype{Context}from'@deepseek-ai/cordis'exportconstname='my-tool-plugin'exportconstinject=['tools']exportfunctionapply(ctx: Context){// ctx.tools is ready here.
ctx.tools.register(/* ... */)}
import{Service,typeContext}from'@deepseek-ai/cordis'exportdefaultclassMyServiceextendsService{staticinject=['tools']constructor(ctx: Context){super(ctx,'myService')// Perform synchronous initialization in the constructor.
}}