@vetta-org/plugin-sdk 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/images.d.ts +2 -0
- package/dist/images.d.ts.map +1 -1
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +11 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +18 -0
- package/dist/logger.js.map +1 -0
- package/dist/logging.d.ts +26 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +38 -0
- package/dist/logging.js.map +1 -0
- package/dist/media.d.ts +20 -0
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js.map +1 -1
- package/dist/models.d.ts +4 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/official.d.ts +18 -1
- package/dist/official.d.ts.map +1 -1
- package/dist/official.js.map +1 -1
- package/dist/service-provider.d.ts +1 -0
- package/dist/service-provider.d.ts.map +1 -1
- package/dist/service-provider.js.map +1 -1
- package/dist/ui.d.ts +7 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/docs/.source.json +1 -0
- package/docs/README.md +3 -1
- package/docs/getting-started.md +19 -10
- package/docs/logging.md +41 -0
- package/docs/manifest.md +2 -2
- package/docs/media.md +19 -2
- package/docs/permissions.md +4 -0
- package/docs/styling-and-pitfalls.md +11 -2
- package/docs/system-plugins.md +2 -2
- package/docs/ui-slots.md +2 -0
- package/package.json +5 -1
package/dist/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,mBAA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AC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC7E;;;;;;;;;;OAUG;IACH,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,8BAA8B,GAAG,IAAI,CAAC;IACvG;;;;;;;;;;OAUG;IACH,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IACnD;;;;;OAKG;IACH,mBAAmB,CAAC,UAAU,EAAE,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAC;IACrE;;;;;;OAMG;IACH,YAAY,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAClE;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAC,IAAI,EAAE,oBAAoB,EAAE,KAAK,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAC;IAC9E;;;;OAIG;IACH,aAAa,CAAC,IAAI,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1F;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC3C;;;;;OAKG;IACH,eAAe,IAAI,kBAAkB,CAAC;IACtC;;;;;OAKG;IACH,qBAAqB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAAG,UAAU,CAAC;CACjF","sourcesContent":["import type { ComponentType, ReactNode } from \"react\";\nimport type { ConversationMessage } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginImageRef } from \"./images.js\";\nimport type { PluginPromptAttachment } from \"./prompt-attachment.js\";\nimport type { ConversationScenario } from \"./scenario.js\";\nimport type { PluginShortcutScopeContribution } from \"./shortcuts.js\";\n\nexport interface PluginGlobalSlotContribution {\n\tid: string;\n\tcomponent: ComponentType;\n}\n\nexport interface PluginAbilityDetailSlotProps {\n\tabilityId: string;\n\tinstalled: boolean;\n\tenabled: boolean;\n}\n\n/** Inline setup/status surface rendered near the top of one ability detail page. */\nexport interface PluginAbilityDetailSlotContribution {\n\tid: string;\n\tabilityId: string;\n\tcomponent: ComponentType<PluginAbilityDetailSlotProps>;\n}\n\n/**\n * Props handed to a workspace-view component. A workspace view owns the whole\n * content area, so unlike panel slots it is addressed by its own route and can\n * be deep-linked; the host passes back its identity so one component can serve\n * several registered views.\n */\nexport interface PluginWorkspaceViewProps {\n\t/** The contribution id as registered (NOT namespaced). */\n\tviewId: string;\n\t/** The owning plugin id. */\n\tpluginId: string;\n}\n\n/**\n * Badge tone. The host maps it to its own theme colors — a plugin cannot pick a\n * raw color, so badges stay consistent with the built-in navigation entries.\n */\nexport type PluginNavBadgeTone = \"accent\" | \"danger\" | \"default\" | \"warning\";\n\n/**\n * A badge on the plugin's sidebar navigation entry.\n *\n * `beta` is the host's own preset — it renders exactly like the built-in\n * 知识库 Beta 标识, wording included (and localized by the host), so plugins do\n * not have to spell \"Beta\" themselves in every locale.\n *\n * `count` renders `99+` past 99 and disappears at 0 — an unread badge showing\n * \"0\" is worse than no badge.\n */\nexport type PluginNavBadge =\n\t| { kind: \"beta\" }\n\t| { kind: \"text\"; text: string; tone?: PluginNavBadgeTone }\n\t| { kind: \"count\"; count: number; tone?: PluginNavBadgeTone }\n\t| { kind: \"dot\"; tone?: PluginNavBadgeTone };\n\n/**\n * A **workspace view**(工作区视图): a full-page surface a plugin contributes to\n * the host's primary navigation. It is the plugin counterpart of a built-in page\n * such as 自动化 / 知识库 — the host gives it its own route\n * (`/workspace/<pluginId>/<viewId>`) and a sidebar entry, and the plugin owns the\n * entire content area while it is open.\n *\n * Use it for standalone workbenches that are NOT bound to one conversation\n * (dashboards, boards, consoles). Conversation-scoped UI belongs in an\n * {@link PluginActivityTabContribution activity tab}; floating UI belongs in a\n * {@link PluginGlobalSlotContribution global slot}.\n */\nexport interface PluginWorkspaceViewContribution {\n\t/** Unique within the plugin; the host namespaces it as `${pluginId}:${id}`. */\n\tid: string;\n\t/** Sidebar entry label. Supports `%catalogKey%` i18n lookup. */\n\tlabel: string;\n\t/**\n\t * Sidebar entry icon as an **iconify class string** (e.g.\n\t * `\"icon-[solar--widget-5-linear]\"`) — NOT a React node, because the host\n\t * renders it inside its own nav button and persists nav layout by key.\n\t *\n\t * Omit it to inherit the plugin's own `plugin.json` icon: a packaged image\n\t * (svg / png / webp …) is masked with the theme's foreground color, so a plugin\n\t * that ships artwork does not have to find a lookalike in an icon set. Set\n\t * {@link PluginWorkspaceViewContribution.iconTint} to `false` to keep its colors.\n\t */\n\ticon?: string;\n\t/**\n\t * Whether an image icon is tinted with the theme's foreground color. Defaults to\n\t * `true`, which keeps the entry consistent with the built-in navigation and legible\n\t * in every theme.\n\t *\n\t * Pass `false` for a full-color logo. Weigh it first: the entry renders at 16px\n\t * beside monochrome built-ins, and a fixed-color image cannot follow the active\n\t * theme — a dark logo can disappear on a dark sidebar. Has no effect on Iconify\n\t * class icons, which are always tinted.\n\t */\n\ticonTint?: boolean;\n\t/** Optional one-line description; shown as the nav entry tooltip. */\n\tdescription?: string;\n\t/**\n\t * Initial badge on the sidebar entry. `{ kind: \"text\" }` supports the same\n\t * `%catalogKey%` i18n lookup as {@link label}. Update it at runtime with\n\t * {@link PluginUiApi.setWorkspaceViewBadge}.\n\t */\n\tbadge?: PluginNavBadge;\n\t/** Zero-props aside from {@link PluginWorkspaceViewProps}. */\n\tcomponent: ComponentType<PluginWorkspaceViewProps>;\n\t/** Sort hint among this plugin's own views (ascending). Defaults to 0. */\n\tnavOrder?: number;\n\t/**\n\t * Whether this view takes a sidebar entry. Defaults to `true`.\n\t *\n\t * Pass `false` for a surface users open occasionally — a setup page, a\n\t * diagnostics console. It then lives only under Settings → More options,\n\t * where the host lists every off-sidebar view and opens it inside the\n\t * settings shell, so switching between such pages stays one click.\n\t *\n\t * The sidebar is a scarce, user-curated space: a plugin that always claims a\n\t * slot pushes the entries someone actually uses into the overflow menu.\n\t */\n\tsidebar?: boolean;\n}\n\n/**\n * What a workspace view puts into the **host page header** — the window's top\n * bar that also carries the drag region, the macOS traffic-light gutter and the\n * sidebar trigger.\n *\n * Without this the header still renders, showing the app name above the\n * plugin's own toolbar — two stacked bars. Set `hideTitle` and move the view's\n * toolbar in here and the surface gets a single, host-consistent header.\n *\n * `left` / `right` are ReactNodes rendered by the host inside that bar (left:\n * right after the sidebar trigger; right: before the window controls). They are\n * rendered in the plugin's i18n + CSS scope, so `useTranslation()` and the\n * plugin's own classes work as usual. Pass fresh nodes whenever the view's\n * state changes — this is a live setter, not a one-time registration.\n */\nexport interface PluginWorkspaceViewHeader {\n\t/** Replaces the host title text. Supports `%catalogKey%` i18n lookup. */\n\ttitle?: string;\n\t/** Drop the host title entirely (use when {@link left} carries its own). */\n\thideTitle?: boolean;\n\t/** Rendered in the header's left cluster, after the sidebar trigger. */\n\tleft?: ReactNode;\n\t/** Rendered in the header's action cluster, before the window controls. */\n\tright?: ReactNode;\n\t/**\n\t * Float the host header OVER the view instead of stacking above it. The view\n\t * then owns the full content height, and its top `~44px` sit under the\n\t * transparent header strip (window drag region / traffic lights / sidebar\n\t * trigger all keep working on top). Use for immersive full-page surfaces\n\t * whose own hero starts at the very top; leave unset for toolbar-style\n\t * headers that need their own opaque row.\n\t */\n\timmersive?: boolean;\n}\n\nexport interface PluginAudioMetadata {\n\t/** Embedded title; preview renderers should fall back to file.name. */\n\ttitle?: string;\n\tartist?: string;\n\t/** Embedded cover art as a Data URL when available. */\n\tcoverDataUrl?: string;\n}\n\nexport interface PluginPreviewUrlOptions {\n\t/** Optional media hint for ambiguous containers such as webm. */\n\tmediaKind?: \"audio\" | \"video\";\n}\n\n/**\n * The file handed to a file-preview plugin component. The host does NOT\n * pre-read or guess encoding — the plugin decides whether to read text or\n * bytes. `path` is also exposed for plugins that prefer native fetch.\n */\nexport interface PluginPreviewFile {\n\tpath: string | null;\n\tname: string;\n\textension: string;\n\tmime: string;\n\tsize: number;\n\t/** Read the file as a UTF-8 string. */\n\treadText(): Promise<string>;\n\t/** Read the raw file bytes. */\n\treadBytes(): Promise<ArrayBuffer>;\n\t/** A fetchable streaming URL for the file (Range-capable). */\n\tgetUrl(options?: PluginPreviewUrlOptions): string;\n\t/**\n\t * Subscribe to on-disk changes of this file. The listener fires (debounced\n\t * by the host) whenever the file's contents change, letting previews update\n\t * live. Returns a Disposable; call dispose() to stop watching. A no-op for\n\t * files without a real path (url-only sources).\n\t */\n\twatch(listener: () => void): Disposable;\n\t/**\n\t * Host-provided audio metadata for local media files. Returns null when the\n\t * host cannot provide metadata, e.g. url-only sources or unsupported files.\n\t */\n\tgetAudioMetadata?(): Promise<PluginAudioMetadata | null>;\n}\n\nexport interface PluginFilePreviewProps {\n\tfile: PluginPreviewFile;\n}\n\n/**\n * A file handed to {@link PluginUiApi.previewFile} — the *opening* side of the\n * global previewer, the mirror image of {@link PluginPreviewFile} (which is the\n * *rendering* side). Bytes never cross over: the host reads the source itself.\n *\n * Exactly one of `path` (local absolute path) or `url` (host media / http URL)\n * must be given. `path` is the shape the host's own file tree uses, so the\n * previewer also offers \"在 Finder 中显示\" for it.\n */\nexport interface PluginPreviewFileRef {\n\t/** Local absolute path. Requires the `fs.read` permission. */\n\tpath?: string;\n\t/** Fetchable URL (host media URL or http/https). Requires `ui.slot.message`. */\n\turl?: string;\n\t/**\n\t * Display name **including the extension** — the previewer dispatches to a\n\t * renderer by this extension, not by `mimeType`. Optional for `path`\n\t * sources (the host falls back to the path's basename).\n\t */\n\tname?: string;\n\tmimeType?: string;\n\t/** Byte size, shown in the previewer's download detail when known. */\n\tsize?: number;\n}\n\nexport interface PluginFilePreviewContribution {\n\t/** Lower-case extensions without the dot, e.g. [\"svg\"]. */\n\textensions: string[];\n\tcomponent: ComponentType<PluginFilePreviewProps>;\n}\n\n/**\n * An activity-panel tab contributed by a plugin. Registering only adds the\n * tab to the \"addable pool\" — it renders only after the user attaches it in\n * the activity panel (scoped by session cwd).\n */\n/** Host residency policy for an activity-panel tab. */\nexport type PluginActivityTabRetention = \"active-only\" | \"warm\" | \"pinned\";\n\nexport interface PluginActivityTabContribution {\n\tid: string;\n\tlabel: string;\n\t/**\n\t * Tab icon as a React node (not an iconify class string).\n\t * Omit to inherit the host-resolved brand icon from `plugin.json#icon`\n\t * (`ctx.plugin.iconUrl`). Prefer omitting for package brand icons so the\n\t * plugin never loads assets via absolute `/…` paths or host protocols.\n\t */\n\ticon?: ReactNode;\n\tcomponent: ComponentType;\n\t/**\n\t * 允许该标签卡出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如\n\t * `[\"project\", \"conversation\"]`)。会话页插槽据此随对话类型显隐。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/**\n\t * 注册后是否默认在标签栏里(缺省 `true`)。声明 `false` 表示「出现条件由我\n\t * 自己决定」——注册只是入池,之后由 {@link PluginUiApi.setActivityTabVisible}\n\t * 或 {@link PluginUiApi.openActivityTab} 决定何时上栏(如 git 只在仓库目录、\n\t * 工作台跟随输入栏 toggle)。无论哪种,用户仍可用减号手动隐藏。\n\t */\n\tinitiallyVisible?: boolean;\n\t/**\n\t * Component residency while the tab is inactive. Defaults to `\"warm\"`:\n\t * visited tabs stay mounted in the host's bounded LRU cache. Use\n\t * `\"active-only\"` for cheap, stateless content and `\"pinned\"` for runtimes\n\t * that must never be evicted while available.\n\t */\n\tretention?: PluginActivityTabRetention;\n\t/**\n\t * @deprecated Use {@link PluginActivityTabContribution.retention}. `true`\n\t * maps to `\"pinned\"`; `false` maps to `\"active-only\"`.\n\t */\n\tkeepAliveWhenAvailable?: boolean;\n}\n\n/** Explicit conversation scope for an activity-tab command. */\nexport interface PluginActivityTabTargetOptions {\n\t/**\n\t * Absolute cwd whose activity-tab state should be changed. Omit to target\n\t * the conversation currently displayed by the host. Tool handlers and\n\t * background work should pass the triggering session's cwd so a foreground\n\t * navigation change cannot redirect the command to another conversation.\n\t */\n\tcwd?: string;\n}\n\n/** Options for {@link PluginUiApi.openActivityTab}. */\nexport interface PluginOpenActivityTabOptions extends PluginActivityTabTargetOptions {\n\t/**\n\t * Desired panel width as it opens: a pixel number, or `\"max\"` to track the\n\t * widest the window allows — `\"max\"` keeps following window resizes until the\n\t * user drags the divider. The host clamps to its min/max bounds. Omit to keep\n\t * the user's current width.\n\t */\n\twidth?: number | \"max\";\n}\n\nexport interface PluginCaptureRegion {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Decoration a plugin contributes to the next outgoing prompt while its input\n * action is active. `metadata` is shallow-merged into the prompt request and\n * `instructions` are appended as hidden, model-visible guidance.\n */\nexport interface PluginPromptDecoration {\n\tmetadata?: Record<string, unknown>;\n\t/** Hidden plugin-owned instructions appended to the next agent turn. */\n\tinstructions?: string[];\n}\n\n/**\n * An action button shown in a row beneath the AI input bar. Rendered as a\n * toggle: clicking activates, clicking again deactivates. While active, the\n * host calls `decoratePrompt()` before each send and merges the returned\n * metadata into the outgoing prompt request. The plugin owns any side state\n * (it is the same Module Federation instance as its other slots).\n */\nexport interface PluginInputActionContribution {\n\tid: string;\n\tlabel: string;\n\t/** Button icon as a React node (not an iconify class string). */\n\ticon?: ReactNode;\n\t/** Whether the action begins in the active state. Defaults to false. */\n\tdefaultActive?: boolean;\n\t/**\n\t * 该输入动作所依赖的 agent 工具名。设置后,仅当该工具在当前会话处于激活(按工具的\n\t * scope_use 解析)时才显示这个 badge——避免在工具被场景屏蔽(如批量任务)时仍显示一个\n\t * 点了也无效的开关。不设则始终显示。例如「图像生成」设为 \"generate_image\"。\n\t */\n\trequiresActiveTool?: string;\n\t/**\n\t * 允许该 toggle 出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现。与 `requiresActiveTool`\n\t * 取「与」:两者都满足才显示。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/**\n\t * When true, this plugin's agent contributions (tools / skills / MCP /\n\t * systemPrompt) and Activity Tabs are hard-isolated: inactive until this\n\t * toggle is on (ADR-0041, knowledgeMode-style). Default false.\n\t */\n\thardIsolation?: boolean;\n\t/**\n\t * Fired when the user toggles the action; `active` is the new state. Return\n\t * `false` when `active` is true to VETO the activation (e.g. the plugin needs\n\t * configuration first) — the toggle stays off. Deactivation can't be vetoed.\n\t */\n\tonToggle?(active: boolean): boolean | void;\n\t/**\n\t * Called by the host before sending while the action is active. The\n\t * returned metadata is merged into the outgoing prompt request.\n\t */\n\tdecoratePrompt?(): PluginPromptDecoration | void;\n}\n\n/**\n * A declarative, serializable descriptor for one card rendered beneath a\n * message. `type` selects a registered card renderer; `key` drives cross-turn\n * dedup (same key across turns = one logical card, shown only under its latest\n * anchor); `payload` carries STABLE REFERENCES (e.g. image ids), not a content\n * snapshot — the renderer resolves live state from it. `title`/`icon` label the\n * card's tab (override the renderer's registration defaults). Rides a tool\n * result's out-of-band `details.cards`; crosses the agent→host boundary, so\n * `icon` is an icon-symbol string, not a node.\n */\nexport interface CardDescriptor {\n\ttype: string;\n\tkey?: string;\n\tpayload?: unknown;\n\ttitle?: string;\n\ticon?: string;\n}\n\n/** A pending (in-flight) tool call handed to a renderer's `pendingFor`. */\nexport interface PluginPendingToolCall {\n\ttoolName: string;\n\targs: Record<string, unknown>;\n}\n\n/**\n * Props for a card renderer. `descriptor` is the card's data; `pending` is true\n * while it was synthesized from an in-flight tool (render a skeleton); `message`\n * is the anchoring conversation message.\n */\nexport interface PluginCardProps {\n\tdescriptor: CardDescriptor;\n\tpending: boolean;\n\tmessage: ConversationMessage;\n}\n\n/**\n * A card renderer registered by a plugin, keyed by `type`. A descriptor whose\n * `type` matches is rendered by `component`. `title`/`icon` are the default tab\n * label/icon (a descriptor may override `title`). `pendingFor`, given an\n * in-flight tool call, returns a provisional descriptor so a skeleton card\n * appears (and claims a tab) before the tool's result lands — or null when this\n * renderer doesn't handle that tool. The `type` must be globally unique across\n * plugins (convention: prefix with the plugin id, e.g. \"image-gen:preview\").\n */\nexport interface PluginCardRendererContribution {\n\ttype: string;\n\tcomponent: ComponentType<PluginCardProps>;\n\ttitle?: string;\n\t/** Default tab icon as a React node (not an iconify class string). */\n\ticon?: ReactNode;\n\tpendingFor?: (toolCall: PluginPendingToolCall) => CardDescriptor | null;\n}\n\n/** A tool call handed to a tool-call slot renderer. */\nexport interface PluginToolCallSlotToolCall {\n\ttoolCallId: string;\n\ttoolName: string;\n\targs: Record<string, unknown>;\n\tstatus: \"pending\" | \"success\" | \"error\" | \"cancelled\";\n\tresult?: string;\n\tisError?: boolean;\n}\n\nexport interface PluginToolCallSlotProps {\n\ttoolCall: PluginToolCallSlotToolCall;\n}\n\n/**\n * A component that **replaces the host's default inline transcript rendering**\n * for a specific tool (matched by `toolName`; first registered renderer wins).\n * This is how a plugin renders rich UI for its OWN agent tool's output — plugin\n * tools cannot emit `details.cards`, so the message card system (registerCardRenderer)\n * does not serve them; the tool-call slot does.\n */\nexport interface PluginToolCallSlotContribution {\n\tid: string;\n\ttoolName: string;\n\tcomponent: ComponentType<PluginToolCallSlotProps>;\n}\n\n/**\n * A card rendered at the bottom of the message list for the LATEST turn — NOT\n * bound to a tool call. The host mounts `component` in the footer slot and\n * re-mounts it each session/turn; the plugin owns visibility entirely (it reads\n * live state via SDK hooks — `useActiveConversation`, `useConversationMessages`,\n * `ctx.conversation.on(\"turn-end\")` — and returns `null` to render nothing,\n * e.g. git renders only inside a repo that has changes). `scope_use` gates which\n * conversation scenarios it may appear in (**fail-closed**, mirrors the other\n * slots). `id` must be unique within the plugin.\n */\nexport interface PluginTurnCardContribution {\n\tid: string;\n\tcomponent: ComponentType;\n\t/**\n\t * 允许该 turn 卡出现的对话场景 slug 列表(镜像其它插槽的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如 `[\"project\"]`)。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n}\n\n/**\n * Options for {@link PluginUiApi.notify}. Surfaces a host toast so users can\n * see plugin failures without opening DevTools.\n */\nexport interface PluginNotifyOptions {\n\t/** Toast body. Required even when `error` is set (user-facing summary). */\n\tmessage: string;\n\t/** Defaults to plugin display name when omitted. */\n\ttitle?: string;\n\t/** Defaults to `\"info\"`; when `error` is set and variant omitted, host uses `\"error\"`. */\n\tvariant?: \"info\" | \"success\" | \"warning\" | \"error\";\n\t/**\n\t * Optional failure cause. Host formats message + stack and adds a\n\t * \"复制堆栈\" action so the user can paste it into bug reports / chat.\n\t */\n\terror?: unknown;\n\t/**\n\t * Auto-dismiss delay in ms. `0` keeps the toast until dismissed.\n\t * Defaults: sticky (`0`) when `error` is present, otherwise host default (~4s).\n\t */\n\tdurationMs?: number;\n}\n\n/**\n * 新会话上下文区的激活条件。**只能写本插件自己的东西**——填别人的 id 一律不生效。\n *\n * 这条限制是故意的:否则插件 A 可以声明「只要用户选了 B 的智能体我就上屏」,把别人的\n * 使用场景劫持过来。\n *\n * 各字段取并集:任意一条命中即激活。至少要声明一条——全空等于「任何新会话都上屏」,宿主拒掉。\n */\nexport interface PluginNewSessionContextActivation {\n\t/** 本插件在 manifest 里声明的智能体 id(不带 `plugin:` 前缀)。 */\n\tagents?: readonly string[];\n\t/** 本插件在 manifest 里声明的团队 id。省略则任意「含本插件成员的团队」都算命中。 */\n\tteams?: readonly string[];\n\t/** 本插件提供的 skill 名;用户在输入框里提到时命中。 */\n\tskills?: readonly string[];\n\t/** 本插件提供的 MCP server 名。 */\n\tmcpServers?: readonly string[];\n}\n\n/** 用户在新会话页当前选中的对话目标。 */\nexport interface PluginNewSessionTarget {\n\treadonly kind: \"agent\" | \"team\";\n\t/** Agent 档案 id 或团队 id。 */\n\treadonly id: string;\n\t/** 目标若由本插件贡献,这里给出 manifest 里的那个 id。 */\n\treadonly contributedId?: string;\n}\n\n/**\n * 渲染上下文。这是一个**会继续生长的对象**:后续新增字段不会破坏既有插件,所以按需\n * 解构、不要假定它只有这些键。\n */\nexport interface PluginNewSessionContext {\n\treadonly target: PluginNewSessionTarget | null;\n\t/** 输入框里提到的、属于本插件的能力。 */\n\treadonly mentionedAbilities: {\n\t\treadonly skills: readonly string[];\n\t\treadonly mcpServers: readonly string[];\n\t};\n\t/**\n\t * 输入框中尚未发送的文本。需要 `conversation.draft.read` 权限,未授予时恒为空串。\n\t *\n\t * 只在本贡献处于激活状态时提供——插件拿不到「用户随便打点什么」的全程流水。\n\t */\n\treadonly draft: string;\n\t/** 当前工作区目录;未选择项目时为 null。 */\n\treadonly cwd: string | null;\n\t/** 回写输入栏。刻意不提供「直接发送」:越过发送前这道关不属于本区职责。 */\n\treadonly composer: {\n\t\t/** 把资源挂成附件,随下一次发送带走。 */\n\t\tattach(attachment: PluginPromptAttachment): void;\n\t\t/**\n\t\t * 往草稿里插一段文本。始终是插入而非替换,免得抹掉用户已经打的内容。\n\t\t *\n\t\t * `position` 缺省为 `\"end\"`(光标处)。`\"start\"` 插到最前面,适合「先定题、细节\n\t\t * 由用户补」这类写法——用户点完多半光标并不在开头,位置只能由调用方定死。\n\t\t */\n\t\tinsertText(text: string, options?: { position?: \"start\" | \"end\" }): void;\n\t};\n}\n\n/**\n * 新会话页输入框下方的一块内容(`ui.slot.new-session-context`)。\n *\n * 与 input-action 的分工:那是发送前的开关,这是发送前的**上下文**——把用户接下来多半\n * 要用到的素材摆出来。激活与否由宿主按 {@link PluginNewSessionContextActivation} 裁决,\n * 插件只负责在被激活后渲染,因此拿不到用户逐键输入的全程内容。\n *\n * 同时有多个贡献上屏时,宿主会在该区域顶部出 tabbar;只有一个时直接渲染内容。\n */\nexport interface PluginNewSessionContextContribution {\n\tid: string;\n\t/** tabbar 上的标题;只有一个贡献上屏时不展示。 */\n\tlabel: string;\n\t/** tab 图标;省略时用插件自己的图标。 */\n\ticon?: ReactNode;\n\tactivateWhen: PluginNewSessionContextActivation;\n\t/**\n\t * 横向占位。`\"input\"`(默认)与输入框同宽,适合补充说明一类的窄内容;`\"wide\"` 铺满\n\t * 页面可用宽度,留给画廊、素材墙这类「内容本身就是主角」的东西——把它们压在输入框\n\t * 宽度里,每一项都会小到看不清。\n\t */\n\twidth?: \"input\" | \"wide\";\n\trender(context: PluginNewSessionContext): ReactNode;\n}\n\n/**\n * 宿主左侧侧边栏此刻的形态。给插件自适应布局用——尤其是沉浸式工作区视图:\n * 侧边栏收起时宿主页头会长出「展开侧边栏」按钮并占住左上角,视图自己画在那一带的\n * 东西需要让位。\n */\nexport interface PluginSidebarState {\n\t/** 用户手动收起了侧边栏。窄屏下这一位仍然只反映用户意愿,不受窗口宽度影响。 */\n\tcollapsed: boolean;\n\t/** 窗口窄到侧边栏改走悬浮覆盖,不再占据左侧一栏。 */\n\tnarrow: boolean;\n\t/** 侧边栏此刻是否实际占着左边那一栏。等价于 `!collapsed && !narrow`,多数自适应只需要这一位。 */\n\tvisible: boolean;\n}\n\nexport interface PluginUiApi {\n\tregisterGlobalSlot(contribution: PluginGlobalSlotContribution): Disposable;\n\tregisterAbilityDetailSlot(contribution: PluginAbilityDetailSlotContribution): Disposable;\n\t/** Render an opaque setup URL as a host-themed PNG data URL. */\n\tcreateQrCode(text: string): Promise<string>;\n\t/**\n\t * Register a **workspace view**(工作区视图)— a full-page surface with its own\n\t * route and sidebar entry, on par with the host's built-in pages. Needs the\n\t * `ui.slot.workspace-view` permission (missing permission = **warn+noop**).\n\t *\n\t * The entry lands in the sidebar's「更多」收纳 by default; the user can pin it\n\t * to the top region or reorder it, and that layout is remembered.\n\t */\n\tregisterWorkspaceView(contribution: PluginWorkspaceViewContribution): Disposable;\n\t/**\n\t * Register a **new-session context block** — content shown beneath the input\n\t * on the new-session page, surfaced only when the user's current selection or\n\t * draft matches {@link PluginNewSessionContextActivation}. Needs the\n\t * `ui.slot.new-session-context` permission (missing permission = **warn+noop**).\n\t */\n\tregisterNewSessionContext(contribution: PluginNewSessionContextContribution): Disposable;\n\t/**\n\t * Navigate to one of this plugin's own workspace views. `viewId` is the\n\t * contribution id passed to {@link PluginUiApi.registerWorkspaceView}. No-op\n\t * when the view is not registered (e.g. permission missing).\n\t */\n\topenWorkspaceView(viewId: string): void;\n\t/**\n\t * Update (or clear, with `null`) the badge on one of this plugin's workspace\n\t * view entries. Re-registering the view is NOT a way to do this — it would\n\t * remount the whole surface — so live badges (unread counts, status dots)\n\t * must come through here.\n\t *\n\t * No-op when the view is not registered (e.g. permission missing).\n\t */\n\tsetWorkspaceViewBadge(viewId: string, badge: PluginNavBadge | null): void;\n\t/**\n\t * Fill (or clear, with `null`) the host page header while one of this\n\t * plugin's workspace views is open. Call it from the view component (an\n\t * effect that re-runs on state change) and clear it on unmount — the host\n\t * keeps the entry keyed by view, and only applies it on that view's route.\n\t *\n\t * The header itself is never removed: it owns the window drag region and the\n\t * macOS traffic-light gutter. This is how a view takes it over instead.\n\t *\n\t * No-op when the view is not registered (e.g. permission missing).\n\t */\n\tsetWorkspaceViewHeader(viewId: string, header: PluginWorkspaceViewHeader | null): void;\n\t/**\n\t * Register a preview component keyed by file extension. The host dispatches\n\t * registered extensions before its built-in fallback renderers; first\n\t * registrant wins on conflict.\n\t */\n\tregisterFilePreview(contribution: PluginFilePreviewContribution): Disposable;\n\t/**\n\t * Register an activity-panel tab into the addable pool. The user attaches\n\t * it manually via the panel's \"+\" picker; attach records are keyed by the\n\t * session cwd.\n\t */\n\tregisterActivityTab(contribution: PluginActivityTabContribution): Disposable;\n\t/**\n\t * Register a toggle action shown beneath the AI input bar. While active,\n\t * its `decoratePrompt()` annotates the next outgoing prompt.\n\t */\n\tregisterInputAction(contribution: PluginInputActionContribution): Disposable;\n\t/**\n\t * Register a card renderer keyed by `type`. Cards rendered beneath a message\n\t * come from tool results' out-of-band `details.cards` (or `pendingFor` for\n\t * in-flight tools); the host resolves each card's `type` to a registered\n\t * renderer. Multiple cards under one message are shown as a tab-switcher\n\t * (\"收纳\") or a flat list.\n\t */\n\tregisterCardRenderer(contribution: PluginCardRendererContribution): Disposable;\n\t/**\n\t * Register a renderer that replaces the host's default inline transcript UI\n\t * for a tool call (matched by `toolName`). The complement to card renderers:\n\t * use it to render UI for a plugin's own agent tool output.\n\t */\n\tregisterToolCallSlot(contribution: PluginToolCallSlotContribution): Disposable;\n\t/**\n\t * Register a card rendered at the bottom of the message list for the latest\n\t * turn — NOT bound to a tool call. The host mounts the component in the\n\t * footer slot; the plugin owns visibility (return `null` to render nothing,\n\t * e.g. git renders only in a repo with changes). Gated by `scope_use`\n\t * (fail-closed). Needs the `ui.slot.turn-card` permission.\n\t */\n\tregisterTurnCard(contribution: PluginTurnCardContribution): Disposable;\n\t/**\n\t * Register a keyboard shortcut scope on the host's shared ShortcutScopeStack\n\t * (same path as host UI: modal > overlay > surface > app). Needs\n\t * `ui.shortcuts.register`. Plugins cannot use kind `\"app\"` (reserved for\n\t * host-configurable global actions). Prefer {@link usePluginShortcutScope}\n\t * from React components with a module-captured `registerShortcutScope`.\n\t */\n\tregisterShortcutScope(contribution: PluginShortcutScopeContribution): Disposable;\n\t/**\n\t * Programmatically attach (if needed) and activate one of this plugin's\n\t * own activity tabs in a conversation's activity panel. `tabId`\n\t * is the contribution id passed to registerActivityTab. Any payload (e.g.\n\t * which image to edit) is passed via the plugin's own in-memory state.\n\t *\n\t * Pass `options.width` to size the panel as it opens — a pixel number, or\n\t * `\"max\"` to expand it to the widest the current window allows (the host\n\t * still clamps to its min/max and auto-hides the sidebar when needed). Omit\n\t * to leave the user's current width untouched.\n\t *\n\t * Omit `options.cwd` for the conversation currently displayed by the host.\n\t * Tool handlers and background work should pass their session cwd explicitly.\n\t */\n\topenActivityTab(tabId: string, options?: PluginOpenActivityTabOptions): void;\n\t/**\n\t * 把本插件的某个活动面板标签卡在目标会话里上栏 / 下栏,**不激活也不展开\n\t * 面板**——`openActivityTab` 是「用户此刻要看它」,这个是「它现在该不该在\n\t * 栏里」。配合 `initiallyVisible: false` 使用,插件即可完全掌握自己标签卡的\n\t * 出现条件(如 git 只在仓库目录里上栏、工作台跟随输入栏 toggle)。\n\t *\n\t * 上栏记录按会话 cwd 持久化(ADR-0026),所以只需在条件变化时调用一次;\n\t * 用户随后用减号手动隐藏的结果不会被重复调用覆盖。缺省作用于宿主当前显示的\n\t * 会话;工具 handler 与后台任务应通过 `options.cwd` 传入自己的会话 cwd。既没有\n\t * 显式 cwd、也没有活动会话时为 no-op(无处记录)。\n\t */\n\tsetActivityTabVisible(tabId: string, visible: boolean, options?: PluginActivityTabTargetOptions): void;\n\t/**\n\t * 直接设置活动面板宽度:像素值,或 `\"max\"` 表示「跟随窗口拉满」(宿主仍会夹到\n\t * 自己的 min/max 内,必要时自动收起侧边栏)。\n\t *\n\t * `\"max\"` 是一种持续状态而非一次性求值:窗口尺寸变化时面板跟着变宽变窄,直到\n\t * 用户拖动分隔条或有人写入具体像素为止。传数字则是一次性的固定宽度。\n\t *\n\t * 与 `openActivityTab(id, { width })` 的区别:那里的宽度只在标签卡首次 attach\n\t * 时生效(避免 activate 重放覆盖用户手拖的宽度);这个是命令式的,每次调用都\n\t * 生效,供插件在自己的标签卡被激活、进入某种视图时按需调整。用户随后仍可拖动。\n\t */\n\tsetActivityPanelWidth(width: number | \"max\"): void;\n\t/**\n\t * Bind or clear plugin-owned context for outgoing prompts. The host renders\n\t * its label/icon and carries a structured `context` as a versioned snapshot.\n\t * Attachments default to one-shot; `lifecycle: \"sticky\"` remains until the\n\t * plugin or user clears the capsule.\n\t */\n\tsetPromptAttachment(attachment: PluginPromptAttachment | null): void;\n\t/**\n\t * Open the host's global full-screen image previewer for the given image.\n\t * Only the image reference (id/url) crosses over — bytes stay out-of-band.\n\t *\n\t * Pass `group` (e.g. all images of the message) to open as an image group:\n\t * the previewer shows a thumbnail strip + arrows and starts at `ref`.\n\t */\n\tpreviewImage(ref: PluginImageRef, group?: PluginImageRef[]): void;\n\t/**\n\t * Open the host's global file previewer for any file — the general form of\n\t * {@link PluginUiApi.previewImage}, which only takes image URLs. Accepts a\n\t * local absolute `path` (the shape the host's own file tree uses) as well as\n\t * a `url`; the previewer dispatches by the file's extension, so a file type\n\t * some plugin registered via `registerFilePreview` lands in that renderer.\n\t *\n\t * Pass `group` (e.g. all outputs of one run) to open as a group: images get\n\t * the thumbnail strip + arrows, and the previewer starts at `file`.\n\t *\n\t * Permissions: `fs.read` as soon as any entry carries a `path` (it hands a\n\t * local file to the host to read); `ui.slot.message` for url-only calls,\n\t * same gate as `previewImage`.\n\t */\n\tpreviewFile(file: PluginPreviewFileRef, group?: PluginPreviewFileRef[]): void;\n\t/**\n\t * Capture a rectangle in the current Vetta window and open the host save\n\t * dialog. Coordinates use renderer DIP values such as getBoundingClientRect().\n\t * Requires `ui.slot.activity-tab`.\n\t */\n\tcaptureRegion(rect: PluginCaptureRegion, defaultFileName: string): Promise<string | null>;\n\t/**\n\t * Copy an image to the system clipboard. Takes a `data:image/...;base64,`\n\t * URL and goes through the native clipboard, so it does not depend on the\n\t * renderer's `ClipboardItem` support. No permission required — the plugin\n\t * can only write what it already rendered.\n\t */\n\tcopyImage(dataUrl: string): Promise<void>;\n\t/**\n\t * Hand a URL to the OS default browser (Electron `shell.openExternal`) —\n\t * NOT the in-app browser panel. Only `http:`/`https:` are accepted; the host\n\t * rejects every other protocol, so this cannot be used to launch arbitrary\n\t * schemes. Needs `shell.openExternal`.\n\t */\n\topenExternal(url: string): Promise<void>;\n\t/**\n\t * Show a global toast in the host UI (bottom-right). No permission required.\n\t * Prefer this over swallowing errors into opaque UI copy: pass `error` so\n\t * the host attaches a one-click \"copy stack\" action for the user.\n\t *\n\t * Capture `ctx.ui.notify` in `activate` if React components need it\n\t * (components do not receive `ctx`).\n\t */\n\tnotify(options: PluginNotifyOptions): void;\n\t/**\n\t * 读当前侧边栏形态。无需权限——这是纯布局信息,不含任何用户数据。\n\t *\n\t * React 组件请改用 `useSidebarState()`:它会在状态变化时重渲染,不必自己订阅。\n\t * 这一对只为拿不到 hook 的地方准备(`activate()` 内、工具处理器、命令式绘制的画布)。\n\t */\n\tgetSidebarState(): PluginSidebarState;\n\t/**\n\t * 订阅侧边栏形态变化——用户收起/展开侧边栏、或窗口跨过窄屏阈值时触发。\n\t * 返回 Disposable 取消订阅;请在插件失活时释放。\n\t *\n\t * 回调按值去重:拖窗口不会把它打成回调风暴,只有三元组真的变了才通知。\n\t */\n\tonSidebarStateChanged(listener: (state: PluginSidebarState) => void): Disposable;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,WAAW,4BAA4B;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,oFAAoF;AACpF,MAAM,WAAW,mCAAmC;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,SAAS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AAK,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAC;IAC9E;;;;OAIG;IACH,aAAa,CAAC,IAAI,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1F;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC3C;;;;;OAKG;IACH,eAAe,IAAI,kBAAkB,CAAC;IACtC;;;;;OAKG;IACH,qBAAqB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAAG,UAAU,CAAC;CACjF","sourcesContent":["import type { ComponentType, ReactNode } from \"react\";\nimport type { ConversationMessage } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginImageRef } from \"./images.js\";\nimport type { PluginPromptAttachment } from \"./prompt-attachment.js\";\nimport type { ConversationScenario } from \"./scenario.js\";\nimport type { PluginShortcutScopeContribution } from \"./shortcuts.js\";\n\nexport interface PluginGlobalSlotContribution {\n\tid: string;\n\tcomponent: ComponentType;\n}\n\nexport interface PluginAbilityDetailSlotProps {\n\tabilityId: string;\n\tinstalled: boolean;\n\tenabled: boolean;\n}\n\n/** Inline setup/status surface rendered near the top of one ability detail page. */\nexport interface PluginAbilityDetailSlotContribution {\n\tid: string;\n\tabilityId: string;\n\tcomponent: ComponentType<PluginAbilityDetailSlotProps>;\n}\n\n/**\n * Props handed to a workspace-view component. A workspace view owns the whole\n * content area, so unlike panel slots it is addressed by its own route and can\n * be deep-linked; the host passes back its identity so one component can serve\n * several registered views.\n */\nexport interface PluginWorkspaceViewProps {\n\t/** The contribution id as registered (NOT namespaced). */\n\tviewId: string;\n\t/** The owning plugin id. */\n\tpluginId: string;\n}\n\n/**\n * Badge tone. The host maps it to its own theme colors — a plugin cannot pick a\n * raw color, so badges stay consistent with the built-in navigation entries.\n */\nexport type PluginNavBadgeTone = \"accent\" | \"danger\" | \"default\" | \"warning\";\n\n/**\n * A badge on the plugin's sidebar navigation entry.\n *\n * `beta` is the host's own preset — it renders exactly like the built-in\n * 知识库 Beta 标识, wording included (and localized by the host), so plugins do\n * not have to spell \"Beta\" themselves in every locale.\n *\n * `count` renders `99+` past 99 and disappears at 0 — an unread badge showing\n * \"0\" is worse than no badge.\n */\nexport type PluginNavBadge =\n\t| { kind: \"beta\" }\n\t| { kind: \"text\"; text: string; tone?: PluginNavBadgeTone }\n\t| { kind: \"count\"; count: number; tone?: PluginNavBadgeTone }\n\t| { kind: \"dot\"; tone?: PluginNavBadgeTone };\n\n/**\n * A **workspace view**(工作区视图): a full-page surface a plugin contributes to\n * the host's primary navigation. It is the plugin counterpart of a built-in page\n * such as 自动化 / 知识库 — the host gives it its own route\n * (`/workspace/<pluginId>/<viewId>`) and a sidebar entry, and the plugin owns the\n * entire content area while it is open.\n *\n * Use it for standalone workbenches that are NOT bound to one conversation\n * (dashboards, boards, consoles). Conversation-scoped UI belongs in an\n * {@link PluginActivityTabContribution activity tab}; floating UI belongs in a\n * {@link PluginGlobalSlotContribution global slot}.\n */\nexport interface PluginWorkspaceViewContribution {\n\t/** Unique within the plugin; the host namespaces it as `${pluginId}:${id}`. */\n\tid: string;\n\t/** Sidebar entry label. Supports `%catalogKey%` i18n lookup. */\n\tlabel: string;\n\t/**\n\t * Sidebar entry icon as an **iconify class string** (e.g.\n\t * `\"icon-[solar--widget-5-linear]\"`) — NOT a React node, because the host\n\t * renders it inside its own nav button and persists nav layout by key.\n\t *\n\t * Omit it to inherit the plugin's own `plugin.json` icon: a packaged image\n\t * (svg / png / webp …) is masked with the theme's foreground color, so a plugin\n\t * that ships artwork does not have to find a lookalike in an icon set. Set\n\t * {@link PluginWorkspaceViewContribution.iconTint} to `false` to keep its colors.\n\t */\n\ticon?: string;\n\t/**\n\t * Whether an image icon is tinted with the theme's foreground color. Defaults to\n\t * `true`, which keeps the entry consistent with the built-in navigation and legible\n\t * in every theme.\n\t *\n\t * Pass `false` for a full-color logo. Weigh it first: the entry renders at 16px\n\t * beside monochrome built-ins, and a fixed-color image cannot follow the active\n\t * theme — a dark logo can disappear on a dark sidebar. Has no effect on Iconify\n\t * class icons, which are always tinted.\n\t */\n\ticonTint?: boolean;\n\t/** Optional one-line description; shown as the nav entry tooltip. */\n\tdescription?: string;\n\t/**\n\t * Initial badge on the sidebar entry. `{ kind: \"text\" }` supports the same\n\t * `%catalogKey%` i18n lookup as {@link label}. Update it at runtime with\n\t * {@link PluginUiApi.setWorkspaceViewBadge}.\n\t */\n\tbadge?: PluginNavBadge;\n\t/** Zero-props aside from {@link PluginWorkspaceViewProps}. */\n\tcomponent: ComponentType<PluginWorkspaceViewProps>;\n\t/** Sort hint among this plugin's own views (ascending). Defaults to 0. */\n\tnavOrder?: number;\n\t/**\n\t * Whether this view takes a sidebar entry. Defaults to `true`.\n\t *\n\t * Pass `false` for a surface users open occasionally — a setup page, a\n\t * diagnostics console. It then lives only under Settings → More options,\n\t * where the host lists every off-sidebar view and opens it inside the\n\t * settings shell, so switching between such pages stays one click.\n\t *\n\t * The sidebar is a scarce, user-curated space: a plugin that always claims a\n\t * slot pushes the entries someone actually uses into the overflow menu.\n\t */\n\tsidebar?: boolean;\n}\n\n/**\n * What a workspace view puts into the **host page header** — the window's top\n * bar that also carries the drag region, the macOS traffic-light gutter and the\n * sidebar trigger.\n *\n * Without this the header still renders, showing the app name above the\n * plugin's own toolbar — two stacked bars. Set `hideTitle` and move the view's\n * toolbar in here and the surface gets a single, host-consistent header.\n *\n * `left` / `right` are ReactNodes rendered by the host inside that bar (left:\n * right after the sidebar trigger; right: before the window controls). They are\n * rendered in the plugin's i18n + CSS scope, so `useTranslation()` and the\n * plugin's own classes work as usual. Pass fresh nodes whenever the view's\n * state changes — this is a live setter, not a one-time registration.\n */\nexport interface PluginWorkspaceViewHeader {\n\t/** Replaces the host title text. Supports `%catalogKey%` i18n lookup. */\n\ttitle?: string;\n\t/** Drop the host title entirely (use when {@link left} carries its own). */\n\thideTitle?: boolean;\n\t/** Rendered in the header's left cluster, after the sidebar trigger. */\n\tleft?: ReactNode;\n\t/** Rendered in the header's action cluster, before the window controls. */\n\tright?: ReactNode;\n\t/**\n\t * Float the host header OVER the view instead of stacking above it. The view\n\t * then owns the full content height, and its top `~44px` sit under the\n\t * transparent header strip (window drag region / traffic lights / sidebar\n\t * trigger all keep working on top). Use for immersive full-page surfaces\n\t * whose own hero starts at the very top; leave unset for toolbar-style\n\t * headers that need their own opaque row.\n\t */\n\timmersive?: boolean;\n}\n\nexport interface PluginAudioMetadata {\n\t/** Embedded title; preview renderers should fall back to file.name. */\n\ttitle?: string;\n\tartist?: string;\n\t/** Embedded cover art as a Data URL when available. */\n\tcoverDataUrl?: string;\n}\n\nexport interface PluginPreviewUrlOptions {\n\t/** Optional media hint for ambiguous containers such as webm. */\n\tmediaKind?: \"audio\" | \"video\";\n}\n\n/**\n * The file handed to a file-preview plugin component. The host does NOT\n * pre-read or guess encoding — the plugin decides whether to read text or\n * bytes. `path` is also exposed for plugins that prefer native fetch.\n */\nexport interface PluginPreviewFile {\n\tpath: string | null;\n\tname: string;\n\textension: string;\n\tmime: string;\n\tsize: number;\n\t/** Read the file as a UTF-8 string. */\n\treadText(): Promise<string>;\n\t/** Read the raw file bytes. */\n\treadBytes(): Promise<ArrayBuffer>;\n\t/** A fetchable streaming URL for the file (Range-capable). */\n\tgetUrl(options?: PluginPreviewUrlOptions): string;\n\t/**\n\t * Subscribe to on-disk changes of this file. The listener fires (debounced\n\t * by the host) whenever the file's contents change, letting previews update\n\t * live. Returns a Disposable; call dispose() to stop watching. A no-op for\n\t * files without a real path (url-only sources).\n\t */\n\twatch(listener: () => void): Disposable;\n\t/**\n\t * Host-provided audio metadata for local media files. Returns null when the\n\t * host cannot provide metadata, e.g. url-only sources or unsupported files.\n\t */\n\tgetAudioMetadata?(): Promise<PluginAudioMetadata | null>;\n}\n\nexport interface PluginFilePreviewProps {\n\tfile: PluginPreviewFile;\n}\n\n/**\n * A file handed to {@link PluginUiApi.previewFile} — the *opening* side of the\n * global previewer, the mirror image of {@link PluginPreviewFile} (which is the\n * *rendering* side). Bytes never cross over: the host reads the source itself.\n *\n * Exactly one of `path` (local absolute path) or `url` (host media / http URL)\n * must be given. `path` is the shape the host's own file tree uses, so the\n * previewer also offers \"在 Finder 中显示\" for it.\n */\nexport interface PluginPreviewFileRef {\n\t/** Local absolute path. Requires the `fs.read` permission. */\n\tpath?: string;\n\t/** Fetchable URL (host media URL or http/https). Requires `ui.slot.message`. */\n\turl?: string;\n\t/**\n\t * Display name **including the extension** — the previewer dispatches to a\n\t * renderer by this extension, not by `mimeType`. Optional for `path`\n\t * sources (the host falls back to the path's basename).\n\t */\n\tname?: string;\n\tmimeType?: string;\n\t/** Byte size, shown in the previewer's download detail when known. */\n\tsize?: number;\n}\n\nexport interface PluginFilePreviewContribution {\n\t/** Lower-case extensions without the dot, e.g. [\"svg\"]. */\n\textensions: string[];\n\tcomponent: ComponentType<PluginFilePreviewProps>;\n}\n\n/**\n * An activity-panel tab contributed by a plugin. Registering only adds the\n * tab to the \"addable pool\" — it renders only after the user attaches it in\n * the activity panel (scoped by session cwd).\n */\n/** Host residency policy for an activity-panel tab. */\nexport type PluginActivityTabRetention = \"active-only\" | \"warm\" | \"pinned\";\n\nexport interface PluginActivityTabContribution {\n\t/**\n\t * 标签栏上的默认相对位置,越小越靠前;缺省 100(排在全部内置标签卡之后)。\n\t *\n\t * 内置的取值可作标尺:文件 0、批量 10、浏览器 15、计划 18、待办 20、后台任务 30。\n\t * 下限被宿主钳到 10,「文件」永远是第一枚;用户拖拽出来的顺序优先于这个值。\n\t */\n\torder?: number;\n\tid: string;\n\tlabel: string;\n\t/**\n\t * Tab icon as a React node (not an iconify class string).\n\t * Omit to inherit the host-resolved brand icon from `plugin.json#icon`\n\t * (`ctx.plugin.iconUrl`). Prefer omitting for package brand icons so the\n\t * plugin never loads assets via absolute `/…` paths or host protocols.\n\t */\n\ticon?: ReactNode;\n\tcomponent: ComponentType;\n\t/**\n\t * 允许该标签卡出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如\n\t * `[\"project\", \"conversation\"]`)。会话页插槽据此随对话类型显隐。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/**\n\t * 注册后是否默认在标签栏里(缺省 `true`)。声明 `false` 表示「出现条件由我\n\t * 自己决定」——注册只是入池,之后由 {@link PluginUiApi.setActivityTabVisible}\n\t * 或 {@link PluginUiApi.openActivityTab} 决定何时上栏(如 git 只在仓库目录、\n\t * 工作台跟随输入栏 toggle)。无论哪种,用户仍可用减号手动隐藏。\n\t */\n\tinitiallyVisible?: boolean;\n\t/**\n\t * Component residency while the tab is inactive. Defaults to `\"warm\"`:\n\t * visited tabs stay mounted in the host's bounded LRU cache. Use\n\t * `\"active-only\"` for cheap, stateless content and `\"pinned\"` for runtimes\n\t * that must never be evicted while available.\n\t */\n\tretention?: PluginActivityTabRetention;\n\t/**\n\t * @deprecated Use {@link PluginActivityTabContribution.retention}. `true`\n\t * maps to `\"pinned\"`; `false` maps to `\"active-only\"`.\n\t */\n\tkeepAliveWhenAvailable?: boolean;\n}\n\n/** Explicit conversation scope for an activity-tab command. */\nexport interface PluginActivityTabTargetOptions {\n\t/**\n\t * Absolute cwd whose activity-tab state should be changed. Omit to target\n\t * the conversation currently displayed by the host. Tool handlers and\n\t * background work should pass the triggering session's cwd so a foreground\n\t * navigation change cannot redirect the command to another conversation.\n\t */\n\tcwd?: string;\n}\n\n/** Options for {@link PluginUiApi.openActivityTab}. */\nexport interface PluginOpenActivityTabOptions extends PluginActivityTabTargetOptions {\n\t/**\n\t * Desired panel width as it opens: a pixel number, or `\"max\"` to track the\n\t * widest the window allows — `\"max\"` keeps following window resizes until the\n\t * user drags the divider. The host clamps to its min/max bounds. Omit to keep\n\t * the user's current width.\n\t */\n\twidth?: number | \"max\";\n}\n\nexport interface PluginCaptureRegion {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Decoration a plugin contributes to the next outgoing prompt while its input\n * action is active. `metadata` is shallow-merged into the prompt request and\n * `instructions` are appended as hidden, model-visible guidance.\n */\nexport interface PluginPromptDecoration {\n\tmetadata?: Record<string, unknown>;\n\t/** Hidden plugin-owned instructions appended to the next agent turn. */\n\tinstructions?: string[];\n}\n\n/**\n * An action button shown in a row beneath the AI input bar. Rendered as a\n * toggle: clicking activates, clicking again deactivates. While active, the\n * host calls `decoratePrompt()` before each send and merges the returned\n * metadata into the outgoing prompt request. The plugin owns any side state\n * (it is the same Module Federation instance as its other slots).\n */\nexport interface PluginInputActionContribution {\n\tid: string;\n\tlabel: string;\n\t/** Button icon as a React node (not an iconify class string). */\n\ticon?: ReactNode;\n\t/** Whether the action begins in the active state. Defaults to false. */\n\tdefaultActive?: boolean;\n\t/**\n\t * 该输入动作所依赖的 agent 工具名。设置后,仅当该工具在当前会话处于激活(按工具的\n\t * scope_use 解析)时才显示这个 badge——避免在工具被场景屏蔽(如批量任务)时仍显示一个\n\t * 点了也无效的开关。不设则始终显示。例如「图像生成」设为 \"generate_image\"。\n\t */\n\trequiresActiveTool?: string;\n\t/**\n\t * 允许该 toggle 出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现。与 `requiresActiveTool`\n\t * 取「与」:两者都满足才显示。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/**\n\t * When true, this plugin's agent contributions (tools / skills / MCP /\n\t * systemPrompt) and Activity Tabs are hard-isolated: inactive until this\n\t * toggle is on (ADR-0041, knowledgeMode-style). Default false.\n\t */\n\thardIsolation?: boolean;\n\t/**\n\t * Fired when the user toggles the action; `active` is the new state. Return\n\t * `false` when `active` is true to VETO the activation (e.g. the plugin needs\n\t * configuration first) — the toggle stays off. Deactivation can't be vetoed.\n\t */\n\tonToggle?(active: boolean): boolean | void;\n\t/**\n\t * Called by the host before sending while the action is active. The\n\t * returned metadata is merged into the outgoing prompt request.\n\t */\n\tdecoratePrompt?(): PluginPromptDecoration | void;\n}\n\n/**\n * A declarative, serializable descriptor for one card rendered beneath a\n * message. `type` selects a registered card renderer; `key` drives cross-turn\n * dedup (same key across turns = one logical card, shown only under its latest\n * anchor); `payload` carries STABLE REFERENCES (e.g. image ids), not a content\n * snapshot — the renderer resolves live state from it. `title`/`icon` label the\n * card's tab (override the renderer's registration defaults). Rides a tool\n * result's out-of-band `details.cards`; crosses the agent→host boundary, so\n * `icon` is an icon-symbol string, not a node.\n */\nexport interface CardDescriptor {\n\ttype: string;\n\tkey?: string;\n\tpayload?: unknown;\n\ttitle?: string;\n\ticon?: string;\n}\n\n/** A pending (in-flight) tool call handed to a renderer's `pendingFor`. */\nexport interface PluginPendingToolCall {\n\ttoolName: string;\n\targs: Record<string, unknown>;\n}\n\n/**\n * Props for a card renderer. `descriptor` is the card's data; `pending` is true\n * while it was synthesized from an in-flight tool (render a skeleton); `message`\n * is the anchoring conversation message.\n */\nexport interface PluginCardProps {\n\tdescriptor: CardDescriptor;\n\tpending: boolean;\n\tmessage: ConversationMessage;\n}\n\n/**\n * A card renderer registered by a plugin, keyed by `type`. A descriptor whose\n * `type` matches is rendered by `component`. `title`/`icon` are the default tab\n * label/icon (a descriptor may override `title`). `pendingFor`, given an\n * in-flight tool call, returns a provisional descriptor so a skeleton card\n * appears (and claims a tab) before the tool's result lands — or null when this\n * renderer doesn't handle that tool. The `type` must be globally unique across\n * plugins (convention: prefix with the plugin id, e.g. \"image-gen:preview\").\n */\nexport interface PluginCardRendererContribution {\n\ttype: string;\n\tcomponent: ComponentType<PluginCardProps>;\n\ttitle?: string;\n\t/** Default tab icon as a React node (not an iconify class string). */\n\ticon?: ReactNode;\n\tpendingFor?: (toolCall: PluginPendingToolCall) => CardDescriptor | null;\n}\n\n/** A tool call handed to a tool-call slot renderer. */\nexport interface PluginToolCallSlotToolCall {\n\ttoolCallId: string;\n\ttoolName: string;\n\targs: Record<string, unknown>;\n\tstatus: \"pending\" | \"success\" | \"error\" | \"cancelled\";\n\tresult?: string;\n\tisError?: boolean;\n}\n\nexport interface PluginToolCallSlotProps {\n\ttoolCall: PluginToolCallSlotToolCall;\n}\n\n/**\n * A component that **replaces the host's default inline transcript rendering**\n * for a specific tool (matched by `toolName`; first registered renderer wins).\n * This is how a plugin renders rich UI for its OWN agent tool's output — plugin\n * tools cannot emit `details.cards`, so the message card system (registerCardRenderer)\n * does not serve them; the tool-call slot does.\n */\nexport interface PluginToolCallSlotContribution {\n\tid: string;\n\ttoolName: string;\n\tcomponent: ComponentType<PluginToolCallSlotProps>;\n}\n\n/**\n * A card rendered at the bottom of the message list for the LATEST turn — NOT\n * bound to a tool call. The host mounts `component` in the footer slot and\n * re-mounts it each session/turn; the plugin owns visibility entirely (it reads\n * live state via SDK hooks — `useActiveConversation`, `useConversationMessages`,\n * `ctx.conversation.on(\"turn-end\")` — and returns `null` to render nothing,\n * e.g. git renders only inside a repo that has changes). `scope_use` gates which\n * conversation scenarios it may appear in (**fail-closed**, mirrors the other\n * slots). `id` must be unique within the plugin.\n */\nexport interface PluginTurnCardContribution {\n\tid: string;\n\tcomponent: ComponentType;\n\t/**\n\t * 允许该 turn 卡出现的对话场景 slug 列表(镜像其它插槽的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如 `[\"project\"]`)。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n}\n\n/**\n * Options for {@link PluginUiApi.notify}. Surfaces a host toast so users can\n * see plugin failures without opening DevTools.\n */\nexport interface PluginNotifyOptions {\n\t/** Toast body. Required even when `error` is set (user-facing summary). */\n\tmessage: string;\n\t/** Defaults to plugin display name when omitted. */\n\ttitle?: string;\n\t/** Defaults to `\"info\"`; when `error` is set and variant omitted, host uses `\"error\"`. */\n\tvariant?: \"info\" | \"success\" | \"warning\" | \"error\";\n\t/**\n\t * Optional failure cause. Host formats message + stack and adds a\n\t * \"复制堆栈\" action so the user can paste it into bug reports / chat.\n\t */\n\terror?: unknown;\n\t/**\n\t * Auto-dismiss delay in ms. `0` keeps the toast until dismissed.\n\t * Defaults: sticky (`0`) when `error` is present, otherwise host default (~4s).\n\t */\n\tdurationMs?: number;\n}\n\n/**\n * 新会话上下文区的激活条件。**只能写本插件自己的东西**——填别人的 id 一律不生效。\n *\n * 这条限制是故意的:否则插件 A 可以声明「只要用户选了 B 的智能体我就上屏」,把别人的\n * 使用场景劫持过来。\n *\n * 各字段取并集:任意一条命中即激活。至少要声明一条——全空等于「任何新会话都上屏」,宿主拒掉。\n */\nexport interface PluginNewSessionContextActivation {\n\t/** 本插件在 manifest 里声明的智能体 id(不带 `plugin:` 前缀)。 */\n\tagents?: readonly string[];\n\t/** 本插件在 manifest 里声明的团队 id。省略则任意「含本插件成员的团队」都算命中。 */\n\tteams?: readonly string[];\n\t/** 本插件提供的 skill 名;用户在输入框里提到时命中。 */\n\tskills?: readonly string[];\n\t/** 本插件提供的 MCP server 名。 */\n\tmcpServers?: readonly string[];\n}\n\n/** 用户在新会话页当前选中的对话目标。 */\nexport interface PluginNewSessionTarget {\n\treadonly kind: \"agent\" | \"team\";\n\t/** Agent 档案 id 或团队 id。 */\n\treadonly id: string;\n\t/** 目标若由本插件贡献,这里给出 manifest 里的那个 id。 */\n\treadonly contributedId?: string;\n}\n\n/**\n * 渲染上下文。这是一个**会继续生长的对象**:后续新增字段不会破坏既有插件,所以按需\n * 解构、不要假定它只有这些键。\n */\nexport interface PluginNewSessionContext {\n\treadonly target: PluginNewSessionTarget | null;\n\t/** 输入框里提到的、属于本插件的能力。 */\n\treadonly mentionedAbilities: {\n\t\treadonly skills: readonly string[];\n\t\treadonly mcpServers: readonly string[];\n\t};\n\t/**\n\t * 输入框中尚未发送的文本。需要 `conversation.draft.read` 权限,未授予时恒为空串。\n\t *\n\t * 只在本贡献处于激活状态时提供——插件拿不到「用户随便打点什么」的全程流水。\n\t */\n\treadonly draft: string;\n\t/** 当前工作区目录;未选择项目时为 null。 */\n\treadonly cwd: string | null;\n\t/** 回写输入栏。刻意不提供「直接发送」:越过发送前这道关不属于本区职责。 */\n\treadonly composer: {\n\t\t/** 把资源挂成附件,随下一次发送带走。 */\n\t\tattach(attachment: PluginPromptAttachment): void;\n\t\t/**\n\t\t * 往草稿里插一段文本。始终是插入而非替换,免得抹掉用户已经打的内容。\n\t\t *\n\t\t * `position` 缺省为 `\"end\"`(光标处)。`\"start\"` 插到最前面,适合「先定题、细节\n\t\t * 由用户补」这类写法——用户点完多半光标并不在开头,位置只能由调用方定死。\n\t\t */\n\t\tinsertText(text: string, options?: { position?: \"start\" | \"end\" }): void;\n\t};\n}\n\n/**\n * 新会话页输入框下方的一块内容(`ui.slot.new-session-context`)。\n *\n * 与 input-action 的分工:那是发送前的开关,这是发送前的**上下文**——把用户接下来多半\n * 要用到的素材摆出来。激活与否由宿主按 {@link PluginNewSessionContextActivation} 裁决,\n * 插件只负责在被激活后渲染,因此拿不到用户逐键输入的全程内容。\n *\n * 同时有多个贡献上屏时,宿主会在该区域顶部出 tabbar;只有一个时直接渲染内容。\n */\nexport interface PluginNewSessionContextContribution {\n\tid: string;\n\t/** tabbar 上的标题;只有一个贡献上屏时不展示。 */\n\tlabel: string;\n\t/** tab 图标;省略时用插件自己的图标。 */\n\ticon?: ReactNode;\n\tactivateWhen: PluginNewSessionContextActivation;\n\t/**\n\t * 横向占位。`\"input\"`(默认)与输入框同宽,适合补充说明一类的窄内容;`\"wide\"` 铺满\n\t * 页面可用宽度,留给画廊、素材墙这类「内容本身就是主角」的东西——把它们压在输入框\n\t * 宽度里,每一项都会小到看不清。\n\t */\n\twidth?: \"input\" | \"wide\";\n\trender(context: PluginNewSessionContext): ReactNode;\n}\n\n/**\n * 宿主左侧侧边栏此刻的形态。给插件自适应布局用——尤其是沉浸式工作区视图:\n * 侧边栏收起时宿主页头会长出「展开侧边栏」按钮并占住左上角,视图自己画在那一带的\n * 东西需要让位。\n */\nexport interface PluginSidebarState {\n\t/** 用户手动收起了侧边栏。窄屏下这一位仍然只反映用户意愿,不受窗口宽度影响。 */\n\tcollapsed: boolean;\n\t/** 窗口窄到侧边栏改走悬浮覆盖,不再占据左侧一栏。 */\n\tnarrow: boolean;\n\t/** 侧边栏此刻是否实际占着左边那一栏。等价于 `!collapsed && !narrow`,多数自适应只需要这一位。 */\n\tvisible: boolean;\n}\n\nexport interface PluginUiApi {\n\tregisterGlobalSlot(contribution: PluginGlobalSlotContribution): Disposable;\n\tregisterAbilityDetailSlot(contribution: PluginAbilityDetailSlotContribution): Disposable;\n\t/** Render an opaque setup URL as a host-themed PNG data URL. */\n\tcreateQrCode(text: string): Promise<string>;\n\t/**\n\t * Register a **workspace view**(工作区视图)— a full-page surface with its own\n\t * route and sidebar entry, on par with the host's built-in pages. Needs the\n\t * `ui.slot.workspace-view` permission (missing permission = **warn+noop**).\n\t *\n\t * The entry lands in the sidebar's「更多」收纳 by default; the user can pin it\n\t * to the top region or reorder it, and that layout is remembered.\n\t */\n\tregisterWorkspaceView(contribution: PluginWorkspaceViewContribution): Disposable;\n\t/**\n\t * Register a **new-session context block** — content shown beneath the input\n\t * on the new-session page, surfaced only when the user's current selection or\n\t * draft matches {@link PluginNewSessionContextActivation}. Needs the\n\t * `ui.slot.new-session-context` permission (missing permission = **warn+noop**).\n\t */\n\tregisterNewSessionContext(contribution: PluginNewSessionContextContribution): Disposable;\n\t/**\n\t * Navigate to one of this plugin's own workspace views. `viewId` is the\n\t * contribution id passed to {@link PluginUiApi.registerWorkspaceView}. No-op\n\t * when the view is not registered (e.g. permission missing).\n\t */\n\topenWorkspaceView(viewId: string): void;\n\t/**\n\t * Update (or clear, with `null`) the badge on one of this plugin's workspace\n\t * view entries. Re-registering the view is NOT a way to do this — it would\n\t * remount the whole surface — so live badges (unread counts, status dots)\n\t * must come through here.\n\t *\n\t * No-op when the view is not registered (e.g. permission missing).\n\t */\n\tsetWorkspaceViewBadge(viewId: string, badge: PluginNavBadge | null): void;\n\t/**\n\t * Fill (or clear, with `null`) the host page header while one of this\n\t * plugin's workspace views is open. Call it from the view component (an\n\t * effect that re-runs on state change) and clear it on unmount — the host\n\t * keeps the entry keyed by view, and only applies it on that view's route.\n\t *\n\t * The header itself is never removed: it owns the window drag region and the\n\t * macOS traffic-light gutter. This is how a view takes it over instead.\n\t *\n\t * No-op when the view is not registered (e.g. permission missing).\n\t */\n\tsetWorkspaceViewHeader(viewId: string, header: PluginWorkspaceViewHeader | null): void;\n\t/**\n\t * Register a preview component keyed by file extension. The host dispatches\n\t * registered extensions before its built-in fallback renderers; first\n\t * registrant wins on conflict.\n\t */\n\tregisterFilePreview(contribution: PluginFilePreviewContribution): Disposable;\n\t/**\n\t * Register an activity-panel tab into the addable pool. The user attaches\n\t * it manually via the panel's \"+\" picker; attach records are keyed by the\n\t * session cwd.\n\t */\n\tregisterActivityTab(contribution: PluginActivityTabContribution): Disposable;\n\t/**\n\t * Register a toggle action shown beneath the AI input bar. While active,\n\t * its `decoratePrompt()` annotates the next outgoing prompt.\n\t */\n\tregisterInputAction(contribution: PluginInputActionContribution): Disposable;\n\t/**\n\t * Register a card renderer keyed by `type`. Cards rendered beneath a message\n\t * come from tool results' out-of-band `details.cards` (or `pendingFor` for\n\t * in-flight tools); the host resolves each card's `type` to a registered\n\t * renderer. Multiple cards under one message are shown as a tab-switcher\n\t * (\"收纳\") or a flat list.\n\t */\n\tregisterCardRenderer(contribution: PluginCardRendererContribution): Disposable;\n\t/**\n\t * Register a renderer that replaces the host's default inline transcript UI\n\t * for a tool call (matched by `toolName`). The complement to card renderers:\n\t * use it to render UI for a plugin's own agent tool output.\n\t */\n\tregisterToolCallSlot(contribution: PluginToolCallSlotContribution): Disposable;\n\t/**\n\t * Register a card rendered at the bottom of the message list for the latest\n\t * turn — NOT bound to a tool call. The host mounts the component in the\n\t * footer slot; the plugin owns visibility (return `null` to render nothing,\n\t * e.g. git renders only in a repo with changes). Gated by `scope_use`\n\t * (fail-closed). Needs the `ui.slot.turn-card` permission.\n\t */\n\tregisterTurnCard(contribution: PluginTurnCardContribution): Disposable;\n\t/**\n\t * Register a keyboard shortcut scope on the host's shared ShortcutScopeStack\n\t * (same path as host UI: modal > overlay > surface > app). Needs\n\t * `ui.shortcuts.register`. Plugins cannot use kind `\"app\"` (reserved for\n\t * host-configurable global actions). Prefer {@link usePluginShortcutScope}\n\t * from React components with a module-captured `registerShortcutScope`.\n\t */\n\tregisterShortcutScope(contribution: PluginShortcutScopeContribution): Disposable;\n\t/**\n\t * Programmatically attach (if needed) and activate one of this plugin's\n\t * own activity tabs in a conversation's activity panel. `tabId`\n\t * is the contribution id passed to registerActivityTab. Any payload (e.g.\n\t * which image to edit) is passed via the plugin's own in-memory state.\n\t *\n\t * Pass `options.width` to size the panel as it opens — a pixel number, or\n\t * `\"max\"` to expand it to the widest the current window allows (the host\n\t * still clamps to its min/max and auto-hides the sidebar when needed). Omit\n\t * to leave the user's current width untouched.\n\t *\n\t * Omit `options.cwd` for the conversation currently displayed by the host.\n\t * Tool handlers and background work should pass their session cwd explicitly.\n\t */\n\topenActivityTab(tabId: string, options?: PluginOpenActivityTabOptions): void;\n\t/**\n\t * 把本插件的某个活动面板标签卡在目标会话里上栏 / 下栏,**不激活也不展开\n\t * 面板**——`openActivityTab` 是「用户此刻要看它」,这个是「它现在该不该在\n\t * 栏里」。配合 `initiallyVisible: false` 使用,插件即可完全掌握自己标签卡的\n\t * 出现条件(如 git 只在仓库目录里上栏、工作台跟随输入栏 toggle)。\n\t *\n\t * 上栏记录按会话 cwd 持久化(ADR-0026),所以只需在条件变化时调用一次;\n\t * 用户随后用减号手动隐藏的结果不会被重复调用覆盖。缺省作用于宿主当前显示的\n\t * 会话;工具 handler 与后台任务应通过 `options.cwd` 传入自己的会话 cwd。既没有\n\t * 显式 cwd、也没有活动会话时为 no-op(无处记录)。\n\t */\n\tsetActivityTabVisible(tabId: string, visible: boolean, options?: PluginActivityTabTargetOptions): void;\n\t/**\n\t * 直接设置活动面板宽度:像素值,或 `\"max\"` 表示「跟随窗口拉满」(宿主仍会夹到\n\t * 自己的 min/max 内,必要时自动收起侧边栏)。\n\t *\n\t * `\"max\"` 是一种持续状态而非一次性求值:窗口尺寸变化时面板跟着变宽变窄,直到\n\t * 用户拖动分隔条或有人写入具体像素为止。传数字则是一次性的固定宽度。\n\t *\n\t * 与 `openActivityTab(id, { width })` 的区别:那里的宽度只在标签卡首次 attach\n\t * 时生效(避免 activate 重放覆盖用户手拖的宽度);这个是命令式的,每次调用都\n\t * 生效,供插件在自己的标签卡被激活、进入某种视图时按需调整。用户随后仍可拖动。\n\t */\n\tsetActivityPanelWidth(width: number | \"max\"): void;\n\t/**\n\t * Bind or clear plugin-owned context for outgoing prompts. The host renders\n\t * its label/icon and carries a structured `context` as a versioned snapshot.\n\t * Attachments default to one-shot; `lifecycle: \"sticky\"` remains until the\n\t * plugin or user clears the capsule.\n\t */\n\tsetPromptAttachment(attachment: PluginPromptAttachment | null): void;\n\t/**\n\t * Open the host's global full-screen image previewer for the given image.\n\t * Only the image reference (id/url) crosses over — bytes stay out-of-band.\n\t *\n\t * Pass `group` (e.g. all images of the message) to open as an image group:\n\t * the previewer shows a thumbnail strip + arrows and starts at `ref`.\n\t */\n\tpreviewImage(ref: PluginImageRef, group?: PluginImageRef[]): void;\n\t/**\n\t * Open the host's global file previewer for any file — the general form of\n\t * {@link PluginUiApi.previewImage}, which only takes image URLs. Accepts a\n\t * local absolute `path` (the shape the host's own file tree uses) as well as\n\t * a `url`; the previewer dispatches by the file's extension, so a file type\n\t * some plugin registered via `registerFilePreview` lands in that renderer.\n\t *\n\t * Pass `group` (e.g. all outputs of one run) to open as a group: images get\n\t * the thumbnail strip + arrows, and the previewer starts at `file`.\n\t *\n\t * Permissions: `fs.read` as soon as any entry carries a `path` (it hands a\n\t * local file to the host to read); `ui.slot.message` for url-only calls,\n\t * same gate as `previewImage`.\n\t */\n\tpreviewFile(file: PluginPreviewFileRef, group?: PluginPreviewFileRef[]): void;\n\t/**\n\t * Capture a rectangle in the current Vetta window and open the host save\n\t * dialog. Coordinates use renderer DIP values such as getBoundingClientRect().\n\t * Requires `ui.slot.activity-tab`.\n\t */\n\tcaptureRegion(rect: PluginCaptureRegion, defaultFileName: string): Promise<string | null>;\n\t/**\n\t * Copy an image to the system clipboard. Takes a `data:image/...;base64,`\n\t * URL and goes through the native clipboard, so it does not depend on the\n\t * renderer's `ClipboardItem` support. No permission required — the plugin\n\t * can only write what it already rendered.\n\t */\n\tcopyImage(dataUrl: string): Promise<void>;\n\t/**\n\t * Hand a URL to the OS default browser (Electron `shell.openExternal`) —\n\t * NOT the in-app browser panel. Only `http:`/`https:` are accepted; the host\n\t * rejects every other protocol, so this cannot be used to launch arbitrary\n\t * schemes. Needs `shell.openExternal`.\n\t */\n\topenExternal(url: string): Promise<void>;\n\t/**\n\t * Show a global toast in the host UI (bottom-right). No permission required.\n\t * Prefer this over swallowing errors into opaque UI copy: pass `error` so\n\t * the host attaches a one-click \"copy stack\" action for the user.\n\t *\n\t * Capture `ctx.ui.notify` in `activate` if React components need it\n\t * (components do not receive `ctx`).\n\t */\n\tnotify(options: PluginNotifyOptions): void;\n\t/**\n\t * 读当前侧边栏形态。无需权限——这是纯布局信息,不含任何用户数据。\n\t *\n\t * React 组件请改用 `useSidebarState()`:它会在状态变化时重渲染,不必自己订阅。\n\t * 这一对只为拿不到 hook 的地方准备(`activate()` 内、工具处理器、命令式绘制的画布)。\n\t */\n\tgetSidebarState(): PluginSidebarState;\n\t/**\n\t * 订阅侧边栏形态变化——用户收起/展开侧边栏、或窗口跨过窄屏阈值时触发。\n\t * 返回 Disposable 取消订阅;请在插件失活时释放。\n\t *\n\t * 回调按值去重:拖窗口不会把它打成回调风暴,只有三元组真的变了才通知。\n\t */\n\tonSidebarStateChanged(listener: (state: PluginSidebarState) => void): Disposable;\n}\n"]}
|
package/dist/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType, ReactNode } from \"react\";\nimport type { ConversationMessage } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginImageRef } from \"./images.js\";\nimport type { PluginPromptAttachment } from \"./prompt-attachment.js\";\nimport type { ConversationScenario } from \"./scenario.js\";\nimport type { PluginShortcutScopeContribution } from \"./shortcuts.js\";\n\nexport interface PluginGlobalSlotContribution {\n\tid: string;\n\tcomponent: ComponentType;\n}\n\nexport interface PluginAbilityDetailSlotProps {\n\tabilityId: string;\n\tinstalled: boolean;\n\tenabled: boolean;\n}\n\n/** Inline setup/status surface rendered near the top of one ability detail page. */\nexport interface PluginAbilityDetailSlotContribution {\n\tid: string;\n\tabilityId: string;\n\tcomponent: ComponentType<PluginAbilityDetailSlotProps>;\n}\n\n/**\n * Props handed to a workspace-view component. A workspace view owns the whole\n * content area, so unlike panel slots it is addressed by its own route and can\n * be deep-linked; the host passes back its identity so one component can serve\n * several registered views.\n */\nexport interface PluginWorkspaceViewProps {\n\t/** The contribution id as registered (NOT namespaced). */\n\tviewId: string;\n\t/** The owning plugin id. */\n\tpluginId: string;\n}\n\n/**\n * Badge tone. The host maps it to its own theme colors — a plugin cannot pick a\n * raw color, so badges stay consistent with the built-in navigation entries.\n */\nexport type PluginNavBadgeTone = \"accent\" | \"danger\" | \"default\" | \"warning\";\n\n/**\n * A badge on the plugin's sidebar navigation entry.\n *\n * `beta` is the host's own preset — it renders exactly like the built-in\n * 知识库 Beta 标识, wording included (and localized by the host), so plugins do\n * not have to spell \"Beta\" themselves in every locale.\n *\n * `count` renders `99+` past 99 and disappears at 0 — an unread badge showing\n * \"0\" is worse than no badge.\n */\nexport type PluginNavBadge =\n\t| { kind: \"beta\" }\n\t| { kind: \"text\"; text: string; tone?: PluginNavBadgeTone }\n\t| { kind: \"count\"; count: number; tone?: PluginNavBadgeTone }\n\t| { kind: \"dot\"; tone?: PluginNavBadgeTone };\n\n/**\n * A **workspace view**(工作区视图): a full-page surface a plugin contributes to\n * the host's primary navigation. It is the plugin counterpart of a built-in page\n * such as 自动化 / 知识库 — the host gives it its own route\n * (`/workspace/<pluginId>/<viewId>`) and a sidebar entry, and the plugin owns the\n * entire content area while it is open.\n *\n * Use it for standalone workbenches that are NOT bound to one conversation\n * (dashboards, boards, consoles). Conversation-scoped UI belongs in an\n * {@link PluginActivityTabContribution activity tab}; floating UI belongs in a\n * {@link PluginGlobalSlotContribution global slot}.\n */\nexport interface PluginWorkspaceViewContribution {\n\t/** Unique within the plugin; the host namespaces it as `${pluginId}:${id}`. */\n\tid: string;\n\t/** Sidebar entry label. Supports `%catalogKey%` i18n lookup. */\n\tlabel: string;\n\t/**\n\t * Sidebar entry icon as an **iconify class string** (e.g.\n\t * `\"icon-[solar--widget-5-linear]\"`) — NOT a React node, because the host\n\t * renders it inside its own nav button and persists nav layout by key.\n\t *\n\t * Omit it to inherit the plugin's own `plugin.json` icon: a packaged image\n\t * (svg / png / webp …) is masked with the theme's foreground color, so a plugin\n\t * that ships artwork does not have to find a lookalike in an icon set. Set\n\t * {@link PluginWorkspaceViewContribution.iconTint} to `false` to keep its colors.\n\t */\n\ticon?: string;\n\t/**\n\t * Whether an image icon is tinted with the theme's foreground color. Defaults to\n\t * `true`, which keeps the entry consistent with the built-in navigation and legible\n\t * in every theme.\n\t *\n\t * Pass `false` for a full-color logo. Weigh it first: the entry renders at 16px\n\t * beside monochrome built-ins, and a fixed-color image cannot follow the active\n\t * theme — a dark logo can disappear on a dark sidebar. Has no effect on Iconify\n\t * class icons, which are always tinted.\n\t */\n\ticonTint?: boolean;\n\t/** Optional one-line description; shown as the nav entry tooltip. */\n\tdescription?: string;\n\t/**\n\t * Initial badge on the sidebar entry. `{ kind: \"text\" }` supports the same\n\t * `%catalogKey%` i18n lookup as {@link label}. Update it at runtime with\n\t * {@link PluginUiApi.setWorkspaceViewBadge}.\n\t */\n\tbadge?: PluginNavBadge;\n\t/** Zero-props aside from {@link PluginWorkspaceViewProps}. */\n\tcomponent: ComponentType<PluginWorkspaceViewProps>;\n\t/** Sort hint among this plugin's own views (ascending). Defaults to 0. */\n\tnavOrder?: number;\n\t/**\n\t * Whether this view takes a sidebar entry. Defaults to `true`.\n\t *\n\t * Pass `false` for a surface users open occasionally — a setup page, a\n\t * diagnostics console. It then lives only under Settings → More options,\n\t * where the host lists every off-sidebar view and opens it inside the\n\t * settings shell, so switching between such pages stays one click.\n\t *\n\t * The sidebar is a scarce, user-curated space: a plugin that always claims a\n\t * slot pushes the entries someone actually uses into the overflow menu.\n\t */\n\tsidebar?: boolean;\n}\n\n/**\n * What a workspace view puts into the **host page header** — the window's top\n * bar that also carries the drag region, the macOS traffic-light gutter and the\n * sidebar trigger.\n *\n * Without this the header still renders, showing the app name above the\n * plugin's own toolbar — two stacked bars. Set `hideTitle` and move the view's\n * toolbar in here and the surface gets a single, host-consistent header.\n *\n * `left` / `right` are ReactNodes rendered by the host inside that bar (left:\n * right after the sidebar trigger; right: before the window controls). They are\n * rendered in the plugin's i18n + CSS scope, so `useTranslation()` and the\n * plugin's own classes work as usual. Pass fresh nodes whenever the view's\n * state changes — this is a live setter, not a one-time registration.\n */\nexport interface PluginWorkspaceViewHeader {\n\t/** Replaces the host title text. Supports `%catalogKey%` i18n lookup. */\n\ttitle?: string;\n\t/** Drop the host title entirely (use when {@link left} carries its own). */\n\thideTitle?: boolean;\n\t/** Rendered in the header's left cluster, after the sidebar trigger. */\n\tleft?: ReactNode;\n\t/** Rendered in the header's action cluster, before the window controls. */\n\tright?: ReactNode;\n\t/**\n\t * Float the host header OVER the view instead of stacking above it. The view\n\t * then owns the full content height, and its top `~44px` sit under the\n\t * transparent header strip (window drag region / traffic lights / sidebar\n\t * trigger all keep working on top). Use for immersive full-page surfaces\n\t * whose own hero starts at the very top; leave unset for toolbar-style\n\t * headers that need their own opaque row.\n\t */\n\timmersive?: boolean;\n}\n\nexport interface PluginAudioMetadata {\n\t/** Embedded title; preview renderers should fall back to file.name. */\n\ttitle?: string;\n\tartist?: string;\n\t/** Embedded cover art as a Data URL when available. */\n\tcoverDataUrl?: string;\n}\n\nexport interface PluginPreviewUrlOptions {\n\t/** Optional media hint for ambiguous containers such as webm. */\n\tmediaKind?: \"audio\" | \"video\";\n}\n\n/**\n * The file handed to a file-preview plugin component. The host does NOT\n * pre-read or guess encoding — the plugin decides whether to read text or\n * bytes. `path` is also exposed for plugins that prefer native fetch.\n */\nexport interface PluginPreviewFile {\n\tpath: string | null;\n\tname: string;\n\textension: string;\n\tmime: string;\n\tsize: number;\n\t/** Read the file as a UTF-8 string. */\n\treadText(): Promise<string>;\n\t/** Read the raw file bytes. */\n\treadBytes(): Promise<ArrayBuffer>;\n\t/** A fetchable streaming URL for the file (Range-capable). */\n\tgetUrl(options?: PluginPreviewUrlOptions): string;\n\t/**\n\t * Subscribe to on-disk changes of this file. The listener fires (debounced\n\t * by the host) whenever the file's contents change, letting previews update\n\t * live. Returns a Disposable; call dispose() to stop watching. A no-op for\n\t * files without a real path (url-only sources).\n\t */\n\twatch(listener: () => void): Disposable;\n\t/**\n\t * Host-provided audio metadata for local media files. Returns null when the\n\t * host cannot provide metadata, e.g. url-only sources or unsupported files.\n\t */\n\tgetAudioMetadata?(): Promise<PluginAudioMetadata | null>;\n}\n\nexport interface PluginFilePreviewProps {\n\tfile: PluginPreviewFile;\n}\n\n/**\n * A file handed to {@link PluginUiApi.previewFile} — the *opening* side of the\n * global previewer, the mirror image of {@link PluginPreviewFile} (which is the\n * *rendering* side). Bytes never cross over: the host reads the source itself.\n *\n * Exactly one of `path` (local absolute path) or `url` (host media / http URL)\n * must be given. `path` is the shape the host's own file tree uses, so the\n * previewer also offers \"在 Finder 中显示\" for it.\n */\nexport interface PluginPreviewFileRef {\n\t/** Local absolute path. Requires the `fs.read` permission. */\n\tpath?: string;\n\t/** Fetchable URL (host media URL or http/https). Requires `ui.slot.message`. */\n\turl?: string;\n\t/**\n\t * Display name **including the extension** — the previewer dispatches to a\n\t * renderer by this extension, not by `mimeType`. Optional for `path`\n\t * sources (the host falls back to the path's basename).\n\t */\n\tname?: string;\n\tmimeType?: string;\n\t/** Byte size, shown in the previewer's download detail when known. */\n\tsize?: number;\n}\n\nexport interface PluginFilePreviewContribution {\n\t/** Lower-case extensions without the dot, e.g. [\"svg\"]. */\n\textensions: string[];\n\tcomponent: ComponentType<PluginFilePreviewProps>;\n}\n\n/**\n * An activity-panel tab contributed by a plugin. Registering only adds the\n * tab to the \"addable pool\" — it renders only after the user attaches it in\n * the activity panel (scoped by session cwd).\n */\n/** Host residency policy for an activity-panel tab. */\nexport type PluginActivityTabRetention = \"active-only\" | \"warm\" | \"pinned\";\n\nexport interface PluginActivityTabContribution {\n\tid: string;\n\tlabel: string;\n\t/**\n\t * Tab icon as a React node (not an iconify class string).\n\t * Omit to inherit the host-resolved brand icon from `plugin.json#icon`\n\t * (`ctx.plugin.iconUrl`). Prefer omitting for package brand icons so the\n\t * plugin never loads assets via absolute `/…` paths or host protocols.\n\t */\n\ticon?: ReactNode;\n\tcomponent: ComponentType;\n\t/**\n\t * 允许该标签卡出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如\n\t * `[\"project\", \"conversation\"]`)。会话页插槽据此随对话类型显隐。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/**\n\t * 注册后是否默认在标签栏里(缺省 `true`)。声明 `false` 表示「出现条件由我\n\t * 自己决定」——注册只是入池,之后由 {@link PluginUiApi.setActivityTabVisible}\n\t * 或 {@link PluginUiApi.openActivityTab} 决定何时上栏(如 git 只在仓库目录、\n\t * 工作台跟随输入栏 toggle)。无论哪种,用户仍可用减号手动隐藏。\n\t */\n\tinitiallyVisible?: boolean;\n\t/**\n\t * Component residency while the tab is inactive. Defaults to `\"warm\"`:\n\t * visited tabs stay mounted in the host's bounded LRU cache. Use\n\t * `\"active-only\"` for cheap, stateless content and `\"pinned\"` for runtimes\n\t * that must never be evicted while available.\n\t */\n\tretention?: PluginActivityTabRetention;\n\t/**\n\t * @deprecated Use {@link PluginActivityTabContribution.retention}. `true`\n\t * maps to `\"pinned\"`; `false` maps to `\"active-only\"`.\n\t */\n\tkeepAliveWhenAvailable?: boolean;\n}\n\n/** Explicit conversation scope for an activity-tab command. */\nexport interface PluginActivityTabTargetOptions {\n\t/**\n\t * Absolute cwd whose activity-tab state should be changed. Omit to target\n\t * the conversation currently displayed by the host. Tool handlers and\n\t * background work should pass the triggering session's cwd so a foreground\n\t * navigation change cannot redirect the command to another conversation.\n\t */\n\tcwd?: string;\n}\n\n/** Options for {@link PluginUiApi.openActivityTab}. */\nexport interface PluginOpenActivityTabOptions extends PluginActivityTabTargetOptions {\n\t/**\n\t * Desired panel width as it opens: a pixel number, or `\"max\"` to track the\n\t * widest the window allows — `\"max\"` keeps following window resizes until the\n\t * user drags the divider. The host clamps to its min/max bounds. Omit to keep\n\t * the user's current width.\n\t */\n\twidth?: number | \"max\";\n}\n\nexport interface PluginCaptureRegion {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Decoration a plugin contributes to the next outgoing prompt while its input\n * action is active. `metadata` is shallow-merged into the prompt request and\n * `instructions` are appended as hidden, model-visible guidance.\n */\nexport interface PluginPromptDecoration {\n\tmetadata?: Record<string, unknown>;\n\t/** Hidden plugin-owned instructions appended to the next agent turn. */\n\tinstructions?: string[];\n}\n\n/**\n * An action button shown in a row beneath the AI input bar. Rendered as a\n * toggle: clicking activates, clicking again deactivates. While active, the\n * host calls `decoratePrompt()` before each send and merges the returned\n * metadata into the outgoing prompt request. The plugin owns any side state\n * (it is the same Module Federation instance as its other slots).\n */\nexport interface PluginInputActionContribution {\n\tid: string;\n\tlabel: string;\n\t/** Button icon as a React node (not an iconify class string). */\n\ticon?: ReactNode;\n\t/** Whether the action begins in the active state. Defaults to false. */\n\tdefaultActive?: boolean;\n\t/**\n\t * 该输入动作所依赖的 agent 工具名。设置后,仅当该工具在当前会话处于激活(按工具的\n\t * scope_use 解析)时才显示这个 badge——避免在工具被场景屏蔽(如批量任务)时仍显示一个\n\t * 点了也无效的开关。不设则始终显示。例如「图像生成」设为 \"generate_image\"。\n\t */\n\trequiresActiveTool?: string;\n\t/**\n\t * 允许该 toggle 出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现。与 `requiresActiveTool`\n\t * 取「与」:两者都满足才显示。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/**\n\t * When true, this plugin's agent contributions (tools / skills / MCP /\n\t * systemPrompt) and Activity Tabs are hard-isolated: inactive until this\n\t * toggle is on (ADR-0041, knowledgeMode-style). Default false.\n\t */\n\thardIsolation?: boolean;\n\t/**\n\t * Fired when the user toggles the action; `active` is the new state. Return\n\t * `false` when `active` is true to VETO the activation (e.g. the plugin needs\n\t * configuration first) — the toggle stays off. Deactivation can't be vetoed.\n\t */\n\tonToggle?(active: boolean): boolean | void;\n\t/**\n\t * Called by the host before sending while the action is active. The\n\t * returned metadata is merged into the outgoing prompt request.\n\t */\n\tdecoratePrompt?(): PluginPromptDecoration | void;\n}\n\n/**\n * A declarative, serializable descriptor for one card rendered beneath a\n * message. `type` selects a registered card renderer; `key` drives cross-turn\n * dedup (same key across turns = one logical card, shown only under its latest\n * anchor); `payload` carries STABLE REFERENCES (e.g. image ids), not a content\n * snapshot — the renderer resolves live state from it. `title`/`icon` label the\n * card's tab (override the renderer's registration defaults). Rides a tool\n * result's out-of-band `details.cards`; crosses the agent→host boundary, so\n * `icon` is an icon-symbol string, not a node.\n */\nexport interface CardDescriptor {\n\ttype: string;\n\tkey?: string;\n\tpayload?: unknown;\n\ttitle?: string;\n\ticon?: string;\n}\n\n/** A pending (in-flight) tool call handed to a renderer's `pendingFor`. */\nexport interface PluginPendingToolCall {\n\ttoolName: string;\n\targs: Record<string, unknown>;\n}\n\n/**\n * Props for a card renderer. `descriptor` is the card's data; `pending` is true\n * while it was synthesized from an in-flight tool (render a skeleton); `message`\n * is the anchoring conversation message.\n */\nexport interface PluginCardProps {\n\tdescriptor: CardDescriptor;\n\tpending: boolean;\n\tmessage: ConversationMessage;\n}\n\n/**\n * A card renderer registered by a plugin, keyed by `type`. A descriptor whose\n * `type` matches is rendered by `component`. `title`/`icon` are the default tab\n * label/icon (a descriptor may override `title`). `pendingFor`, given an\n * in-flight tool call, returns a provisional descriptor so a skeleton card\n * appears (and claims a tab) before the tool's result lands — or null when this\n * renderer doesn't handle that tool. The `type` must be globally unique across\n * plugins (convention: prefix with the plugin id, e.g. \"image-gen:preview\").\n */\nexport interface PluginCardRendererContribution {\n\ttype: string;\n\tcomponent: ComponentType<PluginCardProps>;\n\ttitle?: string;\n\t/** Default tab icon as a React node (not an iconify class string). */\n\ticon?: ReactNode;\n\tpendingFor?: (toolCall: PluginPendingToolCall) => CardDescriptor | null;\n}\n\n/** A tool call handed to a tool-call slot renderer. */\nexport interface PluginToolCallSlotToolCall {\n\ttoolCallId: string;\n\ttoolName: string;\n\targs: Record<string, unknown>;\n\tstatus: \"pending\" | \"success\" | \"error\" | \"cancelled\";\n\tresult?: string;\n\tisError?: boolean;\n}\n\nexport interface PluginToolCallSlotProps {\n\ttoolCall: PluginToolCallSlotToolCall;\n}\n\n/**\n * A component that **replaces the host's default inline transcript rendering**\n * for a specific tool (matched by `toolName`; first registered renderer wins).\n * This is how a plugin renders rich UI for its OWN agent tool's output — plugin\n * tools cannot emit `details.cards`, so the message card system (registerCardRenderer)\n * does not serve them; the tool-call slot does.\n */\nexport interface PluginToolCallSlotContribution {\n\tid: string;\n\ttoolName: string;\n\tcomponent: ComponentType<PluginToolCallSlotProps>;\n}\n\n/**\n * A card rendered at the bottom of the message list for the LATEST turn — NOT\n * bound to a tool call. The host mounts `component` in the footer slot and\n * re-mounts it each session/turn; the plugin owns visibility entirely (it reads\n * live state via SDK hooks — `useActiveConversation`, `useConversationMessages`,\n * `ctx.conversation.on(\"turn-end\")` — and returns `null` to render nothing,\n * e.g. git renders only inside a repo that has changes). `scope_use` gates which\n * conversation scenarios it may appear in (**fail-closed**, mirrors the other\n * slots). `id` must be unique within the plugin.\n */\nexport interface PluginTurnCardContribution {\n\tid: string;\n\tcomponent: ComponentType;\n\t/**\n\t * 允许该 turn 卡出现的对话场景 slug 列表(镜像其它插槽的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如 `[\"project\"]`)。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n}\n\n/**\n * Options for {@link PluginUiApi.notify}. Surfaces a host toast so users can\n * see plugin failures without opening DevTools.\n */\nexport interface PluginNotifyOptions {\n\t/** Toast body. Required even when `error` is set (user-facing summary). */\n\tmessage: string;\n\t/** Defaults to plugin display name when omitted. */\n\ttitle?: string;\n\t/** Defaults to `\"info\"`; when `error` is set and variant omitted, host uses `\"error\"`. */\n\tvariant?: \"info\" | \"success\" | \"warning\" | \"error\";\n\t/**\n\t * Optional failure cause. Host formats message + stack and adds a\n\t * \"复制堆栈\" action so the user can paste it into bug reports / chat.\n\t */\n\terror?: unknown;\n\t/**\n\t * Auto-dismiss delay in ms. `0` keeps the toast until dismissed.\n\t * Defaults: sticky (`0`) when `error` is present, otherwise host default (~4s).\n\t */\n\tdurationMs?: number;\n}\n\n/**\n * 新会话上下文区的激活条件。**只能写本插件自己的东西**——填别人的 id 一律不生效。\n *\n * 这条限制是故意的:否则插件 A 可以声明「只要用户选了 B 的智能体我就上屏」,把别人的\n * 使用场景劫持过来。\n *\n * 各字段取并集:任意一条命中即激活。至少要声明一条——全空等于「任何新会话都上屏」,宿主拒掉。\n */\nexport interface PluginNewSessionContextActivation {\n\t/** 本插件在 manifest 里声明的智能体 id(不带 `plugin:` 前缀)。 */\n\tagents?: readonly string[];\n\t/** 本插件在 manifest 里声明的团队 id。省略则任意「含本插件成员的团队」都算命中。 */\n\tteams?: readonly string[];\n\t/** 本插件提供的 skill 名;用户在输入框里提到时命中。 */\n\tskills?: readonly string[];\n\t/** 本插件提供的 MCP server 名。 */\n\tmcpServers?: readonly string[];\n}\n\n/** 用户在新会话页当前选中的对话目标。 */\nexport interface PluginNewSessionTarget {\n\treadonly kind: \"agent\" | \"team\";\n\t/** Agent 档案 id 或团队 id。 */\n\treadonly id: string;\n\t/** 目标若由本插件贡献,这里给出 manifest 里的那个 id。 */\n\treadonly contributedId?: string;\n}\n\n/**\n * 渲染上下文。这是一个**会继续生长的对象**:后续新增字段不会破坏既有插件,所以按需\n * 解构、不要假定它只有这些键。\n */\nexport interface PluginNewSessionContext {\n\treadonly target: PluginNewSessionTarget | null;\n\t/** 输入框里提到的、属于本插件的能力。 */\n\treadonly mentionedAbilities: {\n\t\treadonly skills: readonly string[];\n\t\treadonly mcpServers: readonly string[];\n\t};\n\t/**\n\t * 输入框中尚未发送的文本。需要 `conversation.draft.read` 权限,未授予时恒为空串。\n\t *\n\t * 只在本贡献处于激活状态时提供——插件拿不到「用户随便打点什么」的全程流水。\n\t */\n\treadonly draft: string;\n\t/** 当前工作区目录;未选择项目时为 null。 */\n\treadonly cwd: string | null;\n\t/** 回写输入栏。刻意不提供「直接发送」:越过发送前这道关不属于本区职责。 */\n\treadonly composer: {\n\t\t/** 把资源挂成附件,随下一次发送带走。 */\n\t\tattach(attachment: PluginPromptAttachment): void;\n\t\t/**\n\t\t * 往草稿里插一段文本。始终是插入而非替换,免得抹掉用户已经打的内容。\n\t\t *\n\t\t * `position` 缺省为 `\"end\"`(光标处)。`\"start\"` 插到最前面,适合「先定题、细节\n\t\t * 由用户补」这类写法——用户点完多半光标并不在开头,位置只能由调用方定死。\n\t\t */\n\t\tinsertText(text: string, options?: { position?: \"start\" | \"end\" }): void;\n\t};\n}\n\n/**\n * 新会话页输入框下方的一块内容(`ui.slot.new-session-context`)。\n *\n * 与 input-action 的分工:那是发送前的开关,这是发送前的**上下文**——把用户接下来多半\n * 要用到的素材摆出来。激活与否由宿主按 {@link PluginNewSessionContextActivation} 裁决,\n * 插件只负责在被激活后渲染,因此拿不到用户逐键输入的全程内容。\n *\n * 同时有多个贡献上屏时,宿主会在该区域顶部出 tabbar;只有一个时直接渲染内容。\n */\nexport interface PluginNewSessionContextContribution {\n\tid: string;\n\t/** tabbar 上的标题;只有一个贡献上屏时不展示。 */\n\tlabel: string;\n\t/** tab 图标;省略时用插件自己的图标。 */\n\ticon?: ReactNode;\n\tactivateWhen: PluginNewSessionContextActivation;\n\t/**\n\t * 横向占位。`\"input\"`(默认)与输入框同宽,适合补充说明一类的窄内容;`\"wide\"` 铺满\n\t * 页面可用宽度,留给画廊、素材墙这类「内容本身就是主角」的东西——把它们压在输入框\n\t * 宽度里,每一项都会小到看不清。\n\t */\n\twidth?: \"input\" | \"wide\";\n\trender(context: PluginNewSessionContext): ReactNode;\n}\n\n/**\n * 宿主左侧侧边栏此刻的形态。给插件自适应布局用——尤其是沉浸式工作区视图:\n * 侧边栏收起时宿主页头会长出「展开侧边栏」按钮并占住左上角,视图自己画在那一带的\n * 东西需要让位。\n */\nexport interface PluginSidebarState {\n\t/** 用户手动收起了侧边栏。窄屏下这一位仍然只反映用户意愿,不受窗口宽度影响。 */\n\tcollapsed: boolean;\n\t/** 窗口窄到侧边栏改走悬浮覆盖,不再占据左侧一栏。 */\n\tnarrow: boolean;\n\t/** 侧边栏此刻是否实际占着左边那一栏。等价于 `!collapsed && !narrow`,多数自适应只需要这一位。 */\n\tvisible: boolean;\n}\n\nexport interface PluginUiApi {\n\tregisterGlobalSlot(contribution: PluginGlobalSlotContribution): Disposable;\n\tregisterAbilityDetailSlot(contribution: PluginAbilityDetailSlotContribution): Disposable;\n\t/** Render an opaque setup URL as a host-themed PNG data URL. */\n\tcreateQrCode(text: string): Promise<string>;\n\t/**\n\t * Register a **workspace view**(工作区视图)— a full-page surface with its own\n\t * route and sidebar entry, on par with the host's built-in pages. Needs the\n\t * `ui.slot.workspace-view` permission (missing permission = **warn+noop**).\n\t *\n\t * The entry lands in the sidebar's「更多」收纳 by default; the user can pin it\n\t * to the top region or reorder it, and that layout is remembered.\n\t */\n\tregisterWorkspaceView(contribution: PluginWorkspaceViewContribution): Disposable;\n\t/**\n\t * Register a **new-session context block** — content shown beneath the input\n\t * on the new-session page, surfaced only when the user's current selection or\n\t * draft matches {@link PluginNewSessionContextActivation}. Needs the\n\t * `ui.slot.new-session-context` permission (missing permission = **warn+noop**).\n\t */\n\tregisterNewSessionContext(contribution: PluginNewSessionContextContribution): Disposable;\n\t/**\n\t * Navigate to one of this plugin's own workspace views. `viewId` is the\n\t * contribution id passed to {@link PluginUiApi.registerWorkspaceView}. No-op\n\t * when the view is not registered (e.g. permission missing).\n\t */\n\topenWorkspaceView(viewId: string): void;\n\t/**\n\t * Update (or clear, with `null`) the badge on one of this plugin's workspace\n\t * view entries. Re-registering the view is NOT a way to do this — it would\n\t * remount the whole surface — so live badges (unread counts, status dots)\n\t * must come through here.\n\t *\n\t * No-op when the view is not registered (e.g. permission missing).\n\t */\n\tsetWorkspaceViewBadge(viewId: string, badge: PluginNavBadge | null): void;\n\t/**\n\t * Fill (or clear, with `null`) the host page header while one of this\n\t * plugin's workspace views is open. Call it from the view component (an\n\t * effect that re-runs on state change) and clear it on unmount — the host\n\t * keeps the entry keyed by view, and only applies it on that view's route.\n\t *\n\t * The header itself is never removed: it owns the window drag region and the\n\t * macOS traffic-light gutter. This is how a view takes it over instead.\n\t *\n\t * No-op when the view is not registered (e.g. permission missing).\n\t */\n\tsetWorkspaceViewHeader(viewId: string, header: PluginWorkspaceViewHeader | null): void;\n\t/**\n\t * Register a preview component keyed by file extension. The host dispatches\n\t * registered extensions before its built-in fallback renderers; first\n\t * registrant wins on conflict.\n\t */\n\tregisterFilePreview(contribution: PluginFilePreviewContribution): Disposable;\n\t/**\n\t * Register an activity-panel tab into the addable pool. The user attaches\n\t * it manually via the panel's \"+\" picker; attach records are keyed by the\n\t * session cwd.\n\t */\n\tregisterActivityTab(contribution: PluginActivityTabContribution): Disposable;\n\t/**\n\t * Register a toggle action shown beneath the AI input bar. While active,\n\t * its `decoratePrompt()` annotates the next outgoing prompt.\n\t */\n\tregisterInputAction(contribution: PluginInputActionContribution): Disposable;\n\t/**\n\t * Register a card renderer keyed by `type`. Cards rendered beneath a message\n\t * come from tool results' out-of-band `details.cards` (or `pendingFor` for\n\t * in-flight tools); the host resolves each card's `type` to a registered\n\t * renderer. Multiple cards under one message are shown as a tab-switcher\n\t * (\"收纳\") or a flat list.\n\t */\n\tregisterCardRenderer(contribution: PluginCardRendererContribution): Disposable;\n\t/**\n\t * Register a renderer that replaces the host's default inline transcript UI\n\t * for a tool call (matched by `toolName`). The complement to card renderers:\n\t * use it to render UI for a plugin's own agent tool output.\n\t */\n\tregisterToolCallSlot(contribution: PluginToolCallSlotContribution): Disposable;\n\t/**\n\t * Register a card rendered at the bottom of the message list for the latest\n\t * turn — NOT bound to a tool call. The host mounts the component in the\n\t * footer slot; the plugin owns visibility (return `null` to render nothing,\n\t * e.g. git renders only in a repo with changes). Gated by `scope_use`\n\t * (fail-closed). Needs the `ui.slot.turn-card` permission.\n\t */\n\tregisterTurnCard(contribution: PluginTurnCardContribution): Disposable;\n\t/**\n\t * Register a keyboard shortcut scope on the host's shared ShortcutScopeStack\n\t * (same path as host UI: modal > overlay > surface > app). Needs\n\t * `ui.shortcuts.register`. Plugins cannot use kind `\"app\"` (reserved for\n\t * host-configurable global actions). Prefer {@link usePluginShortcutScope}\n\t * from React components with a module-captured `registerShortcutScope`.\n\t */\n\tregisterShortcutScope(contribution: PluginShortcutScopeContribution): Disposable;\n\t/**\n\t * Programmatically attach (if needed) and activate one of this plugin's\n\t * own activity tabs in a conversation's activity panel. `tabId`\n\t * is the contribution id passed to registerActivityTab. Any payload (e.g.\n\t * which image to edit) is passed via the plugin's own in-memory state.\n\t *\n\t * Pass `options.width` to size the panel as it opens — a pixel number, or\n\t * `\"max\"` to expand it to the widest the current window allows (the host\n\t * still clamps to its min/max and auto-hides the sidebar when needed). Omit\n\t * to leave the user's current width untouched.\n\t *\n\t * Omit `options.cwd` for the conversation currently displayed by the host.\n\t * Tool handlers and background work should pass their session cwd explicitly.\n\t */\n\topenActivityTab(tabId: string, options?: PluginOpenActivityTabOptions): void;\n\t/**\n\t * 把本插件的某个活动面板标签卡在目标会话里上栏 / 下栏,**不激活也不展开\n\t * 面板**——`openActivityTab` 是「用户此刻要看它」,这个是「它现在该不该在\n\t * 栏里」。配合 `initiallyVisible: false` 使用,插件即可完全掌握自己标签卡的\n\t * 出现条件(如 git 只在仓库目录里上栏、工作台跟随输入栏 toggle)。\n\t *\n\t * 上栏记录按会话 cwd 持久化(ADR-0026),所以只需在条件变化时调用一次;\n\t * 用户随后用减号手动隐藏的结果不会被重复调用覆盖。缺省作用于宿主当前显示的\n\t * 会话;工具 handler 与后台任务应通过 `options.cwd` 传入自己的会话 cwd。既没有\n\t * 显式 cwd、也没有活动会话时为 no-op(无处记录)。\n\t */\n\tsetActivityTabVisible(tabId: string, visible: boolean, options?: PluginActivityTabTargetOptions): void;\n\t/**\n\t * 直接设置活动面板宽度:像素值,或 `\"max\"` 表示「跟随窗口拉满」(宿主仍会夹到\n\t * 自己的 min/max 内,必要时自动收起侧边栏)。\n\t *\n\t * `\"max\"` 是一种持续状态而非一次性求值:窗口尺寸变化时面板跟着变宽变窄,直到\n\t * 用户拖动分隔条或有人写入具体像素为止。传数字则是一次性的固定宽度。\n\t *\n\t * 与 `openActivityTab(id, { width })` 的区别:那里的宽度只在标签卡首次 attach\n\t * 时生效(避免 activate 重放覆盖用户手拖的宽度);这个是命令式的,每次调用都\n\t * 生效,供插件在自己的标签卡被激活、进入某种视图时按需调整。用户随后仍可拖动。\n\t */\n\tsetActivityPanelWidth(width: number | \"max\"): void;\n\t/**\n\t * Bind or clear plugin-owned context for outgoing prompts. The host renders\n\t * its label/icon and carries a structured `context` as a versioned snapshot.\n\t * Attachments default to one-shot; `lifecycle: \"sticky\"` remains until the\n\t * plugin or user clears the capsule.\n\t */\n\tsetPromptAttachment(attachment: PluginPromptAttachment | null): void;\n\t/**\n\t * Open the host's global full-screen image previewer for the given image.\n\t * Only the image reference (id/url) crosses over — bytes stay out-of-band.\n\t *\n\t * Pass `group` (e.g. all images of the message) to open as an image group:\n\t * the previewer shows a thumbnail strip + arrows and starts at `ref`.\n\t */\n\tpreviewImage(ref: PluginImageRef, group?: PluginImageRef[]): void;\n\t/**\n\t * Open the host's global file previewer for any file — the general form of\n\t * {@link PluginUiApi.previewImage}, which only takes image URLs. Accepts a\n\t * local absolute `path` (the shape the host's own file tree uses) as well as\n\t * a `url`; the previewer dispatches by the file's extension, so a file type\n\t * some plugin registered via `registerFilePreview` lands in that renderer.\n\t *\n\t * Pass `group` (e.g. all outputs of one run) to open as a group: images get\n\t * the thumbnail strip + arrows, and the previewer starts at `file`.\n\t *\n\t * Permissions: `fs.read` as soon as any entry carries a `path` (it hands a\n\t * local file to the host to read); `ui.slot.message` for url-only calls,\n\t * same gate as `previewImage`.\n\t */\n\tpreviewFile(file: PluginPreviewFileRef, group?: PluginPreviewFileRef[]): void;\n\t/**\n\t * Capture a rectangle in the current Vetta window and open the host save\n\t * dialog. Coordinates use renderer DIP values such as getBoundingClientRect().\n\t * Requires `ui.slot.activity-tab`.\n\t */\n\tcaptureRegion(rect: PluginCaptureRegion, defaultFileName: string): Promise<string | null>;\n\t/**\n\t * Copy an image to the system clipboard. Takes a `data:image/...;base64,`\n\t * URL and goes through the native clipboard, so it does not depend on the\n\t * renderer's `ClipboardItem` support. No permission required — the plugin\n\t * can only write what it already rendered.\n\t */\n\tcopyImage(dataUrl: string): Promise<void>;\n\t/**\n\t * Hand a URL to the OS default browser (Electron `shell.openExternal`) —\n\t * NOT the in-app browser panel. Only `http:`/`https:` are accepted; the host\n\t * rejects every other protocol, so this cannot be used to launch arbitrary\n\t * schemes. Needs `shell.openExternal`.\n\t */\n\topenExternal(url: string): Promise<void>;\n\t/**\n\t * Show a global toast in the host UI (bottom-right). No permission required.\n\t * Prefer this over swallowing errors into opaque UI copy: pass `error` so\n\t * the host attaches a one-click \"copy stack\" action for the user.\n\t *\n\t * Capture `ctx.ui.notify` in `activate` if React components need it\n\t * (components do not receive `ctx`).\n\t */\n\tnotify(options: PluginNotifyOptions): void;\n\t/**\n\t * 读当前侧边栏形态。无需权限——这是纯布局信息,不含任何用户数据。\n\t *\n\t * React 组件请改用 `useSidebarState()`:它会在状态变化时重渲染,不必自己订阅。\n\t * 这一对只为拿不到 hook 的地方准备(`activate()` 内、工具处理器、命令式绘制的画布)。\n\t */\n\tgetSidebarState(): PluginSidebarState;\n\t/**\n\t * 订阅侧边栏形态变化——用户收起/展开侧边栏、或窗口跨过窄屏阈值时触发。\n\t * 返回 Disposable 取消订阅;请在插件失活时释放。\n\t *\n\t * 回调按值去重:拖窗口不会把它打成回调风暴,只有三元组真的变了才通知。\n\t */\n\tonSidebarStateChanged(listener: (state: PluginSidebarState) => void): Disposable;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType, ReactNode } from \"react\";\nimport type { ConversationMessage } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginImageRef } from \"./images.js\";\nimport type { PluginPromptAttachment } from \"./prompt-attachment.js\";\nimport type { ConversationScenario } from \"./scenario.js\";\nimport type { PluginShortcutScopeContribution } from \"./shortcuts.js\";\n\nexport interface PluginGlobalSlotContribution {\n\tid: string;\n\tcomponent: ComponentType;\n}\n\nexport interface PluginAbilityDetailSlotProps {\n\tabilityId: string;\n\tinstalled: boolean;\n\tenabled: boolean;\n}\n\n/** Inline setup/status surface rendered near the top of one ability detail page. */\nexport interface PluginAbilityDetailSlotContribution {\n\tid: string;\n\tabilityId: string;\n\tcomponent: ComponentType<PluginAbilityDetailSlotProps>;\n}\n\n/**\n * Props handed to a workspace-view component. A workspace view owns the whole\n * content area, so unlike panel slots it is addressed by its own route and can\n * be deep-linked; the host passes back its identity so one component can serve\n * several registered views.\n */\nexport interface PluginWorkspaceViewProps {\n\t/** The contribution id as registered (NOT namespaced). */\n\tviewId: string;\n\t/** The owning plugin id. */\n\tpluginId: string;\n}\n\n/**\n * Badge tone. The host maps it to its own theme colors — a plugin cannot pick a\n * raw color, so badges stay consistent with the built-in navigation entries.\n */\nexport type PluginNavBadgeTone = \"accent\" | \"danger\" | \"default\" | \"warning\";\n\n/**\n * A badge on the plugin's sidebar navigation entry.\n *\n * `beta` is the host's own preset — it renders exactly like the built-in\n * 知识库 Beta 标识, wording included (and localized by the host), so plugins do\n * not have to spell \"Beta\" themselves in every locale.\n *\n * `count` renders `99+` past 99 and disappears at 0 — an unread badge showing\n * \"0\" is worse than no badge.\n */\nexport type PluginNavBadge =\n\t| { kind: \"beta\" }\n\t| { kind: \"text\"; text: string; tone?: PluginNavBadgeTone }\n\t| { kind: \"count\"; count: number; tone?: PluginNavBadgeTone }\n\t| { kind: \"dot\"; tone?: PluginNavBadgeTone };\n\n/**\n * A **workspace view**(工作区视图): a full-page surface a plugin contributes to\n * the host's primary navigation. It is the plugin counterpart of a built-in page\n * such as 自动化 / 知识库 — the host gives it its own route\n * (`/workspace/<pluginId>/<viewId>`) and a sidebar entry, and the plugin owns the\n * entire content area while it is open.\n *\n * Use it for standalone workbenches that are NOT bound to one conversation\n * (dashboards, boards, consoles). Conversation-scoped UI belongs in an\n * {@link PluginActivityTabContribution activity tab}; floating UI belongs in a\n * {@link PluginGlobalSlotContribution global slot}.\n */\nexport interface PluginWorkspaceViewContribution {\n\t/** Unique within the plugin; the host namespaces it as `${pluginId}:${id}`. */\n\tid: string;\n\t/** Sidebar entry label. Supports `%catalogKey%` i18n lookup. */\n\tlabel: string;\n\t/**\n\t * Sidebar entry icon as an **iconify class string** (e.g.\n\t * `\"icon-[solar--widget-5-linear]\"`) — NOT a React node, because the host\n\t * renders it inside its own nav button and persists nav layout by key.\n\t *\n\t * Omit it to inherit the plugin's own `plugin.json` icon: a packaged image\n\t * (svg / png / webp …) is masked with the theme's foreground color, so a plugin\n\t * that ships artwork does not have to find a lookalike in an icon set. Set\n\t * {@link PluginWorkspaceViewContribution.iconTint} to `false` to keep its colors.\n\t */\n\ticon?: string;\n\t/**\n\t * Whether an image icon is tinted with the theme's foreground color. Defaults to\n\t * `true`, which keeps the entry consistent with the built-in navigation and legible\n\t * in every theme.\n\t *\n\t * Pass `false` for a full-color logo. Weigh it first: the entry renders at 16px\n\t * beside monochrome built-ins, and a fixed-color image cannot follow the active\n\t * theme — a dark logo can disappear on a dark sidebar. Has no effect on Iconify\n\t * class icons, which are always tinted.\n\t */\n\ticonTint?: boolean;\n\t/** Optional one-line description; shown as the nav entry tooltip. */\n\tdescription?: string;\n\t/**\n\t * Initial badge on the sidebar entry. `{ kind: \"text\" }` supports the same\n\t * `%catalogKey%` i18n lookup as {@link label}. Update it at runtime with\n\t * {@link PluginUiApi.setWorkspaceViewBadge}.\n\t */\n\tbadge?: PluginNavBadge;\n\t/** Zero-props aside from {@link PluginWorkspaceViewProps}. */\n\tcomponent: ComponentType<PluginWorkspaceViewProps>;\n\t/** Sort hint among this plugin's own views (ascending). Defaults to 0. */\n\tnavOrder?: number;\n\t/**\n\t * Whether this view takes a sidebar entry. Defaults to `true`.\n\t *\n\t * Pass `false` for a surface users open occasionally — a setup page, a\n\t * diagnostics console. It then lives only under Settings → More options,\n\t * where the host lists every off-sidebar view and opens it inside the\n\t * settings shell, so switching between such pages stays one click.\n\t *\n\t * The sidebar is a scarce, user-curated space: a plugin that always claims a\n\t * slot pushes the entries someone actually uses into the overflow menu.\n\t */\n\tsidebar?: boolean;\n}\n\n/**\n * What a workspace view puts into the **host page header** — the window's top\n * bar that also carries the drag region, the macOS traffic-light gutter and the\n * sidebar trigger.\n *\n * Without this the header still renders, showing the app name above the\n * plugin's own toolbar — two stacked bars. Set `hideTitle` and move the view's\n * toolbar in here and the surface gets a single, host-consistent header.\n *\n * `left` / `right` are ReactNodes rendered by the host inside that bar (left:\n * right after the sidebar trigger; right: before the window controls). They are\n * rendered in the plugin's i18n + CSS scope, so `useTranslation()` and the\n * plugin's own classes work as usual. Pass fresh nodes whenever the view's\n * state changes — this is a live setter, not a one-time registration.\n */\nexport interface PluginWorkspaceViewHeader {\n\t/** Replaces the host title text. Supports `%catalogKey%` i18n lookup. */\n\ttitle?: string;\n\t/** Drop the host title entirely (use when {@link left} carries its own). */\n\thideTitle?: boolean;\n\t/** Rendered in the header's left cluster, after the sidebar trigger. */\n\tleft?: ReactNode;\n\t/** Rendered in the header's action cluster, before the window controls. */\n\tright?: ReactNode;\n\t/**\n\t * Float the host header OVER the view instead of stacking above it. The view\n\t * then owns the full content height, and its top `~44px` sit under the\n\t * transparent header strip (window drag region / traffic lights / sidebar\n\t * trigger all keep working on top). Use for immersive full-page surfaces\n\t * whose own hero starts at the very top; leave unset for toolbar-style\n\t * headers that need their own opaque row.\n\t */\n\timmersive?: boolean;\n}\n\nexport interface PluginAudioMetadata {\n\t/** Embedded title; preview renderers should fall back to file.name. */\n\ttitle?: string;\n\tartist?: string;\n\t/** Embedded cover art as a Data URL when available. */\n\tcoverDataUrl?: string;\n}\n\nexport interface PluginPreviewUrlOptions {\n\t/** Optional media hint for ambiguous containers such as webm. */\n\tmediaKind?: \"audio\" | \"video\";\n}\n\n/**\n * The file handed to a file-preview plugin component. The host does NOT\n * pre-read or guess encoding — the plugin decides whether to read text or\n * bytes. `path` is also exposed for plugins that prefer native fetch.\n */\nexport interface PluginPreviewFile {\n\tpath: string | null;\n\tname: string;\n\textension: string;\n\tmime: string;\n\tsize: number;\n\t/** Read the file as a UTF-8 string. */\n\treadText(): Promise<string>;\n\t/** Read the raw file bytes. */\n\treadBytes(): Promise<ArrayBuffer>;\n\t/** A fetchable streaming URL for the file (Range-capable). */\n\tgetUrl(options?: PluginPreviewUrlOptions): string;\n\t/**\n\t * Subscribe to on-disk changes of this file. The listener fires (debounced\n\t * by the host) whenever the file's contents change, letting previews update\n\t * live. Returns a Disposable; call dispose() to stop watching. A no-op for\n\t * files without a real path (url-only sources).\n\t */\n\twatch(listener: () => void): Disposable;\n\t/**\n\t * Host-provided audio metadata for local media files. Returns null when the\n\t * host cannot provide metadata, e.g. url-only sources or unsupported files.\n\t */\n\tgetAudioMetadata?(): Promise<PluginAudioMetadata | null>;\n}\n\nexport interface PluginFilePreviewProps {\n\tfile: PluginPreviewFile;\n}\n\n/**\n * A file handed to {@link PluginUiApi.previewFile} — the *opening* side of the\n * global previewer, the mirror image of {@link PluginPreviewFile} (which is the\n * *rendering* side). Bytes never cross over: the host reads the source itself.\n *\n * Exactly one of `path` (local absolute path) or `url` (host media / http URL)\n * must be given. `path` is the shape the host's own file tree uses, so the\n * previewer also offers \"在 Finder 中显示\" for it.\n */\nexport interface PluginPreviewFileRef {\n\t/** Local absolute path. Requires the `fs.read` permission. */\n\tpath?: string;\n\t/** Fetchable URL (host media URL or http/https). Requires `ui.slot.message`. */\n\turl?: string;\n\t/**\n\t * Display name **including the extension** — the previewer dispatches to a\n\t * renderer by this extension, not by `mimeType`. Optional for `path`\n\t * sources (the host falls back to the path's basename).\n\t */\n\tname?: string;\n\tmimeType?: string;\n\t/** Byte size, shown in the previewer's download detail when known. */\n\tsize?: number;\n}\n\nexport interface PluginFilePreviewContribution {\n\t/** Lower-case extensions without the dot, e.g. [\"svg\"]. */\n\textensions: string[];\n\tcomponent: ComponentType<PluginFilePreviewProps>;\n}\n\n/**\n * An activity-panel tab contributed by a plugin. Registering only adds the\n * tab to the \"addable pool\" — it renders only after the user attaches it in\n * the activity panel (scoped by session cwd).\n */\n/** Host residency policy for an activity-panel tab. */\nexport type PluginActivityTabRetention = \"active-only\" | \"warm\" | \"pinned\";\n\nexport interface PluginActivityTabContribution {\n\t/**\n\t * 标签栏上的默认相对位置,越小越靠前;缺省 100(排在全部内置标签卡之后)。\n\t *\n\t * 内置的取值可作标尺:文件 0、批量 10、浏览器 15、计划 18、待办 20、后台任务 30。\n\t * 下限被宿主钳到 10,「文件」永远是第一枚;用户拖拽出来的顺序优先于这个值。\n\t */\n\torder?: number;\n\tid: string;\n\tlabel: string;\n\t/**\n\t * Tab icon as a React node (not an iconify class string).\n\t * Omit to inherit the host-resolved brand icon from `plugin.json#icon`\n\t * (`ctx.plugin.iconUrl`). Prefer omitting for package brand icons so the\n\t * plugin never loads assets via absolute `/…` paths or host protocols.\n\t */\n\ticon?: ReactNode;\n\tcomponent: ComponentType;\n\t/**\n\t * 允许该标签卡出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如\n\t * `[\"project\", \"conversation\"]`)。会话页插槽据此随对话类型显隐。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/**\n\t * 注册后是否默认在标签栏里(缺省 `true`)。声明 `false` 表示「出现条件由我\n\t * 自己决定」——注册只是入池,之后由 {@link PluginUiApi.setActivityTabVisible}\n\t * 或 {@link PluginUiApi.openActivityTab} 决定何时上栏(如 git 只在仓库目录、\n\t * 工作台跟随输入栏 toggle)。无论哪种,用户仍可用减号手动隐藏。\n\t */\n\tinitiallyVisible?: boolean;\n\t/**\n\t * Component residency while the tab is inactive. Defaults to `\"warm\"`:\n\t * visited tabs stay mounted in the host's bounded LRU cache. Use\n\t * `\"active-only\"` for cheap, stateless content and `\"pinned\"` for runtimes\n\t * that must never be evicted while available.\n\t */\n\tretention?: PluginActivityTabRetention;\n\t/**\n\t * @deprecated Use {@link PluginActivityTabContribution.retention}. `true`\n\t * maps to `\"pinned\"`; `false` maps to `\"active-only\"`.\n\t */\n\tkeepAliveWhenAvailable?: boolean;\n}\n\n/** Explicit conversation scope for an activity-tab command. */\nexport interface PluginActivityTabTargetOptions {\n\t/**\n\t * Absolute cwd whose activity-tab state should be changed. Omit to target\n\t * the conversation currently displayed by the host. Tool handlers and\n\t * background work should pass the triggering session's cwd so a foreground\n\t * navigation change cannot redirect the command to another conversation.\n\t */\n\tcwd?: string;\n}\n\n/** Options for {@link PluginUiApi.openActivityTab}. */\nexport interface PluginOpenActivityTabOptions extends PluginActivityTabTargetOptions {\n\t/**\n\t * Desired panel width as it opens: a pixel number, or `\"max\"` to track the\n\t * widest the window allows — `\"max\"` keeps following window resizes until the\n\t * user drags the divider. The host clamps to its min/max bounds. Omit to keep\n\t * the user's current width.\n\t */\n\twidth?: number | \"max\";\n}\n\nexport interface PluginCaptureRegion {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Decoration a plugin contributes to the next outgoing prompt while its input\n * action is active. `metadata` is shallow-merged into the prompt request and\n * `instructions` are appended as hidden, model-visible guidance.\n */\nexport interface PluginPromptDecoration {\n\tmetadata?: Record<string, unknown>;\n\t/** Hidden plugin-owned instructions appended to the next agent turn. */\n\tinstructions?: string[];\n}\n\n/**\n * An action button shown in a row beneath the AI input bar. Rendered as a\n * toggle: clicking activates, clicking again deactivates. While active, the\n * host calls `decoratePrompt()` before each send and merges the returned\n * metadata into the outgoing prompt request. The plugin owns any side state\n * (it is the same Module Federation instance as its other slots).\n */\nexport interface PluginInputActionContribution {\n\tid: string;\n\tlabel: string;\n\t/** Button icon as a React node (not an iconify class string). */\n\ticon?: ReactNode;\n\t/** Whether the action begins in the active state. Defaults to false. */\n\tdefaultActive?: boolean;\n\t/**\n\t * 该输入动作所依赖的 agent 工具名。设置后,仅当该工具在当前会话处于激活(按工具的\n\t * scope_use 解析)时才显示这个 badge——避免在工具被场景屏蔽(如批量任务)时仍显示一个\n\t * 点了也无效的开关。不设则始终显示。例如「图像生成」设为 \"generate_image\"。\n\t */\n\trequiresActiveTool?: string;\n\t/**\n\t * 允许该 toggle 出现的对话场景 slug 列表(镜像工具的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现。与 `requiresActiveTool`\n\t * 取「与」:两者都满足才显示。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/**\n\t * When true, this plugin's agent contributions (tools / skills / MCP /\n\t * systemPrompt) and Activity Tabs are hard-isolated: inactive until this\n\t * toggle is on (ADR-0041, knowledgeMode-style). Default false.\n\t */\n\thardIsolation?: boolean;\n\t/**\n\t * Fired when the user toggles the action; `active` is the new state. Return\n\t * `false` when `active` is true to VETO the activation (e.g. the plugin needs\n\t * configuration first) — the toggle stays off. Deactivation can't be vetoed.\n\t */\n\tonToggle?(active: boolean): boolean | void;\n\t/**\n\t * Called by the host before sending while the action is active. The\n\t * returned metadata is merged into the outgoing prompt request.\n\t */\n\tdecoratePrompt?(): PluginPromptDecoration | void;\n}\n\n/**\n * A declarative, serializable descriptor for one card rendered beneath a\n * message. `type` selects a registered card renderer; `key` drives cross-turn\n * dedup (same key across turns = one logical card, shown only under its latest\n * anchor); `payload` carries STABLE REFERENCES (e.g. image ids), not a content\n * snapshot — the renderer resolves live state from it. `title`/`icon` label the\n * card's tab (override the renderer's registration defaults). Rides a tool\n * result's out-of-band `details.cards`; crosses the agent→host boundary, so\n * `icon` is an icon-symbol string, not a node.\n */\nexport interface CardDescriptor {\n\ttype: string;\n\tkey?: string;\n\tpayload?: unknown;\n\ttitle?: string;\n\ticon?: string;\n}\n\n/** A pending (in-flight) tool call handed to a renderer's `pendingFor`. */\nexport interface PluginPendingToolCall {\n\ttoolName: string;\n\targs: Record<string, unknown>;\n}\n\n/**\n * Props for a card renderer. `descriptor` is the card's data; `pending` is true\n * while it was synthesized from an in-flight tool (render a skeleton); `message`\n * is the anchoring conversation message.\n */\nexport interface PluginCardProps {\n\tdescriptor: CardDescriptor;\n\tpending: boolean;\n\tmessage: ConversationMessage;\n}\n\n/**\n * A card renderer registered by a plugin, keyed by `type`. A descriptor whose\n * `type` matches is rendered by `component`. `title`/`icon` are the default tab\n * label/icon (a descriptor may override `title`). `pendingFor`, given an\n * in-flight tool call, returns a provisional descriptor so a skeleton card\n * appears (and claims a tab) before the tool's result lands — or null when this\n * renderer doesn't handle that tool. The `type` must be globally unique across\n * plugins (convention: prefix with the plugin id, e.g. \"image-gen:preview\").\n */\nexport interface PluginCardRendererContribution {\n\ttype: string;\n\tcomponent: ComponentType<PluginCardProps>;\n\ttitle?: string;\n\t/** Default tab icon as a React node (not an iconify class string). */\n\ticon?: ReactNode;\n\tpendingFor?: (toolCall: PluginPendingToolCall) => CardDescriptor | null;\n}\n\n/** A tool call handed to a tool-call slot renderer. */\nexport interface PluginToolCallSlotToolCall {\n\ttoolCallId: string;\n\ttoolName: string;\n\targs: Record<string, unknown>;\n\tstatus: \"pending\" | \"success\" | \"error\" | \"cancelled\";\n\tresult?: string;\n\tisError?: boolean;\n}\n\nexport interface PluginToolCallSlotProps {\n\ttoolCall: PluginToolCallSlotToolCall;\n}\n\n/**\n * A component that **replaces the host's default inline transcript rendering**\n * for a specific tool (matched by `toolName`; first registered renderer wins).\n * This is how a plugin renders rich UI for its OWN agent tool's output — plugin\n * tools cannot emit `details.cards`, so the message card system (registerCardRenderer)\n * does not serve them; the tool-call slot does.\n */\nexport interface PluginToolCallSlotContribution {\n\tid: string;\n\ttoolName: string;\n\tcomponent: ComponentType<PluginToolCallSlotProps>;\n}\n\n/**\n * A card rendered at the bottom of the message list for the LATEST turn — NOT\n * bound to a tool call. The host mounts `component` in the footer slot and\n * re-mounts it each session/turn; the plugin owns visibility entirely (it reads\n * live state via SDK hooks — `useActiveConversation`, `useConversationMessages`,\n * `ctx.conversation.on(\"turn-end\")` — and returns `null` to render nothing,\n * e.g. git renders only inside a repo that has changes). `scope_use` gates which\n * conversation scenarios it may appear in (**fail-closed**, mirrors the other\n * slots). `id` must be unique within the plugin.\n */\nexport interface PluginTurnCardContribution {\n\tid: string;\n\tcomponent: ComponentType;\n\t/**\n\t * 允许该 turn 卡出现的对话场景 slug 列表(镜像其它插槽的 scope_use)。**fail-closed**:\n\t * 未声明/空数组 = 任何会话都不显示;声明后仅在列出的场景里出现(如 `[\"project\"]`)。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n}\n\n/**\n * Options for {@link PluginUiApi.notify}. Surfaces a host toast so users can\n * see plugin failures without opening DevTools.\n */\nexport interface PluginNotifyOptions {\n\t/** Toast body. Required even when `error` is set (user-facing summary). */\n\tmessage: string;\n\t/** Defaults to plugin display name when omitted. */\n\ttitle?: string;\n\t/** Defaults to `\"info\"`; when `error` is set and variant omitted, host uses `\"error\"`. */\n\tvariant?: \"info\" | \"success\" | \"warning\" | \"error\";\n\t/**\n\t * Optional failure cause. Host formats message + stack and adds a\n\t * \"复制堆栈\" action so the user can paste it into bug reports / chat.\n\t */\n\terror?: unknown;\n\t/**\n\t * Auto-dismiss delay in ms. `0` keeps the toast until dismissed.\n\t * Defaults: sticky (`0`) when `error` is present, otherwise host default (~4s).\n\t */\n\tdurationMs?: number;\n}\n\n/**\n * 新会话上下文区的激活条件。**只能写本插件自己的东西**——填别人的 id 一律不生效。\n *\n * 这条限制是故意的:否则插件 A 可以声明「只要用户选了 B 的智能体我就上屏」,把别人的\n * 使用场景劫持过来。\n *\n * 各字段取并集:任意一条命中即激活。至少要声明一条——全空等于「任何新会话都上屏」,宿主拒掉。\n */\nexport interface PluginNewSessionContextActivation {\n\t/** 本插件在 manifest 里声明的智能体 id(不带 `plugin:` 前缀)。 */\n\tagents?: readonly string[];\n\t/** 本插件在 manifest 里声明的团队 id。省略则任意「含本插件成员的团队」都算命中。 */\n\tteams?: readonly string[];\n\t/** 本插件提供的 skill 名;用户在输入框里提到时命中。 */\n\tskills?: readonly string[];\n\t/** 本插件提供的 MCP server 名。 */\n\tmcpServers?: readonly string[];\n}\n\n/** 用户在新会话页当前选中的对话目标。 */\nexport interface PluginNewSessionTarget {\n\treadonly kind: \"agent\" | \"team\";\n\t/** Agent 档案 id 或团队 id。 */\n\treadonly id: string;\n\t/** 目标若由本插件贡献,这里给出 manifest 里的那个 id。 */\n\treadonly contributedId?: string;\n}\n\n/**\n * 渲染上下文。这是一个**会继续生长的对象**:后续新增字段不会破坏既有插件,所以按需\n * 解构、不要假定它只有这些键。\n */\nexport interface PluginNewSessionContext {\n\treadonly target: PluginNewSessionTarget | null;\n\t/** 输入框里提到的、属于本插件的能力。 */\n\treadonly mentionedAbilities: {\n\t\treadonly skills: readonly string[];\n\t\treadonly mcpServers: readonly string[];\n\t};\n\t/**\n\t * 输入框中尚未发送的文本。需要 `conversation.draft.read` 权限,未授予时恒为空串。\n\t *\n\t * 只在本贡献处于激活状态时提供——插件拿不到「用户随便打点什么」的全程流水。\n\t */\n\treadonly draft: string;\n\t/** 当前工作区目录;未选择项目时为 null。 */\n\treadonly cwd: string | null;\n\t/** 回写输入栏。刻意不提供「直接发送」:越过发送前这道关不属于本区职责。 */\n\treadonly composer: {\n\t\t/** 把资源挂成附件,随下一次发送带走。 */\n\t\tattach(attachment: PluginPromptAttachment): void;\n\t\t/**\n\t\t * 往草稿里插一段文本。始终是插入而非替换,免得抹掉用户已经打的内容。\n\t\t *\n\t\t * `position` 缺省为 `\"end\"`(光标处)。`\"start\"` 插到最前面,适合「先定题、细节\n\t\t * 由用户补」这类写法——用户点完多半光标并不在开头,位置只能由调用方定死。\n\t\t */\n\t\tinsertText(text: string, options?: { position?: \"start\" | \"end\" }): void;\n\t};\n}\n\n/**\n * 新会话页输入框下方的一块内容(`ui.slot.new-session-context`)。\n *\n * 与 input-action 的分工:那是发送前的开关,这是发送前的**上下文**——把用户接下来多半\n * 要用到的素材摆出来。激活与否由宿主按 {@link PluginNewSessionContextActivation} 裁决,\n * 插件只负责在被激活后渲染,因此拿不到用户逐键输入的全程内容。\n *\n * 同时有多个贡献上屏时,宿主会在该区域顶部出 tabbar;只有一个时直接渲染内容。\n */\nexport interface PluginNewSessionContextContribution {\n\tid: string;\n\t/** tabbar 上的标题;只有一个贡献上屏时不展示。 */\n\tlabel: string;\n\t/** tab 图标;省略时用插件自己的图标。 */\n\ticon?: ReactNode;\n\tactivateWhen: PluginNewSessionContextActivation;\n\t/**\n\t * 横向占位。`\"input\"`(默认)与输入框同宽,适合补充说明一类的窄内容;`\"wide\"` 铺满\n\t * 页面可用宽度,留给画廊、素材墙这类「内容本身就是主角」的东西——把它们压在输入框\n\t * 宽度里,每一项都会小到看不清。\n\t */\n\twidth?: \"input\" | \"wide\";\n\trender(context: PluginNewSessionContext): ReactNode;\n}\n\n/**\n * 宿主左侧侧边栏此刻的形态。给插件自适应布局用——尤其是沉浸式工作区视图:\n * 侧边栏收起时宿主页头会长出「展开侧边栏」按钮并占住左上角,视图自己画在那一带的\n * 东西需要让位。\n */\nexport interface PluginSidebarState {\n\t/** 用户手动收起了侧边栏。窄屏下这一位仍然只反映用户意愿,不受窗口宽度影响。 */\n\tcollapsed: boolean;\n\t/** 窗口窄到侧边栏改走悬浮覆盖,不再占据左侧一栏。 */\n\tnarrow: boolean;\n\t/** 侧边栏此刻是否实际占着左边那一栏。等价于 `!collapsed && !narrow`,多数自适应只需要这一位。 */\n\tvisible: boolean;\n}\n\nexport interface PluginUiApi {\n\tregisterGlobalSlot(contribution: PluginGlobalSlotContribution): Disposable;\n\tregisterAbilityDetailSlot(contribution: PluginAbilityDetailSlotContribution): Disposable;\n\t/** Render an opaque setup URL as a host-themed PNG data URL. */\n\tcreateQrCode(text: string): Promise<string>;\n\t/**\n\t * Register a **workspace view**(工作区视图)— a full-page surface with its own\n\t * route and sidebar entry, on par with the host's built-in pages. Needs the\n\t * `ui.slot.workspace-view` permission (missing permission = **warn+noop**).\n\t *\n\t * The entry lands in the sidebar's「更多」收纳 by default; the user can pin it\n\t * to the top region or reorder it, and that layout is remembered.\n\t */\n\tregisterWorkspaceView(contribution: PluginWorkspaceViewContribution): Disposable;\n\t/**\n\t * Register a **new-session context block** — content shown beneath the input\n\t * on the new-session page, surfaced only when the user's current selection or\n\t * draft matches {@link PluginNewSessionContextActivation}. Needs the\n\t * `ui.slot.new-session-context` permission (missing permission = **warn+noop**).\n\t */\n\tregisterNewSessionContext(contribution: PluginNewSessionContextContribution): Disposable;\n\t/**\n\t * Navigate to one of this plugin's own workspace views. `viewId` is the\n\t * contribution id passed to {@link PluginUiApi.registerWorkspaceView}. No-op\n\t * when the view is not registered (e.g. permission missing).\n\t */\n\topenWorkspaceView(viewId: string): void;\n\t/**\n\t * Update (or clear, with `null`) the badge on one of this plugin's workspace\n\t * view entries. Re-registering the view is NOT a way to do this — it would\n\t * remount the whole surface — so live badges (unread counts, status dots)\n\t * must come through here.\n\t *\n\t * No-op when the view is not registered (e.g. permission missing).\n\t */\n\tsetWorkspaceViewBadge(viewId: string, badge: PluginNavBadge | null): void;\n\t/**\n\t * Fill (or clear, with `null`) the host page header while one of this\n\t * plugin's workspace views is open. Call it from the view component (an\n\t * effect that re-runs on state change) and clear it on unmount — the host\n\t * keeps the entry keyed by view, and only applies it on that view's route.\n\t *\n\t * The header itself is never removed: it owns the window drag region and the\n\t * macOS traffic-light gutter. This is how a view takes it over instead.\n\t *\n\t * No-op when the view is not registered (e.g. permission missing).\n\t */\n\tsetWorkspaceViewHeader(viewId: string, header: PluginWorkspaceViewHeader | null): void;\n\t/**\n\t * Register a preview component keyed by file extension. The host dispatches\n\t * registered extensions before its built-in fallback renderers; first\n\t * registrant wins on conflict.\n\t */\n\tregisterFilePreview(contribution: PluginFilePreviewContribution): Disposable;\n\t/**\n\t * Register an activity-panel tab into the addable pool. The user attaches\n\t * it manually via the panel's \"+\" picker; attach records are keyed by the\n\t * session cwd.\n\t */\n\tregisterActivityTab(contribution: PluginActivityTabContribution): Disposable;\n\t/**\n\t * Register a toggle action shown beneath the AI input bar. While active,\n\t * its `decoratePrompt()` annotates the next outgoing prompt.\n\t */\n\tregisterInputAction(contribution: PluginInputActionContribution): Disposable;\n\t/**\n\t * Register a card renderer keyed by `type`. Cards rendered beneath a message\n\t * come from tool results' out-of-band `details.cards` (or `pendingFor` for\n\t * in-flight tools); the host resolves each card's `type` to a registered\n\t * renderer. Multiple cards under one message are shown as a tab-switcher\n\t * (\"收纳\") or a flat list.\n\t */\n\tregisterCardRenderer(contribution: PluginCardRendererContribution): Disposable;\n\t/**\n\t * Register a renderer that replaces the host's default inline transcript UI\n\t * for a tool call (matched by `toolName`). The complement to card renderers:\n\t * use it to render UI for a plugin's own agent tool output.\n\t */\n\tregisterToolCallSlot(contribution: PluginToolCallSlotContribution): Disposable;\n\t/**\n\t * Register a card rendered at the bottom of the message list for the latest\n\t * turn — NOT bound to a tool call. The host mounts the component in the\n\t * footer slot; the plugin owns visibility (return `null` to render nothing,\n\t * e.g. git renders only in a repo with changes). Gated by `scope_use`\n\t * (fail-closed). Needs the `ui.slot.turn-card` permission.\n\t */\n\tregisterTurnCard(contribution: PluginTurnCardContribution): Disposable;\n\t/**\n\t * Register a keyboard shortcut scope on the host's shared ShortcutScopeStack\n\t * (same path as host UI: modal > overlay > surface > app). Needs\n\t * `ui.shortcuts.register`. Plugins cannot use kind `\"app\"` (reserved for\n\t * host-configurable global actions). Prefer {@link usePluginShortcutScope}\n\t * from React components with a module-captured `registerShortcutScope`.\n\t */\n\tregisterShortcutScope(contribution: PluginShortcutScopeContribution): Disposable;\n\t/**\n\t * Programmatically attach (if needed) and activate one of this plugin's\n\t * own activity tabs in a conversation's activity panel. `tabId`\n\t * is the contribution id passed to registerActivityTab. Any payload (e.g.\n\t * which image to edit) is passed via the plugin's own in-memory state.\n\t *\n\t * Pass `options.width` to size the panel as it opens — a pixel number, or\n\t * `\"max\"` to expand it to the widest the current window allows (the host\n\t * still clamps to its min/max and auto-hides the sidebar when needed). Omit\n\t * to leave the user's current width untouched.\n\t *\n\t * Omit `options.cwd` for the conversation currently displayed by the host.\n\t * Tool handlers and background work should pass their session cwd explicitly.\n\t */\n\topenActivityTab(tabId: string, options?: PluginOpenActivityTabOptions): void;\n\t/**\n\t * 把本插件的某个活动面板标签卡在目标会话里上栏 / 下栏,**不激活也不展开\n\t * 面板**——`openActivityTab` 是「用户此刻要看它」,这个是「它现在该不该在\n\t * 栏里」。配合 `initiallyVisible: false` 使用,插件即可完全掌握自己标签卡的\n\t * 出现条件(如 git 只在仓库目录里上栏、工作台跟随输入栏 toggle)。\n\t *\n\t * 上栏记录按会话 cwd 持久化(ADR-0026),所以只需在条件变化时调用一次;\n\t * 用户随后用减号手动隐藏的结果不会被重复调用覆盖。缺省作用于宿主当前显示的\n\t * 会话;工具 handler 与后台任务应通过 `options.cwd` 传入自己的会话 cwd。既没有\n\t * 显式 cwd、也没有活动会话时为 no-op(无处记录)。\n\t */\n\tsetActivityTabVisible(tabId: string, visible: boolean, options?: PluginActivityTabTargetOptions): void;\n\t/**\n\t * 直接设置活动面板宽度:像素值,或 `\"max\"` 表示「跟随窗口拉满」(宿主仍会夹到\n\t * 自己的 min/max 内,必要时自动收起侧边栏)。\n\t *\n\t * `\"max\"` 是一种持续状态而非一次性求值:窗口尺寸变化时面板跟着变宽变窄,直到\n\t * 用户拖动分隔条或有人写入具体像素为止。传数字则是一次性的固定宽度。\n\t *\n\t * 与 `openActivityTab(id, { width })` 的区别:那里的宽度只在标签卡首次 attach\n\t * 时生效(避免 activate 重放覆盖用户手拖的宽度);这个是命令式的,每次调用都\n\t * 生效,供插件在自己的标签卡被激活、进入某种视图时按需调整。用户随后仍可拖动。\n\t */\n\tsetActivityPanelWidth(width: number | \"max\"): void;\n\t/**\n\t * Bind or clear plugin-owned context for outgoing prompts. The host renders\n\t * its label/icon and carries a structured `context` as a versioned snapshot.\n\t * Attachments default to one-shot; `lifecycle: \"sticky\"` remains until the\n\t * plugin or user clears the capsule.\n\t */\n\tsetPromptAttachment(attachment: PluginPromptAttachment | null): void;\n\t/**\n\t * Open the host's global full-screen image previewer for the given image.\n\t * Only the image reference (id/url) crosses over — bytes stay out-of-band.\n\t *\n\t * Pass `group` (e.g. all images of the message) to open as an image group:\n\t * the previewer shows a thumbnail strip + arrows and starts at `ref`.\n\t */\n\tpreviewImage(ref: PluginImageRef, group?: PluginImageRef[]): void;\n\t/**\n\t * Open the host's global file previewer for any file — the general form of\n\t * {@link PluginUiApi.previewImage}, which only takes image URLs. Accepts a\n\t * local absolute `path` (the shape the host's own file tree uses) as well as\n\t * a `url`; the previewer dispatches by the file's extension, so a file type\n\t * some plugin registered via `registerFilePreview` lands in that renderer.\n\t *\n\t * Pass `group` (e.g. all outputs of one run) to open as a group: images get\n\t * the thumbnail strip + arrows, and the previewer starts at `file`.\n\t *\n\t * Permissions: `fs.read` as soon as any entry carries a `path` (it hands a\n\t * local file to the host to read); `ui.slot.message` for url-only calls,\n\t * same gate as `previewImage`.\n\t */\n\tpreviewFile(file: PluginPreviewFileRef, group?: PluginPreviewFileRef[]): void;\n\t/**\n\t * Capture a rectangle in the current Vetta window and open the host save\n\t * dialog. Coordinates use renderer DIP values such as getBoundingClientRect().\n\t * Requires `ui.slot.activity-tab`.\n\t */\n\tcaptureRegion(rect: PluginCaptureRegion, defaultFileName: string): Promise<string | null>;\n\t/**\n\t * Copy an image to the system clipboard. Takes a `data:image/...;base64,`\n\t * URL and goes through the native clipboard, so it does not depend on the\n\t * renderer's `ClipboardItem` support. No permission required — the plugin\n\t * can only write what it already rendered.\n\t */\n\tcopyImage(dataUrl: string): Promise<void>;\n\t/**\n\t * Hand a URL to the OS default browser (Electron `shell.openExternal`) —\n\t * NOT the in-app browser panel. Only `http:`/`https:` are accepted; the host\n\t * rejects every other protocol, so this cannot be used to launch arbitrary\n\t * schemes. Needs `shell.openExternal`.\n\t */\n\topenExternal(url: string): Promise<void>;\n\t/**\n\t * Show a global toast in the host UI (bottom-right). No permission required.\n\t * Prefer this over swallowing errors into opaque UI copy: pass `error` so\n\t * the host attaches a one-click \"copy stack\" action for the user.\n\t *\n\t * Capture `ctx.ui.notify` in `activate` if React components need it\n\t * (components do not receive `ctx`).\n\t */\n\tnotify(options: PluginNotifyOptions): void;\n\t/**\n\t * 读当前侧边栏形态。无需权限——这是纯布局信息,不含任何用户数据。\n\t *\n\t * React 组件请改用 `useSidebarState()`:它会在状态变化时重渲染,不必自己订阅。\n\t * 这一对只为拿不到 hook 的地方准备(`activate()` 内、工具处理器、命令式绘制的画布)。\n\t */\n\tgetSidebarState(): PluginSidebarState;\n\t/**\n\t * 订阅侧边栏形态变化——用户收起/展开侧边栏、或窗口跨过窄屏阈值时触发。\n\t * 返回 Disposable 取消订阅;请在插件失活时释放。\n\t *\n\t * 回调按值去重:拖窗口不会把它打成回调风暴,只有三元组真的变了才通知。\n\t */\n\tonSidebarStateChanged(listener: (state: PluginSidebarState) => void): Disposable;\n}\n"]}
|
package/docs/.source.json
CHANGED
package/docs/README.md
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
| 文档 | 内容 |
|
|
18
18
|
| --- | --- |
|
|
19
19
|
| [getting-started.md](./getting-started.md) | 环境、脚手架、Vite/Module Federation、构建、安装(含本地路径)、调试闭环 |
|
|
20
|
+
| [logging.md](./logging.md) | **插件持久化日志**:自动绑定插件身份、子作用域、结构化字段、隐私与版本要求 |
|
|
20
21
|
| [ability-details.md](./ability-details.md) | **能力详情页**:`ability.json`、结构化区块、Markdown 文件引用、多语言、资源打包与限制 |
|
|
21
22
|
| [guiding-the-agent.md](./guiding-the-agent.md) | **引导模型用好你的扩展**:三层心智模型、name/description 正反触发段、返回值引导、skill 渐进披露、执行边界、反模式与自检清单 |
|
|
22
23
|
| [manifest.md](./manifest.md) | `plugin.json` 全字段、`commands`、`contributionMode`、`agent_mode`(已废弃)、`defaultLocale` / i18n、settings、guidingWords、agent 贡献、**贡献智能体与团队** |
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
| **顶层不要出现依赖共享 React 的 JSX** | Module Federation 的加载时序问题。放进组件或 `activate` 内 | [styling-and-pitfalls](./styling-and-pitfalls.md#module-federation-顶层-jsx-陷阱) |
|
|
47
48
|
| **不要写 `agent_mode`** | 已废弃,无运行时语义。想收窄某个工具的使用场景,把「何时不该用它 + 替代做法」写进该工具 description 的反向触发段 | [guiding-the-agent](./guiding-the-agent.md#3-description-反向触发段在选择前说明边界) |
|
|
48
49
|
| **依赖用 registry 上已发布的 semver** | 不要 `workspace:*`——那是仓库内插件专用的,发出去的包在用户机器上装不上 | [getting-started](./getting-started.md#2-packagejson) |
|
|
49
|
-
|
|
|
50
|
+
| **目录市场发布要有构建制品** | 旧版 GitHub 市场通过仓库目录安装时,宿主直接读 `entry` 与 `styles`;新版 schema v3 可把 `.vettapkg` 发布为独立制品,市场仓库只保留元数据 | [getting-started](./getting-started.md#6-构建与打包) |
|
|
50
51
|
| **信息不足时问用户** | 插件 id、展示名、要用哪些权限、功能边界、是否立刻安装——不要自己假定 | — |
|
|
51
52
|
|
|
52
53
|
## 插件能做什么
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
| 能力 | 入口 | 权限 | 文档 |
|
|
57
58
|
| --- | --- | --- | --- |
|
|
58
59
|
| **全局 Toast / 错误通知** | `ctx.ui.notify` | 无 | [ui-slots](./ui-slots.md#全局通知-notify) |
|
|
60
|
+
| **持久化诊断日志** | `logger`(`@vetta-org/plugin-sdk/logger`) | 无 | [logging](./logging.md) |
|
|
59
61
|
| 全局浮层 UI | `ctx.ui.registerGlobalSlot` | `ui.slot.global` | [ui-slots](./ui-slots.md#全局浮层-registerglobalslot) |
|
|
60
62
|
| **工作区视图**(整页 + 侧边栏入口) | `ctx.ui.registerWorkspaceView` | `ui.slot.workspace-view` | [ui-slots](./ui-slots.md#工作区视图-registerworkspaceview) |
|
|
61
63
|
| 文件预览 | `ctx.ui.registerFilePreview` | `ui.slot.file-preview` | [ui-slots](./ui-slots.md#文件预览-registerfilepreview) |
|
package/docs/getting-started.md
CHANGED
|
@@ -104,7 +104,7 @@ dist/
|
|
|
104
104
|
}
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
> `react` / `react-dom` 仅用于类型与本地构建——运行时由**宿主作为共享单例提供**,不会打进你的 bundle(见 [styling-and-pitfalls.md](./styling-and-pitfalls.md))。`@vetta-org/plugin-sdk` 同理:构建时被 external 化,运行时由宿主提供。可选 UI primitives `@vetta-org/ui`(`Button` / `Dialog` / `Switch
|
|
107
|
+
> `react` / `react-dom` 仅用于类型与本地构建——运行时由**宿主作为共享单例提供**,不会打进你的 bundle(见 [styling-and-pitfalls.md](./styling-and-pitfalls.md))。`@vetta-org/plugin-sdk` 同理:构建时被 external 化,运行时由宿主提供。可选 UI primitives `@vetta-org/ui`(`Button` / `Dialog` / `Switch`…)需要同时设置 `hostUi: true` 并在 `devDependencies` 声明;没有使用时两者都不要添加。仓库内插件用 `workspace:*` 直链源码;仓库外插件改用发布版本号。
|
|
108
108
|
|
|
109
109
|
## 3. vite.config.ts
|
|
110
110
|
|
|
@@ -122,14 +122,15 @@ export default defineConfig({
|
|
|
122
122
|
name: "my_plugin", // MF remoteName,与 plugin.json.moduleFederation.remoteName 一致
|
|
123
123
|
entry: "./src/index.tsx", // 入口(默认即此)
|
|
124
124
|
expose: "./plugin", // 暴露名(默认 "./plugin",与 plugin.json.moduleFederation.expose 一致)
|
|
125
|
-
//
|
|
125
|
+
// hostUi: true, // 仅在导入 @vetta-org/ui 时开启
|
|
126
|
+
// package: true, // 见 §5:构建后自动产出 release/<id>-<version>.vettapkg
|
|
126
127
|
}),
|
|
127
128
|
],
|
|
128
129
|
esbuild: { jsx: "automatic", jsxImportSource: "react" },
|
|
129
130
|
});
|
|
130
131
|
```
|
|
131
132
|
|
|
132
|
-
`vettaPluginFederation`
|
|
133
|
+
`vettaPluginFederation` 默认把 `react` / `react-dom` / `@vetta-org/plugin-sdk` 设为 `singleton`、`import:false`(用宿主的),生产构建时 external 化 SDK。设置 `hostUi: true` 后才会以相同方式共享并 external 化 `@vetta-org/ui`。构建产出 `mf-manifest.json` + `remoteEntry.js`,CSS 落 `dist/style.css`。
|
|
133
134
|
|
|
134
135
|
它还会在插件 Tailwind 编译前自动接入 plugin-sdk 的宿主主题 Token 契约,因此
|
|
135
136
|
`text-foreground`、`text-muted-foreground/50`、`bg-card` 等语义类可以直接使用;
|
|
@@ -194,13 +195,13 @@ export default definePlugin({
|
|
|
194
195
|
bunx vite build # 产出 dist/(mf-manifest.json + remoteEntry.js + style.css)
|
|
195
196
|
```
|
|
196
197
|
|
|
197
|
-
发布需要一个
|
|
198
|
+
发布需要一个 **`.vettapkg` 插件包**。它使用 ZIP 容器,根目录放 `plugin.json`,其下 `dist/`。两种方式:
|
|
198
199
|
|
|
199
|
-
- **自动**:`vettaPluginFederation({ ..., package: true })`,`vite build` 后自动产出 `release/<id>-<version>.
|
|
200
|
-
-
|
|
200
|
+
- **自动**:`vettaPluginFederation({ ..., package: true })`,`vite build` 后自动产出 `release/<id>-<version>.vettapkg`(打包 `plugin.json` + `dist/` + 清单声明的 `styles` / `agent.promptPaths` / `agent.skillPaths`;存在 `ability.json` 时也打包它和 `presentation/`)。
|
|
201
|
+
- **手动**:自行用 ZIP 容器打包 `plugin.json` 与 `dist/`,并使用 `.vettapkg` 扩展名:
|
|
201
202
|
|
|
202
203
|
```text
|
|
203
|
-
my-plugin.
|
|
204
|
+
my-plugin.vettapkg
|
|
204
205
|
plugin.json
|
|
205
206
|
ability.json # 可选
|
|
206
207
|
presentation/ # 使用 ability.json 时可选
|
|
@@ -214,13 +215,21 @@ bunx vite build # 产出 dist/(mf-manifest.json + remoteEntry.js + style.
|
|
|
214
215
|
> 归档根目录必须有 `plugin.json`,或只含**一个**顶层文件夹、`plugin.json` 在其中。
|
|
215
216
|
> 能力详情是可选的;需要 showcase、功能网格、图片或长篇 Markdown 时见 [ability-details.md](./ability-details.md)。
|
|
216
217
|
|
|
218
|
+
GitHub 能力市场有两种分发合同:schema v1/v2 从 `source.path` 目录直接安装,
|
|
219
|
+
所以该目录必须包含构建后的 `dist/`;schema v3 从 `releases[]` 指向的固定 `.vettapkg`
|
|
220
|
+
安装,市场仓库的 `source.path` 只放详情资源,`dist/` 和插件包留在制品存储。
|
|
221
|
+
每个新版本写明已经发布的最低 App 版本、实际使用的 `pluginApiVersion`、插件包 URL
|
|
222
|
+
和 SHA-256;市场会按用户 App 与宿主 API 版本选择可安装的版本。见仓库的
|
|
223
|
+
[`docs/open-marketplace.md`](../open-marketplace.md#pluginmcp-与-bundle) 和
|
|
224
|
+
[ADR-0120](../adr/0120-plugin-marketplace-releases-are-versioned-artifacts.md)。
|
|
225
|
+
|
|
217
226
|
## 7. 安装
|
|
218
227
|
|
|
219
228
|
### GUI
|
|
220
229
|
|
|
221
230
|
通过桌面 App **设置 → 插件**(或独立插件页)安装:
|
|
222
231
|
|
|
223
|
-
-
|
|
232
|
+
- **本地插件包**:选择本地 `.vettapkg` 文件(`installFromArchive`)。旧 `.zip` 插件包仍可导入,但新发布应使用专用扩展名。
|
|
224
233
|
- **远程 URL**:填写 zip 下载地址(`installFromUrl`)。
|
|
225
234
|
|
|
226
235
|
安装后用户插件落在:
|
|
@@ -240,11 +249,11 @@ bunx vite build # 产出 dist/(mf-manifest.json + remoteEntry.js + style.
|
|
|
240
249
|
```json
|
|
241
250
|
{
|
|
242
251
|
"operation": "install-from-path",
|
|
243
|
-
"path": "/abs/path/to/my-plugin-0.1.2.
|
|
252
|
+
"path": "/abs/path/to/my-plugin-0.1.2.vettapkg"
|
|
244
253
|
}
|
|
245
254
|
```
|
|
246
255
|
|
|
247
|
-
- 路径:本机可读 **`.
|
|
256
|
+
- 路径:本机可读 **`.vettapkg` 绝对路径**(不限 cwd;兼容旧 `.zip`)。
|
|
248
257
|
- 用户确认后:按 `plugin.json` **一次授予声明权限**并默认**启用**。
|
|
249
258
|
- Desktop API:`window.vetta.plugins.installFromPath(path, { grantedPermissions?, enable? })`。
|
|
250
259
|
- 不可覆盖系统插件 id。
|
package/docs/logging.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 插件日志
|
|
2
|
+
|
|
3
|
+
Plugin API 2.5.0 起,插件可以从独立 SDK 子路径导入已经绑定身份的 logger:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { logger } from "@vetta-org/plugin-sdk/logger";
|
|
7
|
+
|
|
8
|
+
logger.info("Model synchronization completed", { modelCount: 12 });
|
|
9
|
+
logger.error("Model synchronization failed", { channel: "codex", error });
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
logger 的 `pluginId` 与版本来自构建时校验过的 `plugin.json`。插件不传 `ctx`,也不能自行声明或覆盖日志身份。`@vetta-org/plugin-vite` 在生产构建与开发服务器中把该子路径替换成当前插件专属的 facade;没有经过兼容构建工具处理时,调用会给出明确错误,不会写出无法归属的日志。
|
|
13
|
+
|
|
14
|
+
需要区分模块时使用子作用域:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
const log = logger.child("models").child("sync");
|
|
18
|
+
|
|
19
|
+
log.debug("Catalog request started");
|
|
20
|
+
log.info("Catalog published", { modelCount: 12 });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
可用级别为 `debug`、`info`、`warn`、`error`。第二个参数必须是字段对象;异常放进 `error` 字段,宿主会保留名称、消息、堆栈和 cause 链。
|
|
24
|
+
|
|
25
|
+
## 持久化与隐私
|
|
26
|
+
|
|
27
|
+
日志进入 Desktop 的 Renderer 日志管线,由宿主统一持久化、轮转并纳入诊断信息。宿主限制消息和字段大小、处理循环引用,并对常见敏感字段名、Bearer、JWT、敏感 URL 参数和邮箱做防御性脱敏。
|
|
28
|
+
|
|
29
|
+
脱敏不是插件泄露秘密的许可证。不要记录 token、Cookie、Authorization header、OAuth 内容、完整用户文件或凭据;对象字段名不明显时,宿主无法判断其中是否包含秘密。
|
|
30
|
+
|
|
31
|
+
logger 无需权限:它只能写宿主管理的诊断通道,不能选择路径、读取日志或关闭轮转。它也不替代 `ctx.ui.notify()`——用户需要知道并采取行动的失败仍应通知;logger 用于开发者诊断和事后定位。
|
|
32
|
+
|
|
33
|
+
## 版本要求
|
|
34
|
+
|
|
35
|
+
使用该入口的插件需要:
|
|
36
|
+
|
|
37
|
+
- `@vetta-org/plugin-sdk >= 0.3.7 < 0.4.0`
|
|
38
|
+
- `@vetta-org/plugin-vite >= 0.2.3 < 0.3.0`
|
|
39
|
+
- `plugin.json#pluginApiVersion` 声明 `^2.5.0`
|
|
40
|
+
|
|
41
|
+
旧插件不导入 logger 时保持原行为。
|
package/docs/manifest.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 清单参考(plugin.json)
|
|
2
2
|
|
|
3
|
-
`plugin.json` 是插件的唯一清单,位于
|
|
3
|
+
`plugin.json` 是插件的唯一清单,位于 `.vettapkg` 包的 ZIP 容器根目录(或唯一顶层文件夹内)。
|
|
4
4
|
|
|
5
5
|
它描述插件的运行时合同。能力页的可选长详情使用独立的 `ability.json`,见
|
|
6
6
|
[能力详情页](./ability-details.md);不要把 showcase、长 Markdown 或展示图片塞进 `plugin.json`。
|
|
@@ -61,7 +61,7 @@ Schema 只描述 `plugin.json` 数据本身;Plugin API 版本是否兼容、
|
|
|
61
61
|
| `id` | ✅ | string | 全局唯一插件 id。决定安装目录、id 冲突时的去重,建议小写短横线。 |
|
|
62
62
|
| `name` | ✅ | string | 展示名。可用 `%key%`(见 [i18n](#i18n))。 |
|
|
63
63
|
| `version` | ✅ | string | 语义化版本。**bump 它可强制宿主重新拉取**绕过缓存(见 [styling-and-pitfalls.md](./styling-and-pitfalls.md))。 |
|
|
64
|
-
| `pluginApiVersion` | ✅ | string |
|
|
64
|
+
| `pluginApiVersion` | ✅ | string | 兼容的宿主 Plugin API 版本范围;基础插件可用 `^2.0.0`,使用较新能力时按对应文档提高下限。 |
|
|
65
65
|
| `entry` | ✅ | string | Module Federation 清单路径,通常为 `dist/mf-manifest.json`。 |
|
|
66
66
|
| `moduleFederation` | ✅ | `{ remoteName, expose }` | `remoteName` 与 vite 配置 `name` 一致;`expose` 与 vite `expose` 一致(默认 `./plugin`)。 |
|
|
67
67
|
| `styles` | ❌ | string[] | 要注入的 CSS 文件路径(相对插件根)。 |
|