Skip to main content
xbot
切换暗/亮/自动模式 切换暗/亮/自动模式 切换暗/亮/自动模式 返回首页

权限字符串完整列表(plugin/permissions.go)。插件在 plugin.jsonpermissions 中声明。通配符 "*"(仅 Go 侧)授予全部;未知权限在 manifest 校验时失败。

后端权限(Go)

常量字符串授予
PermToolsRegistertools.register注册工具与中间件(RegisterToolRegisterToolsUseMiddleware)。
PermToolsCalltools.call调用工具。
PermHooksSubscribehooks.subscribe订阅生命周期 hook(OnPreToolUse 等)与注册插件错误回调。
PermContextEnrichcontext.enrich注册上下文注入器(EnrichContext)。
PermStoragePrivatestorage.private访问插件私有键值存储(Storage() 及类型化助手)。
PermStorageSharedstorage.shared访问共享插件存储。
PermNetworkOutboundnetwork.outbound发起出站网络请求。
PermBusReadbus.read从事件总线读取(配合 bus.plugin)。
PermBusWritebus.write发布到事件总线(配合 bus.plugin)。
PermBusPluginbus.plugin使用插件间事件总线。Subscribe 需要 bus.plugin+bus.readPublish 需要 bus.plugin+bus.write
PermUIContributeui.contribute贡献 UI widget(ContributeUI)。manifest 的 contributes.ui 同样要求此权限。
PermChannelsRegisterchannels.register注册自定义 Channel provider。
PermCommandsRegistercommands.register注册斜杠命令。
PermCronSchedulecron.schedule调度与取消定时任务。
PermUIThemesui.themes贡献主题(ContributeTheme)。
PermUIOverlayui.overlay注册与控制覆盖层(RegisterOverlayShowOverlayHideOverlay)。
PermNotificationsSendnotifications.send发送通知与播放音效(NotifyPlaySound)。

前端权限(Web 插件 v2)

web/src/plugin-api/manifest.tsPermission 类型一致,且同时注册在 Go 后端白名单(allPermissions)中——两份名单必须保持同步(不同步会导致 reload 失败:unknown permission "ui"):

权限授予(前端 PluginContext<P> 能力)
events类型化事件总线访问(ctx.events.on/once)。
commands命令注册/执行(ctx.commands.register/execute/registerKeybinding)。
rpc后端 RPC 调用(ctx.rpc.call/notify)。
state键值状态存储(ctx.state)。
uiUI 能力:toast、面板开关、编辑器视图 tab(ctx.ui.openViewTab/openFileTab)。
plugins插件间注册表(ctx.plugins)。
config插件配置 API(ctx.config)。

强制机制

  • GoPermissionCheckerNewPermissionCheckerHasHasAllHasAny)——pluginContextImpl 在每个能力调用处检查权限,违规返回 *PermissionError(通知类静默警告)。
  • Web:能力即类型——PluginContext<P> 仅暴露权限位于 P 中的能力接口;访问未声明能力是编译期错误。