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 — create, edit, and disable mocks the plugin owns (api.rules.createMock, getOwnMock, disableMock)
  • 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
ai.chat, ai.chatStreamai:chat
http.sendnetwork:outbound
proxy.getStatusproxy:read
stats.getProcessStatsstats:read
storage.get, storage.liststorage:read
storage.set, storage.delete, storage.clearstorage:write
rules.list, rules.getrules:read
rules.createMock, rules.disableMock, rules.getOwnMockrules:write
traffic.listFlows, traffic.getFlowtraffic:read

host.getRuntime and ui/theme/i18n/log/events/settings calls do not require additional permission.

  • t(key, options?)
  • language
  • onLanguageChange(callback) — returns an unsubscribe function
  • registerLocale(lang, resources)
  • register(theme)
  • set(themeId)
  • registerPage(page)
  • registerSlot(slotId, options) — options.component
  • registerContextMenuItem(config)
  • toast(message, type?)
  • components — shared host components: Editor, DiffEditor, Markdown
  • chat(messages)
  • chatStream(messages, onChunk, options?)
  • isEnabled()
  • getProcessStats()
  • getStatus()
  • get(key?) — read the plugin’s own settings
  • info(message, context?)
  • warn(message, context?)
  • error(message, error?)
  • send(request)
  • get(key)
  • set(key, value)
  • delete(key)
  • list(prefix?)
  • clear()
  • on(eventName, callback) — returns an unsubscribe function
  • list(filter?)
  • get(id)
  • createMock(config) — returns the new rule ID
  • getOwnMock(ruleId) — fetch a mock this plugin created, for editing
  • disableMock(ruleId) — disable a mock this plugin created
  • 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.