Open-source, local-first AI agent for real work.
TypeScript agent-toolsai-agentbyokcoding-agentcross-platformdesktop-appdeveloper-toolselectronharnessknowledge-basellmwikilocal-firstmcpplugin-systemprivacy-firstskillstypescriptvettaworkflow-automation
import type { ComponentType, ReactNode } from "react";
import type { ConversationMessage } from "./conversation.js";
import type { Disposable } from "./disposable.js";
import type { PluginImageRef } from "./images.js";
import type { PluginPromptAttachment } from "./prompt-attachment.js";
import type { ConversationScenario } from "./scenario.js";
import type { PluginShortcutScopeContribution } from "./shortcuts.js";
export interface PluginGlobalSlotContribution {
id: string;
component: ComponentType;
}
export interface PluginAbilityDetailSlotProps {
abilityId: string;
installed: boolean;
enabled: boolean;
}
/** Inline setup/status surface rendered near the top of one ability detail page. */
export interface PluginAbilityDetailSlotContribution {
id: string;
abilityId: string;
component: ComponentType<PluginAbilityDetailSlotProps>;
}
/**
* Props handed to a workspace-view component. A workspace view owns the whole
* content area, so unlike panel slots it is addressed by its own route and can
* be deep-linked; the host passes back its identity so one component can serve
* several registered views.
*/
export interface PluginWorkspaceViewProps {
/** The contribution id as registered (NOT namespaced). */
viewId: string;
/** The owning plugin id. */
pluginId: string;
}
/**
* Badge tone. The host maps it to its own theme colors — a plugin cannot pick a
* raw color, so badges stay consistent with the built-in navigation entries.
*/
export type PluginNavBadgeTone = "accent" | "danger" | "default" | "warning";
/**
* A badge on the plugin's sidebar navigation entry.
*
* `beta` is the host's own preset — it renders exactly like the built-in
* 知识库 Beta 标识, wording included (and localized by the host), so plugins do
* not have to spell "Beta" themselves in every locale.
*
* `count` renders `99+` past 99 and disappears at 0 — an unread badge showing
* "0" is worse than no badge.
*/
export type PluginNavBadge =
| { kind: "beta" }
| { kind: "text"; text: string; tone?: PluginNavBadgeTone }
| { kind: "count"; count: number; tone?: PluginNavBadgeTone }
| { kind: "dot"; tone?: PluginNavBadgeTone };
/**
* A **workspace view**(工作区视图): a full-page surface a plugin contributes to
* the host's primary navigation. It is the plugin counterpart of a built-in page
* such as 自动化 / 知识库 — the host gives it its own route
* (`/workspace/<pluginId>/<viewId>`) and a sidebar entry, and the plugin owns the
* entire content area while it is open.
*
* Use it for standalone workbenches that are NOT bound to one conversation
* (dashboards, boards, consoles). Conversation-scoped UI belongs in an
* {@link PluginActivityTabContribution activity tab}; floating UI belongs in a
* {@link PluginGlobalSlotContribution global slot}.
*/
export interface PluginWorkspaceViewContribution {
/** Unique within the plugin; the host namespaces it as `${pluginId}:${id}`. */
id: string;
/** Sidebar entry label. Supports `%catalogKey%` i18n lookup. */
label: string;
/**
* Sidebar entry icon as an **iconify class string** (e.g.
* `"icon-[solar--widget-5-linear]"`) — NOT a React node, because the host
* renders it inside its own nav button and persists nav layout by key.
*
* Omit it to inherit the plugin's own `plugin.json` icon: a packaged image
* (svg / png / webp …) is masked with the theme's foreground color, so a plugin
* that ships artwork does not have to find a lookalike in an icon set. Set
* {@link PluginWorkspaceViewContribution.iconTint} to `false` to keep its colors.
*/
icon?: string;
/**
* Whether an image icon is tinted with the theme's foreground color. Defaults to
* `true`, which keeps the entry consistent with the built-in navigation and legible
* in every theme.
*
* Pass `false` for a full-color logo. Weigh it first: the entry renders at 16px
* beside monochrome built-ins, and a fixed-color image cannot follow the active
* theme — a dark logo can disappear on a dark sidebar. Has no effect on Iconify
* class icons, which are always tinted.
*/
iconTint?: boolean;
/** Optional one-line description; shown as the nav entry tooltip. */
description?: string;
/**
* Initial badge on the sidebar entry. `{ kind: "text" }` supports the same
* `%catalogKey%` i18n lookup as {@link label}. Update it at runtime with
* {@link PluginUiApi.setWorkspaceViewBadge}.
*/
badge?: PluginNavBadge;
/** Zero-props aside from {@link PluginWorkspaceViewProps}. */
component: ComponentType<PluginWorkspaceViewProps>;
/** Sort hint among this plugin's own views (ascending). Defaults to 0. */
navOrder?: number;
/**
* Whether this view takes a sidebar entry. Defaults to `true`.
*
* Pass `false` for a surface users open occasionally — a setup page, a
* diagnostics console. It then lives only under Settings → More options,
* where the host lists every off-sidebar view and opens it inside the
* settings shell, so switching between such pages stays one click.
*
* The sidebar is a scarce, user-curated space: a plugin that always claims a
* slot pushes the entries someone actually uses into the overflow menu.
*/
sidebar?: boolean;
}
/**
* What a workspace view puts into the **host page header** — the window's top
* bar that also carries the drag region, the macOS traffic-light gutter and the
* sidebar trigger.
*
* Without this the header still renders, showing the app name above the
* plugin's own toolbar — two stacked bars. Set `hideTitle` and move the view's
* toolbar in here and the surface gets a single, host-consistent header.
*
* `left` / `right` are ReactNodes rendered by the host inside that bar (left:
* right after the sidebar trigger; right: before the window controls). They are
* rendered in the plugin's i18n + CSS scope, so `useTranslation()` and the
* plugin's own classes work as usual. Pass fresh nodes whenever the view's
* state changes — this is a live setter, not a one-time registration.
*/
export interface PluginWorkspaceViewHeader {
/** Replaces the host title text. Supports `%catalogKey%` i18n lookup. */
title?: string;
/** Drop the host title entirely (use when {@link left} carries its own). */
hideTitle?: boolean;
/** Rendered in the header's left cluster, after the sidebar trigger. */
left?: ReactNode;
/** Rendered in the header's action cluster, before the window controls. */
right?: ReactNode;
/**
* Float the host header OVER the view instead of stacking above it. The view
* then owns the full content height, and its top `~44px` sit under the
* transparent header strip (window drag region / traffic lights / sidebar
* trigger all keep working on top). Use for immersive full-page surfaces
* whose own hero starts at the very top; leave unset for toolbar-style
* headers that need their own opaque row.
*/
immersive?: boolean;
}
export interface PluginAudioMetadata {
/** Embedded title; preview renderers should fall back to file.name. */
title?: string;
artist?: string;
/** Embedded cover art as a Data URL when available. */
coverDataUrl?: string;
}
export interface PluginPreviewUrlOptions {
/** Optional media hint for ambiguous containers such as webm. */
mediaKind?: "audio" | "video";
}
/**
* The file handed to a file-preview plugin component. The host does NOT
* pre-read or guess encoding — the plugin decides whether to read text or
* bytes. `path` is also exposed for plugins that prefer native fetch.
*/
export interface PluginPreviewFile {
path: string | null;
name: string;
extension: string;
mime: string;
size: number;
/** Read the file as a UTF-8 string. */
readText(): Promise<string>;
/** Read the raw file bytes. */
readBytes(): Promise<ArrayBuffer>;
/** A fetchable streaming URL for the file (Range-capable). */
getUrl(options?: PluginPreviewUrlOptions): string;
/**
* Subscribe to on-disk changes of this file. The listener fires (debounced
* by the host) whenever the file's contents change, letting previews update
* live. Returns a Disposable; call dispose() to stop watching. A no-op for
* files without a real path (url-only sources).
*/
watch(listener: () => void): Disposable;
/**
* Host-provided audio metadata for local media files. Returns null when the
* host cannot provide metadata, e.g. url-only sources or unsupported files.
*/
getAudioMetadata?(): Promise<PluginAudioMetadata | null>;
}
export interface PluginFilePreviewProps {
file: PluginPreviewFile;
}
/**
* A file handed to {@link PluginUiApi.previewFile} — the *opening* side of the
* global previewer, the mirror image of {@link PluginPreviewFile} (which is the
* *rendering* side). Bytes never cross over: the host reads the source itself.
*
* Exactly one of `path` (local absolute path) or `url` (host media / http URL)
* must be given. `path` is the shape the host's own file tree uses, so the
* previewer also offers "在 Finder 中显示" for it.
*/
export interface PluginPreviewFileRef {
/** Local absolute path. Requires the `fs.read` permission. */
path?: string;
/** Fetchable URL (host media URL or http/https). Requires `ui.slot.message`. */
url?: string;
/**
* Display name **including the extension** — the previewer dispatches to a
* renderer by this extension, not by `mimeType`. Optional for `path`
* sources (the host falls back to the path's basename).
*/
name?: string;
mimeType?: string;
/** Byte size, shown in the previewer's download detail when known. */
size?: number;
}
export interface PluginFilePreviewContribution {
/** Lower-case extensions without the dot, e.g. ["svg"]. */
extensions: string[];
component: ComponentType<PluginFilePreviewProps>;
}
/** Host residency policy for an activity-panel tab. */
export type PluginActivityTabRetention = "active-only" | "warm" | "pinned";
/**
* 活动面板标签卡此刻所在的工作空间。`cwd` 与面板自己的作用域一致(项目详情页是项目根,
* 会话页是会话 cwd),插件据此判断这个工作空间该不该出现自己的标签卡。
*/
export interface PluginActivityTabScope {
readonly cwd: string | null;
}
/**
* 一帧的标签卡状态,由 {@link PluginActivityTabContribution.useMeta} 按当前工作空间返回。
* 只影响「在不在栏上」这类摆放语义;名字与图标仍以注册时声明为默认值。
*/
export interface PluginActivityTabMeta {
/** 覆盖注册时的 label(已本地化);省略时用注册值。 */
readonly label?: string;
/** 覆盖注册时的 icon;省略时用注册值(含 `plugin.json#icon` 回落)。 */
readonly icon?: ReactNode;
/** 标签卡角标;0 / 省略表示不显示。 */
readonly badge?: number;
/**
* 固定上栏:只要本帧返回的 meta 非空且 `pinned` 为 true,标签卡就一直在标签栏里,
* 用户无法用减号移除,也不受「+」可添加池与历史隐藏记录左右。适合「工作空间里有
* 这个东西就必须看得到」的面板(如项目根存在 `.git` 的 Git 面板)。
*
* 省略 = 按用户的上栏记录 / `initiallyVisible` 决定,用户仍可移除。
*/
readonly pinned?: boolean;
}
/** {@link PluginActivityTabContribution.useMeta} 的返回:null = 本帧不进入候选。 */
export type PluginActivityTabMetaResult = PluginActivityTabMeta | null;
export interface PluginActivityTabContribution {
/**
* 这张卡需要的面板宽度:像素值,或 `"max"`(跟随窗口拉满)。画布、预览这类宽内容卡声明它。
*
* 面板宽度按选中的标签卡决定:声明了 `defaultWidth` 的卡用它自己的宽度,用户在它上面拖出的
* 宽度也只记在这张卡上;没声明的卡共用用户给普通卡定的宽度(默认 360)。用户拖过就以用户为准,
* 双击分隔条回到这里声明的值。Plugin API `^2.14.0`;旧宿主忽略。
*/
defaultWidth?: number | "max";
/**
* 标签栏上的默认相对位置,越小越靠前;缺省 100(排在全部内置标签卡之后)。
*
* 内置的取值可作标尺:文件 0、批量 10、浏览器 15、计划 18、待办 20、后台任务 30。
* 下限被宿主钳到 10,「文件」永远是第一枚;用户拖拽出来的顺序优先于这个值。
*/
order?: number;
id: string;
label: string;
/**
* Tab icon as a React node (not an iconify class string).
* Omit to inherit the host-resolved brand icon from `plugin.json#icon`
* (`ctx.plugin.iconUrl`). Prefer omitting for package brand icons so the
* plugin never loads assets via absolute `/…` paths or host protocols.
*/
icon?: ReactNode;
component: ComponentType;
/**
* 允许该标签卡出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:
* 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如
* `["project", "conversation"]`)。会话页插槽据此随对话类型显隐。
*/
scope_use?: readonly ConversationScenario[];
/**
* 注册后是否默认在标签栏里(缺省 `true`)。声明 `false` 表示「出现条件由我
* 自己决定」——注册只是入池,之后由 {@link PluginUiApi.setActivityTabVisible}
* 或 {@link PluginUiApi.openActivityTab} 决定何时上栏(如 git 只在仓库目录、
* 工作台跟随输入栏 toggle)。无论哪种,用户仍可用减号手动隐藏。
*/
initiallyVisible?: boolean;
/**
* Component residency while the tab is inactive. Defaults to `"warm"`:
* visited tabs stay mounted in the host's bounded LRU cache. Use
* `"active-only"` for cheap, stateless content and `"pinned"` for runtimes
* that must never be evicted while available.
*/
retention?: PluginActivityTabRetention;
/**
* @deprecated Use {@link PluginActivityTabContribution.retention}. `true`
* maps to `"pinned"`; `false` maps to `"active-only"`.
*/
keepAliveWhenAvailable?: boolean;
/**
* 按当前工作面决定这一帧的 meta:返回 `null` 表示本帧不进入候选(既不上栏,也不在
* 「+」里),返回 `{ pinned: true }` 表示固定上栏且不可移除。
*
* 这是一个 **React hook**:宿主每次解析标签栏时按「已注册定义」各调用一次,所以可以在
* 里面用任意 hook(自己的缓存 store、`useTranslation`……)。约束:
* - 渲染期必须是纯计算,探测一类的异步工作放进 `useEffect`,结果写回自己的 store;
* - 抛错只会让这一项消失(与 `null` 同效),不影响其它标签卡;
* - 省略时行为与本字段出现前一致:静态 label / icon / badge,按用户上栏记录显隐。
*/
useMeta?: (scope: PluginActivityTabScope) => PluginActivityTabMetaResult;
}
/**
* 会话底部面板的组件贡献。
*
* 与 {@link PluginActivityTabContribution} 的分工:活动面板在右侧、一个贡献只有一个
* 实例、适合「看某个东西的当前状态」;底部面板横跨会话页下沿、可分屏、**同一个贡献
* 可以开多个实例**,适合终端、日志跟随这类长驻的工作面。
*
* meta 走命令式的 {@link PluginBottomPanelContextValue.setMeta} 而不是「每帧返回 meta
* 的 hook」:多实例场景下 hook 拿不到实例身份,两套 meta 事实源会在改名后打架。
*/
export interface PluginBottomPanelContribution {
/** Unique within the plugin; the host namespaces it as `plugin:<pluginId>:<id>`. */
id: string;
/** 「+」菜单里的名字,也是新实例的初始名。Supports `%catalogKey%` i18n lookup. */
label: string;
/**
* Tab icon as a React node or an iconify class string.
* Omit to inherit the host-resolved brand icon from `plugin.json#icon`.
*/
icon?: ReactNode;
/** Zero-props;实例上下文经 {@link useBottomPanel} 取。 */
component: ComponentType;
/**
* 允许出现的对话场景 slug 列表。**fail-closed**:未声明/空数组 = 任何会话都不出现。
*/
scope_use?: readonly ConversationScenario[];
/** 「+」菜单里的相对位置,越小越靠前;缺省 100(排在内置之后)。 */
order?: number;
/**
* 同一会话里最多能开几个实例;缺省不限。单例面板给 1,终端一类不设。
*/
maxInstances?: number;
}
/** Explicit conversation scope for an activity-tab command. */
export interface PluginActivityTabTargetOptions {
/**
* Absolute cwd whose activity-tab state should be changed. Omit to target
* the conversation currently displayed by the host. Tool handlers and
* background work should pass the triggering session's cwd so a foreground
* navigation change cannot redirect the command to another conversation.
*/
cwd?: string;
}
/** Options for {@link PluginUiApi.openActivityTab}. */
export interface PluginOpenActivityTabOptions extends PluginActivityTabTargetOptions {
/**
* The width this tab wants: a pixel number, or `"max"` to track the widest
* the window allows. The host clamps to its min/max bounds.
*
* Since Plugin API `^2.14.0` this is the tab's **default** width (same as
* `defaultWidth` on registration, which is the preferred place to declare
* it): the panel width follows the selected tab, a width the user dragged on
* this tab always wins, and other tabs keep their own widths. Repeating the
* call (including `activate` replays) never overrides the user. When this
* call opens the panel, it slides in at the tab's width in one motion. Older
* hosts apply it only on first attach or when opening a closed panel.
*/
width?: number | "max";
/**
* The session on whose behalf the tab opens — pass `session.id` from the
* tool handler context. When that session is not the one the user is
* looking at (several conversations running at once), the host only puts
* the tab on that session's tab bar — it does not open the panel, switch
* its tab or resize it in front of the user, and switching to that session
* later does not open it either: the user opens it from the tab bar (guide
* them with a turn card if needed). Omit for calls the user triggered
* directly (a button or menu in the foreground), which always open.
* Plugin API `^2.14.0`; older hosts ignore it and open immediately.
*/
sessionId?: string;
}
/** Options for {@link PluginUiApi.setActivityPanelWidth}. */
export interface PluginActivityPanelWidthOptions {
/**
* Same as {@link PluginOpenActivityTabOptions.sessionId}: when that session
* is in the background the call is ignored, so it never resizes the panel
* the user is looking at. Plugin API `^2.14.0`; older hosts ignore it.
*/
sessionId?: string;
}
export interface PluginCaptureRegion {
x: number;
y: number;
width: number;
height: number;
}
/**
* Decoration a plugin contributes to the next outgoing prompt while its input
* action is active. `metadata` is shallow-merged into the prompt request and
* `instructions` are appended as hidden, model-visible guidance.
*/
export interface PluginPromptDecoration {
metadata?: Record<string, unknown>;
/** Hidden plugin-owned instructions appended to the next agent turn. */
instructions?: string[];
}
/**
* An action button shown in a row beneath the AI input bar. Rendered as a
* toggle: clicking activates, clicking again deactivates. While active, the
* host calls `decoratePrompt()` before each send and merges the returned
* metadata into the outgoing prompt request. The plugin owns any side state
* (it is the same Module Federation instance as its other slots).
*/
export interface PluginInputActionContribution {
id: string;
label: string;
/** Button icon as a React node. Omit to inherit the plugin's `plugin.json#icon`. */
icon?: ReactNode;
/** Whether the action begins in the active state. Defaults to false. */
defaultActive?: boolean;
/**
* 该输入动作所依赖的 agent 工具名。设置后,仅当该工具在当前会话处于激活(按工具的
* scope_use 解析)时才显示这个 badge——避免在工具被场景屏蔽(如批量任务)时仍显示一个
* 点了也无效的开关。不设则始终显示。例如「图像生成」设为 "generate_image"。
*/
requiresActiveTool?: string;
/**
* 允许该 toggle 出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:
* 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现。与 `requiresActiveTool`
* 取「与」:两者都满足才显示。
*/
scope_use?: readonly ConversationScenario[];
/**
* When true, this plugin's agent contributions (tools / skills / MCP /
* systemPrompt) and Activity Tabs are hard-isolated: inactive until this
* toggle is on (ADR-0041, knowledgeMode-style). Default false.
*/
hardIsolation?: boolean;
/**
* Fired when the user toggles the action; `active` is the new state. Return
* `false` when `active` is true to VETO the activation (e.g. the plugin needs
* configuration first) — the toggle stays off. Deactivation can't be vetoed.
*/
onToggle?(active: boolean): boolean | void;
/**
* Called by the host before sending while the action is active. The
* returned metadata is merged into the outgoing prompt request.
*/
decoratePrompt?(): PluginPromptDecoration | void;
}
/**
* A declarative, serializable descriptor for one card rendered beneath a
* message. `type` selects a registered card renderer; `key` drives cross-turn
* dedup (same key across turns = one logical card, shown only under its latest
* anchor); `payload` carries STABLE REFERENCES (e.g. image ids), not a content
* snapshot — the renderer resolves live state from it. `title`/`icon` label the
* card's tab (override the renderer's registration defaults). Rides a tool
* result's out-of-band `details.cards`; crosses the agent→host boundary, so
* `icon` is an icon-symbol string, not a node.
*/
export interface CardDescriptor {
type: string;
key?: string;
payload?: unknown;
title?: string;
icon?: string;
}
/** A pending (in-flight) tool call handed to a renderer's `pendingFor`. */
export interface PluginPendingToolCall {
toolName: string;
args: Record<string, unknown>;
}
/**
* Props for a card renderer. `descriptor` is the card's data; `pending` is true
* while it was synthesized from an in-flight tool (render a skeleton); `message`
* is the anchoring conversation message.
*/
export interface PluginCardProps {
descriptor: CardDescriptor;
pending: boolean;
message: ConversationMessage;
}
/**
* A card renderer registered by a plugin, keyed by `type`. A descriptor whose
* `type` matches is rendered by `component`. `title`/`icon` are the default tab
* label/icon (a descriptor may override either). `pendingFor`, given an
* in-flight tool call, returns a provisional descriptor so a skeleton card
* appears (and claims a tab) before the tool's result lands — or null when this
* renderer doesn't handle that tool. The `type` must be globally unique across
* plugins (convention: prefix with the plugin id, e.g. "image-gen:preview").
*/
export interface PluginCardRendererContribution {
type: string;
component: ComponentType<PluginCardProps>;
title?: string;
/** Default tab icon as a React node. Omit to inherit the plugin's `plugin.json#icon`. */
icon?: ReactNode;
pendingFor?: (toolCall: PluginPendingToolCall) => CardDescriptor | null;
}
/** A tool call handed to a tool-call slot renderer. */
export interface PluginToolCallSlotToolCall {
toolCallId: string;
toolName: string;
args: Record<string, unknown>;
status: "pending" | "success" | "error" | "cancelled";
result?: string;
isError?: boolean;
}
export interface PluginToolCallSlotProps {
toolCall: PluginToolCallSlotToolCall;
}
/**
* A component that **replaces the host's default inline transcript rendering**
* for a specific tool (matched by `toolName`; first registered renderer wins).
* This is how a plugin renders rich UI for its OWN agent tool's output — plugin
* tools cannot emit `details.cards`, so the message card system (registerCardRenderer)
* does not serve them; the tool-call slot does.
*/
export interface PluginToolCallSlotContribution {
id: string;
toolName: string;
component: ComponentType<PluginToolCallSlotProps>;
}
/**
* A card rendered at the bottom of the message list for the LATEST turn — NOT
* bound to a tool call. The host mounts `component` in the footer slot and
* re-mounts it each session/turn; the plugin owns visibility entirely (it reads
* live state via SDK hooks — `useActiveConversation`, `useConversationMessages`,
* `ctx.conversation.on("turn-end")` — and returns `null` to render nothing,
* e.g. git renders only inside a repo that has changes). `scope_use` gates which
* conversation scenarios it may appear in (**fail-closed**, mirrors the other
* slots). `id` must be unique within the plugin.
*/
export interface PluginTurnCardContribution {
id: string;
component: ComponentType;
/**
* 允许该 turn 卡出现的对话场景 slug 列表(镜像其它插槽的 scope_use)。**fail-closed**:
* 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如 `["project"]`)。
*/
scope_use?: readonly ConversationScenario[];
}
/**
* Options for {@link PluginUiApi.notify}. Surfaces a host toast so users can
* see plugin failures without opening DevTools.
*/
export interface PluginNotifyOptions {
/** Toast body. Required even when `error` is set (user-facing summary). */
message: string;
/** Defaults to plugin display name when omitted. */
title?: string;
/** Defaults to `"info"`; when `error` is set and variant omitted, host uses `"error"`. */
variant?: "info" | "success" | "warning" | "error";
/**
* Optional failure cause. Host formats message + stack and adds a
* "复制堆栈" action so the user can paste it into bug reports / chat.
*/
error?: unknown;
/**
* Auto-dismiss delay in ms. `0` keeps the toast until dismissed.
* Defaults: sticky (`0`) when `error` is present, otherwise host default (~4s).
*/
durationMs?: number;
}
/**
* 新会话上下文区的激活条件。**只能写本插件自己的东西**——填别人的 id 一律不生效。
*
* 这条限制是故意的:否则插件 A 可以声明「只要用户选了 B 的智能体我就上屏」,把别人的
* 使用场景劫持过来。
*
* 各字段取并集:任意一条命中即激活。至少要声明一条——全空等于「任何新会话都上屏」,宿主拒掉。
*/
export interface PluginNewSessionContextActivation {
/** 本插件在 manifest 里声明的智能体 id(不带 `plugin:` 前缀)。 */
agents?: readonly string[];
/** 本插件在 manifest 里声明的团队 id。省略则任意「含本插件成员的团队」都算命中。 */
teams?: readonly string[];
/** 本插件提供的 skill 名;用户在输入框里提到时命中。 */
skills?: readonly string[];
/** 本插件提供的 MCP server 名。 */
mcpServers?: readonly string[];
}
/** 用户在新会话页当前选中的对话目标。 */
export interface PluginNewSessionTarget {
readonly kind: "agent" | "team";
/** Agent 档案 id 或团队 id。 */
readonly id: string;
/** 目标若由本插件贡献,这里给出 manifest 里的那个 id。 */
readonly contributedId?: string;
}
/**
* 渲染上下文。这是一个**会继续生长的对象**:后续新增字段不会破坏既有插件,所以按需
* 解构、不要假定它只有这些键。
*/
export interface PluginNewSessionContext {
readonly target: PluginNewSessionTarget | null;
/** 输入框里提到的、属于本插件的能力。 */
readonly mentionedAbilities: {
readonly skills: readonly string[];
readonly mcpServers: readonly string[];
};
/**
* 输入框中尚未发送的文本。需要 `conversation.draft.read` 权限,未授予时恒为空串。
*
* 只在本贡献处于激活状态时提供——插件拿不到「用户随便打点什么」的全程流水。
*/
readonly draft: string;
/** 当前工作区目录;未选择项目时为 null。 */
readonly cwd: string | null;
/** 回写输入栏。刻意不提供「直接发送」:越过发送前这道关不属于本区职责。 */
readonly composer: {
/** 把资源挂成附件,随下一次发送带走。 */
attach(attachment: PluginPromptAttachment): void;
/**
* 往草稿里插一段文本。始终是插入而非替换,免得抹掉用户已经打的内容。
*
* `position` 缺省为 `"end"`(光标处)。`"start"` 插到最前面,适合「先定题、细节
* 由用户补」这类写法——用户点完多半光标并不在开头,位置只能由调用方定死。
*/
insertText(text: string, options?: { position?: "start" | "end" }): void;
};
}
/**
* 新会话页输入框下方的一块内容(`ui.slot.new-session-context`)。
*
* 与 input-action 的分工:那是发送前的开关,这是发送前的**上下文**——把用户接下来多半
* 要用到的素材摆出来。激活与否由宿主按 {@link PluginNewSessionContextActivation} 裁决,
* 插件只负责在被激活后渲染,因此拿不到用户逐键输入的全程内容。
*
* 同时有多个贡献上屏时,宿主会在该区域顶部出 tabbar;只有一个时直接渲染内容。
*/
export interface PluginNewSessionContextContribution {
id: string;
/** tabbar 上的标题;只有一个贡献上屏时不展示。 */
label: string;
/** tab 图标;省略时用插件自己的图标。 */
icon?: ReactNode;
activateWhen: PluginNewSessionContextActivation;
/**
* 横向占位。`"input"`(默认)与输入框同宽,适合补充说明一类的窄内容;`"wide"` 铺满
* 页面可用宽度,留给画廊、素材墙这类「内容本身就是主角」的东西——把它们压在输入框
* 宽度里,每一项都会小到看不清。
*/
width?: "input" | "wide";
render(context: PluginNewSessionContext): ReactNode;
}
/**
* 顶栏动作的下拉菜单项。点击一项执行 `onSelect` 并关闭菜单(`checkbox` / `radio` 例外,见
* {@link PluginHeaderActionMenuItemKind})。
*/
/**
* 菜单项的类型。省略即普通命令项;其余类型让「列表就是状态」的场景(分支列表、开关、
* 加载中、空态)不必退化成纯文字:
* - `checkbox` / `radio`:`checked` 决定勾选标记,点它触发 `onSelect` 后菜单不自动关(适合切换开关);
* - `label`:分组标题,不可点;
* - `loading` / `empty`:占位行,自动禁用、不可点;
* - `submenu`:`children` 是下一级菜单项(只支持一层)。
*/
export type PluginHeaderActionMenuItemKind =
| "item"
| "checkbox"
| "radio"
| "label"
| "loading"
| "empty"
| "submenu";
export interface PluginHeaderActionMenuItem {
/** 项在菜单内唯一的 id。 */
id: string;
/** 默认 `item`。 */
kind?: PluginHeaderActionMenuItemKind;
label: string;
/** 菜单项前的图标,16px 方框内显示。`checkbox` / `radio` 已选中时换成勾选标记。 */
icon?: ReactNode;
/** `submenu` 且给了 `children` 时可省略。 */
onSelect?: () => void;
/** `submenu` 的下一级菜单项。 */
children?: readonly PluginHeaderActionMenuItem[];
/** `checkbox` / `radio` 是否已选中。 */
checked?: boolean;
disabled?: boolean;
/** 禁用原因:禁用时排在 `title` 之前显示,用户才知道为什么点不了。 */
disabledReason?: string;
/** 危险操作(红色)。 */
destructive?: boolean;
/** 在这一项之前画一条分隔线。 */
separatorBefore?: boolean;
}
/** 顶栏动作气泡里的内容组件拿到的 props。 */
export interface PluginHeaderActionPopoverProps {
/** 关闭气泡(例如内容里点了「完成」)。 */
close: () => void;
}
/** 角标与图标的语义色,跟随宿主主题;`neutral` 为默认。 */
export type PluginHeaderActionTone = "neutral" | "info" | "success" | "warning" | "danger";
/** 气泡尺寸:`sm` 约 16rem,`md`(默认)约 24rem,`lg` 约 32rem。 */
export type PluginHeaderActionPopoverSize = "sm" | "md" | "lg";
/**
* 气泡的容器形态。默认 `popover`(贴着按钮的小浮层);内容是有输入框、列表等需要专注的界面时
* 用 `dialog`(宿主居中对话框,带标题栏与关闭按钮,宽度由 `size` 决定)。
*/
export type PluginHeaderActionPopoverHost = "popover" | "dialog";
/** 气泡声明:直接给组件,或给组件加容器参数。 */
export type PluginHeaderActionPopover =
| ComponentType<PluginHeaderActionPopoverProps>
| {
component: ComponentType<PluginHeaderActionPopoverProps>;
size?: PluginHeaderActionPopoverSize;
host?: PluginHeaderActionPopoverHost;
title?: string;
};
/** 顶栏动作此刻能拿到的上下文:它在哪个页面、当前工作目录是什么。 */
export interface PluginHeaderActionContext {
/**
* 当前页面。`conversation` = 会话页;`new-session` = 新会话页(还没有消息,
* 顶栏只有置顶与活动面板开关)。
*/
surface: PluginHeaderActionSurface;
/** 当前工作目录;没有项目(例如空白新会话)时为 `null`。 */
cwd: string | null;
}
/** 顶栏动作可以出现的页面。 */
export type PluginHeaderActionSurface = "conversation" | "new-session";
/**
* 顶栏动作此刻的**声明**,由 {@link PluginHeaderActionContribution.useAction} 返回。
*
* 宿主用它统一渲染成与内置按钮完全一致的一格;插件能决定的只有下面这些字段,没有 `className`、
* `style`,也无法替换按钮本身。默认**只有图标**,名称靠悬浮提示(`title`)显示;需要把状态
* 写在脸上时用 `label`(宽屏才显示,窄了自动退回图标)。
* `click` / `menuItems` / `popover` **三选一**:
* 同时给多个时按 `menuItems` > `popover` > `onClick` 取第一个;一个都没有则该动作不显示。
*
* 宿主会校验并截断:`title` 最长 40 字、`label` 最长 24 字(超出截断),`menuItems` 最多
* 20 项,`badge` 只接受数字(≥ 1,超过 99 显示 `99+`)或 `true`(红点)。
*/
export interface PluginHeaderActionState {
/** 必填。悬浮提示、无障碍名称(按钮上不显示文字时,用户全靠它认出这个动作)。 */
title: string;
/**
* 必填。图标节点,宿主放进 16px 的固定方框里并忽略指针事件,建议直接用
* iconify 的 `<span className="icon-[solar--…]" />`。
*/
icon: ReactNode;
/**
* 图标右侧的文字,用于「状态本身就是文字」的动作(分支名、当前模型、同步落后数)。
* 最长 24 字;顶栏有位置时显示,被收纳、页头挤窄、顶栏超过 4 格时自动退回纯图标
* (`labelRole: "readout"` 不受 4 格限制,见下)。
*/
label?: string;
/**
* 文字的角色。默认 `"caption"`:文字是按钮名称的补充,顶栏超过 4 格时收起。
* `"readout"`:文字就是要展示的、随时间变化的状态值(如 `≈123 tok/s`),顶栏超过 4 格时仍显示,
* 被 `promoteWhenActive` 露出时也显示;被收纳或页头挤窄时照样只剩图标,所以读数仍要写进 `title`。
* 只给读数用,命令名称不要标成 readout。Plugin API `^2.13.0`;旧宿主忽略此字段,表现与 `"caption"` 相同。
*/
labelRole?: "caption" | "readout";
/** 角标:数字显示计数,`true` 显示红点。被收纳时宿主会把它汇总到收纳入口上。 */
badge?: number | boolean;
/** 角标与图标的语义色,默认 `neutral`(灰色数字 / 本色图标)。 */
tone?: PluginHeaderActionTone;
/** 选中态(例如面板已打开)。 */
active?: boolean;
disabled?: boolean;
/** 禁用原因:禁用时替代 `title` 显示,用户才知道为什么点不了。 */
disabledReason?: string;
/**
* 处于选中态时,即使被收纳也要在活动面板开关左侧露出来(例如「正在录制」这类必须可见的状态)。
* 只在顶栏有活动面板开关的页面上生效。
*/
promoteWhenActive?: boolean;
/** 点击直接执行。 */
onClick?: () => void;
/** 点击向下弹出下拉菜单。 */
menuItems?: readonly PluginHeaderActionMenuItem[];
/**
* 点击弹出气泡,内容是你自己的组件。气泡的背景、圆角、投影由宿主固定,宽高随内容自适应;
* 被收纳时它会在收纳托盘里**内联展开**(宽约 260px),内容请能在这个宽度下正常显示。
*/
popover?: PluginHeaderActionPopover;
}
/**
* 会话页与新会话页顶栏右侧按钮组里的一格(`ui.slot.header-action`)。
*
* 顶栏右侧是**宿主统一管理的一个按钮组**:内置按钮(导出 / 置顶 / 终端 / 底部面板)与所有插件
* 贡献排在同一组里,外观由宿主决定,插件不能自定义样式。显示规则:
* - 顶栏最多显示 7 格(不含最右侧固定的「活动面板」开关),内置与插件共用这 7 个名额;
* - 超出的、以及用户主动收起的动作进入「收纳」托盘(悬浮在按钮组上时,组下方出现的小白条);
* - 用户可以在托盘里拖动调整顺序、决定哪些在顶栏哪些收纳,这份布局按动作 id 记在本机;
* - 新装插件的动作:顶栏还有空位就排进去,否则进收纳,不会挤走用户已有的布局;
* - `pin: "prefer"` 只是「用户没调整过时优先上栏」的建议,仍然用户可以改、也不突破 7 格上限。
* 所以插件**不能**假定自己一定在顶栏上,也不能依赖相邻的是谁。
*
* 出现页面由 `surfaces` 决定,默认只有会话页。
*/
export interface PluginHeaderActionContribution {
/** 贡献 id,在本插件内唯一,最长 64 字符。用户的布局按 `${插件 id}:${id}` 记忆,请不要随意改名。 */
id: string;
/**
* 默认排序权重,小的靠左。**只影响用户还没自己调整过时的初始位置**,省略按注册顺序排在最后;
* 同值按插件 id、贡献 id 稳定排序。
*/
order?: number;
/** 出现在哪些页面,默认 `["conversation"]`。 */
surfaces?: readonly PluginHeaderActionSurface[];
/**
* 初始布局建议。`"prefer"` 表示用户没调整过布局时优先占用顶栏的一个名额
* (仍受 7 格上限与用户后来的调整约束);默认 `"normal"`,即先待在收纳托盘里。
*/
pin?: "normal" | "prefer";
/**
* 返回动作此刻的声明,返回 `null` 表示当前不适用(例如没有项目目录),宿主不显示也不占位。
*
* 这是一个 **React hook**:宿主在对应页面顶栏挂载期间一直调用它,所以可以在里面用任意 hook
* (`useActiveConversation()`、`useTranslation()`、你自己的 store……),数据变化时自然重新声明。
* 入参给出当前页面与工作目录,可以据此决定是否出现、显示什么。
* 约束:
* - 渲染期必须是纯计算,不要在里面发请求、起定时器;这类副作用放进 `useEffect`;
* - 抛错只会让这一项消失(错误边界隔离),不会影响其它动作;
* - 每次渲染都可以返回新对象,宿主不依赖引用相等。
*/
useAction: (context: PluginHeaderActionContext) => PluginHeaderActionState | null;
}
/**
* 宿主左侧侧边栏此刻的形态。给插件自适应布局用——尤其是沉浸式工作区视图:
* 侧边栏收起时宿主页头会长出「展开侧边栏」按钮并占住左上角,视图自己画在那一带的
* 东西需要让位。
*/
export interface PluginSidebarState {
/** 用户手动收起了侧边栏。窄屏下这一位仍然只反映用户意愿,不受窗口宽度影响。 */
collapsed: boolean;
/** 窗口窄到侧边栏改走悬浮覆盖,不再占据左侧一栏。 */
narrow: boolean;
/** 侧边栏此刻是否实际占着左边那一栏。等价于 `!collapsed && !narrow`,多数自适应只需要这一位。 */
visible: boolean;
}
export interface PluginUiApi {
registerGlobalSlot(contribution: PluginGlobalSlotContribution): Disposable;
registerAbilityDetailSlot(contribution: PluginAbilityDetailSlotContribution): Disposable;
/** Render an opaque setup URL as a host-themed PNG data URL. */
createQrCode(text: string): Promise<string>;
/**
* Register a **workspace view**(工作区视图)— a full-page surface with its own
* route and sidebar entry, on par with the host's built-in pages. Needs the
* `ui.slot.workspace-view` permission (missing permission = **warn+noop**).
*
* The entry lands in the sidebar's「更多」收纳 by default; the user can pin it
* to the top region or reorder it, and that layout is remembered.
*/
registerWorkspaceView(contribution: PluginWorkspaceViewContribution): Disposable;
/**
* Register a **new-session context block** — content shown beneath the input
* on the new-session page, surfaced only when the user's current selection or
* draft matches {@link PluginNewSessionContextActivation}. Needs the
* `ui.slot.new-session-context` permission (missing permission = **warn+noop**).
*/
registerNewSessionContext(contribution: PluginNewSessionContextContribution): Disposable;
/**
* Register a **header action** — one declarative slot in the conversation
* page header's host-managed button group (icon / badge plus a click,
* menu or popover; no custom styling — see
* {@link PluginHeaderActionContribution}). The user decides, via the group's
* overflow tray, which actions sit in the header (max 7 shared with the host's
* own buttons) and in what order. Needs the `ui.slot.header-action`
* permission (missing permission = **warn+noop**) and Plugin API `^2.9.0`.
*/
registerHeaderAction(contribution: PluginHeaderActionContribution): Disposable;
/**
* Navigate to one of this plugin's own workspace views. `viewId` is the
* contribution id passed to {@link PluginUiApi.registerWorkspaceView}. No-op
* when the view is not registered (e.g. permission missing).
*/
openWorkspaceView(viewId: string): void;
/**
* Update (or clear, with `null`) the badge on one of this plugin's workspace
* view entries. Re-registering the view is NOT a way to do this — it would
* remount the whole surface — so live badges (unread counts, status dots)
* must come through here.
*
* No-op when the view is not registered (e.g. permission missing).
*/
setWorkspaceViewBadge(viewId: string, badge: PluginNavBadge | null): void;
/**
* Fill (or clear, with `null`) the host page header while one of this
* plugin's workspace views is open. Call it from the view component (an
* effect that re-runs on state change) and clear it on unmount — the host
* keeps the entry keyed by view, and only applies it on that view's route.
*
* The header itself is never removed: it owns the window drag region and the
* macOS traffic-light gutter. This is how a view takes it over instead.
*
* No-op when the view is not registered (e.g. permission missing).
*/
setWorkspaceViewHeader(viewId: string, header: PluginWorkspaceViewHeader | null): void;
/**
* Register a preview component keyed by file extension. The host dispatches
* registered extensions before its built-in fallback renderers; first
* registrant wins on conflict.
*/
registerFilePreview(contribution: PluginFilePreviewContribution): Disposable;
/**
* Register an activity-panel tab into the addable pool. The user attaches
* it manually via the panel's "+" picker; attach records are keyed by the
* workspace cwd. A contribution that declares `useMeta` decides its own
* availability per workspace (see {@link PluginActivityTabContribution.useMeta}).
*/
registerActivityTab(contribution: PluginActivityTabContribution): Disposable;
/**
* Register a component into the session's bottom panel addable pool. The user
* opens instances from the panel's "+" menu; one contribution can have several
* instances in the same session, and each instance renames itself through
* {@link useBottomPanel}.
*/
registerBottomPanel(contribution: PluginBottomPanelContribution): Disposable;
/**
* Register a toggle action shown beneath the AI input bar. While active,
* its `decoratePrompt()` annotates the next outgoing prompt.
*/
registerInputAction(contribution: PluginInputActionContribution): Disposable;
/**
* Register a card renderer keyed by `type`. Cards rendered beneath a message
* come from tool results' out-of-band `details.cards` (or `pendingFor` for
* in-flight tools); the host resolves each card's `type` to a registered
* renderer. Multiple cards under one message are shown as a tab-switcher
* ("收纳") or a flat list.
*/
registerCardRenderer(contribution: PluginCardRendererContribution): Disposable;
/**
* Register a renderer that replaces the host's default inline transcript UI
* for a tool call (matched by `toolName`). The complement to card renderers:
* use it to render UI for a plugin's own agent tool output.
*/
registerToolCallSlot(contribution: PluginToolCallSlotContribution): Disposable;
/**
* Register a card rendered at the bottom of the message list for the latest
* turn — NOT bound to a tool call. The host mounts the component in the
* footer slot; the plugin owns visibility (return `null` to render nothing,
* e.g. git renders only in a repo with changes). Gated by `scope_use`
* (fail-closed). Needs the `ui.slot.turn-card` permission.
*/
registerTurnCard(contribution: PluginTurnCardContribution): Disposable;
/**
* Register a keyboard shortcut scope on the host's shared ShortcutScopeStack
* (same path as host UI: modal > overlay > surface > app). Needs
* `ui.shortcuts.register`. Plugins cannot use kind `"app"` (reserved for
* host-configurable global actions). Prefer {@link usePluginShortcutScope}
* from React components with a module-captured `registerShortcutScope`.
*/
registerShortcutScope(contribution: PluginShortcutScopeContribution): Disposable;
/**
* Programmatically attach (if needed) and activate one of this plugin's
* own activity tabs in a conversation's activity panel. `tabId`
* is the contribution id passed to registerActivityTab. Any payload (e.g.
* which image to edit) is passed via the plugin's own in-memory state.
*
* Pass `options.width` to size the panel as it opens — a pixel number, or
* `"max"` to expand it to the widest the current window allows (the host
* still clamps to its min/max and auto-hides the sidebar when needed). Omit
* to leave the user's current width untouched.
*
* Omit `options.cwd` for the conversation currently displayed by the host.
* Tool handlers and background work should pass their session cwd explicitly,
* together with `options.sessionId`, so a tool running in a background
* conversation does not grab the panel the user is looking at.
*/
openActivityTab(tabId: string, options?: PluginOpenActivityTabOptions): void;
/**
* 把本插件的某个活动面板标签卡在目标会话里上栏 / 下栏,**不激活也不展开
* 面板**——`openActivityTab` 是「用户此刻要看它」,这个是「它现在该不该在
* 栏里」。配合 `initiallyVisible: false` 使用,插件即可完全掌握自己标签卡的
* 出现条件(如 git 只在仓库目录里上栏、工作台跟随输入栏 toggle)。
*
* 上栏记录按会话 cwd 持久化(ADR-0026),所以只需在条件变化时调用一次;
* 用户随后用减号手动隐藏的结果不会被重复调用覆盖。缺省作用于宿主当前显示的
* 会话;工具 handler 与后台任务应通过 `options.cwd` 传入自己的会话 cwd。既没有
* 显式 cwd、也没有活动会话时为 no-op(无处记录)。
*/
setActivityTabVisible(tabId: string, visible: boolean, options?: PluginActivityTabTargetOptions): void;
/**
* 给本插件**正在显示的**标签卡一个临时宽度:像素值,或 `"max"`(跟随窗口拉满,宿主仍会
* 夹到 min/max 内,必要时自动收起侧边栏)。用于标签卡内部切换模式时(如进出全宽的图谱视图)。
*
* Plugin API `^2.14.0` 起:只在面板当前选中的是本插件的卡时生效;切走这张卡即失效、
* 不落盘,也不改用户给面板定的宽度(用户拖一下就以用户为准)。这张卡**一直**需要的宽度
* 请用注册时的 `defaultWidth` 声明,不要在挂载时调用本方法——那样每次激活都会冲掉用户
* 在这张卡上拖出的宽度。旧宿主上它直接改面板宽度。
*/
setActivityPanelWidth(width: number | "max", options?: PluginActivityPanelWidthOptions): void;
/**
* 这个会话此刻是否在用户眼前:普通会话就是正在显示的那一个,团队会话里任一成员都算。
* 传工具 handler 上下文里的 `session.id`。用来决定一个工具的副作用该不该落到用户
* 眼前的界面上(例如把画布切到刚建好的设计),同时跑着几个会话时尤其要分清。
* Plugin API `^2.14.0`;旧宿主没有这个方法,调用前先判断是否存在。
*/
isSessionInView?(sessionId: string): boolean;
/**
* Bind or clear plugin-owned context for outgoing prompts. The host renders
* its label/icon and carries a structured `context` as a versioned snapshot.
* Attachments default to one-shot; `lifecycle: "sticky"` remains until the
* plugin or user clears the capsule.
*/
setPromptAttachment(attachment: PluginPromptAttachment | null): void;
/**
* Open the host's global full-screen image previewer for the given image.
* Only the image reference (id/url) crosses over — bytes stay out-of-band.
*
* Pass `group` (e.g. all images of the message) to open as an image group:
* the previewer shows a thumbnail strip + arrows and starts at `ref`.
*/
previewImage(ref: PluginImageRef, group?: PluginImageRef[]): void;
/**
* Open the host's global file previewer for any file — the general form of
* {@link PluginUiApi.previewImage}, which only takes image URLs. Accepts a
* local absolute `path` (the shape the host's own file tree uses) as well as
* a `url`; the previewer dispatches by the file's extension, so a file type
* some plugin registered via `registerFilePreview` lands in that renderer.
*
* Pass `group` (e.g. all outputs of one run) to open as a group: images get
* the thumbnail strip + arrows, and the previewer starts at `file`.
*
* Permissions: `fs.read` as soon as any entry carries a `path` (it hands a
* local file to the host to read); `ui.slot.message` for url-only calls,
* same gate as `previewImage`.
*/
previewFile(file: PluginPreviewFileRef, group?: PluginPreviewFileRef[]): void;
/**
* Capture a rectangle in the current Vetta window and open the host save
* dialog. Coordinates use renderer DIP values such as getBoundingClientRect().
* Requires `ui.slot.activity-tab`.
*/
captureRegion(rect: PluginCaptureRegion, defaultFileName: string): Promise<string | null>;
/**
* Copy an image to the system clipboard. Takes a `data:image/...;base64,`
* URL and goes through the native clipboard, so it does not depend on the
* renderer's `ClipboardItem` support. No permission required — the plugin
* can only write what it already rendered.
*/
copyImage(dataUrl: string): Promise<void>;
/**
* Hand a URL to the OS default browser (Electron `shell.openExternal`) —
* NOT the in-app browser panel. Only `http:`/`https:` are accepted; the host
* rejects every other protocol, so this cannot be used to launch arbitrary
* schemes. Needs `shell.openExternal`.
*/
openExternal(url: string): Promise<void>;
/**
* Show a global toast in the host UI (bottom-right). No permission required.
* Prefer this over swallowing errors into opaque UI copy: pass `error` so
* the host attaches a one-click "copy stack" action for the user.
*
* Capture `ctx.ui.notify` in `activate` if React components need it
* (components do not receive `ctx`).
*/
notify(options: PluginNotifyOptions): void;
/**
* 读当前侧边栏形态。无需权限——这是纯布局信息,不含任何用户数据。
*
* React 组件请改用 `useSidebarState()`:它会在状态变化时重渲染,不必自己订阅。
* 这一对只为拿不到 hook 的地方准备(`activate()` 内、工具处理器、命令式绘制的画布)。
*/
getSidebarState(): PluginSidebarState;
/**
* 订阅侧边栏形态变化——用户收起/展开侧边栏、或窗口跨过窄屏阈值时触发。
* 返回 Disposable 取消订阅;请在插件失活时释放。
*
* 回调按值去重:拖窗口不会把它打成回调风暴,只有三元组真的变了才通知。
*/
onSidebarStateChanged(listener: (state: PluginSidebarState) => void): Disposable;
}