Skip to content
ZH

Plugins & API

This page is the unified reference for RelayCraft plugin capabilities and RelayCraft.api.

  • Left sidebar pages (api.ui.registerPage)
  • Standard UI slots (api.ui.registerSlot)
  • Traffic context menu actions (api.ui.registerContextMenuItem)
  • Rule automation (api.rules.createMock)
  • Traffic analytics (api.traffic.listFlows, api.traffic.getFlow)
  • Runtime-aware dashboards (api.host.getRuntime)

Plugin UI code receives:

  • RelayCraft.api: scoped plugin API
  • RelayCraft.components: curated host UI components
  • RelayCraft.icons: curated icon set

ProxyPilot is kept as a compatibility alias of RelayCraft.

Each plugin defines metadata, capabilities, and permissions in plugin.yaml.

manifestVersion: "1.0"
id: "com.example.my-plugin"
name: "My Plugin"
version: "0.1.0"
entry:
ui: "dist/index.js"
permissions:
- traffic:read
- rules:write
capabilities:
ui:
pages:
- id: "my-page"
title: "My Page"
icon: "Puzzle"
path: "/my-page"

Restricted API calls are blocked unless the permission is declared in permissions.

API MethodRequired Permission
stats.getProcessStatsstats:read
rules.listrules:read
rules.getrules:read
rules.createMockrules:write
traffic.listFlowstraffic:read
traffic.getFlowtraffic:read

host.getRuntime does not require additional permission.

  • t(key, options?)
  • changeLanguage(lng)
  • getCurrentLanguage()
  • register(theme)
  • remove(themeName)
  • list()
  • registerPage(page)
  • unregisterPage(pageId)
  • registerSlot(slotName, component, props?)
  • unregisterSlot(slotId)
  • registerContextMenuItem(item)
  • unregisterContextMenuItem(itemId)
  • toast(message, type?)
  • chat(messages)
  • complete(prompt, options?)
  • getProcessStats()
  • getStatus()
  • start()
  • stop()
  • restart()
  • get(key?)
  • set(key, value)
  • watch(key, cb)
  • info(message, context?)
  • warn(message, context?)
  • error(message, context?)
  • debug(message, context?)
  • send(request)
  • get(key)
  • set(key, value)
  • remove(key)
  • clear()
  • list()
  • on(eventName, callback)
  • off(eventName, callback)
  • emit(eventName, payload)
  • list(filter?)
  • get(id)
  • createMock(config)
  • listFlows(filter?)
  • getFlow(id, options?)
  • getRuntime()

Standard slot names:

  • sidebar-top
  • sidebar-bottom
  • status-bar-left
  • status-bar-center
  • status-bar-right
  • flow-detail-tabs
  • flow-detail-actions

Filter fields:

  • sessionId, method, host, urlPattern, status
  • offset, limit

Response fields:

  • flows[]
  • total, offset, limit, hasMore

Options:

  • includeBodies (default false)
  • maxBodyBytes (default 128KB, host hard cap 2MB)

Response includes request/response metadata and rule hit info.

  • RelayCraft keeps v1 APIs backward compatible.
  • New APIs are additive.
  • Permission checks are enforced at runtime by the host bridge.