import type { Plugin } from "@opencode-ai/plugin" import { loadAgentPaaSConfig } from "../lib/agentpaas" import { approvalMonitor } from "../lib/approval-monitor" const plugin: Plugin = async ({ client }) => { const config = await loadAgentPaaSConfig().catch(() => undefined) if (!config) return {} const monitor = approvalMonitor(config, async (message) => { const response = await client.tui.showToast({ body: { title: "PaaS 待审批", message, variant: "warning", duration: 10000 }, }) if (response.error) throw new Error("提醒未投递") }) void monitor.poll().catch(() => undefined) return { async dispose() { monitor.dispose() }, async "tool.execute.after"(input) { if (input.tool.startsWith("agentpaas_")) void monitor.poll().catch(() => undefined) }, } } export default plugin