Files
Agent-System-Frontend/src/pluginHost.ts
T
weichenandCursor 22f7d84560 Load plugin ESM pages and record command-pair checks
Why: Plugin pages must mount through a host bridge, and button versus chat command parity needs a check that vitest does not execute as a unit test.
Evidence: npx vitest run passed. The Playwright file lives under e2e and is outside the tsconfig include.
Impact: loadPluginPage expects mount/unmount. @playwright/test is not a required dependency yet.
Refs: docs/proposals/2026-10-01-plugin-contract-v2.md
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-01 10:34:36 +00:00

15 lines
626 B
TypeScript

import type { PluginPageDecl } from './contracts'
export interface PluginPageModule {
mount(el: HTMLElement, bridge: unknown): void
unmount?: () => void
}
// loadPluginPage 按声明加载 ESM。模块 URL 由插件页面声明给出,宿主不内嵌领域页面。
export async function loadPluginPage(page: PluginPageDecl): Promise<PluginPageModule> {
if (!page.module) throw new Error(`plugin page ${page.id} missing module`)
const mod = await import(/* @vite-ignore */ page.module)
if (typeof mod.mount !== 'function') throw new Error(`plugin page ${page.id} has no mount`)
return mod as PluginPageModule
}