Files
fusion/packages/plugin-sdk/src/index.ts
Fusion c187c670e1 feat(FN-2255): add plugin runtime discovery contracts
- Extend core/plugin-sdk types with runtime manifest metadata, runtime factory, and runtime registration exports
- Add runtime validation in plugin manifest parsing, including runtimeId slug and semver checks
- Add PluginLoader.getPluginRuntimes() and PluginRunner runtime cache/invalidation plumbing across plugin lifecycle events
- Expand plugin loader/runner test coverage for runtime discovery and cache behavior, and document runtime registration in PLUGIN_AUTHORING.md
2026-04-22 13:01:25 -07:00

105 lines
2.6 KiB
TypeScript

/**
* Fusion Plugin SDK
*
* This package provides type definitions and helpers for creating Fusion plugins.
* It re-exports all plugin-related types from @fusion/core.
*
* @example
* ```typescript
* import { definePlugin } from "@fusion/plugin-sdk";
*
* export default definePlugin({
* manifest: {
* id: "my-plugin",
* name: "My Plugin",
* version: "1.0.0",
* },
* hooks: {
* onLoad: async (ctx) => {
* ctx.logger.info("Plugin loaded!");
* },
* },
* tools: [
* {
* name: "my_tool",
* description: "Does something useful",
* parameters: { type: "object", properties: { input: { type: "string" } } },
* execute: async (params, ctx) => ({
* content: [{ type: "text", text: `Processed: ${params.input}` }],
* }),
* },
* ],
* });
* ```
*/
// Re-export all plugin types from @fusion/core
export type {
PluginManifest,
PluginSettingSchema,
PluginSettingType,
PluginOnLoad,
PluginOnUnload,
PluginOnTaskCreated,
PluginOnTaskMoved,
PluginOnTaskCompleted,
PluginOnError,
PluginToolDefinition,
PluginToolResult,
PluginRouteDefinition,
PluginRouteMethod,
PluginUiSlotDefinition,
PluginRuntimeManifestMetadata,
PluginRuntimeFactory,
PluginRuntimeRegistration,
PluginContext,
PluginLogger,
FusionPlugin,
PluginState,
PluginInstallation,
} from "../../core/src/plugin-types.js";
export { validatePluginManifest } from "../../core/src/plugin-types.js";
import type { FusionPlugin } from "../../core/src/plugin-types.js";
/**
* Type-safe helper for defining a Fusion plugin.
*
* Provides autocompletion and compile-time validation for plugin definitions.
* This is an identity function - it returns the input unchanged.
*
* @example
* ```typescript
* export default definePlugin({
* manifest: {
* id: "my-plugin",
* name: "My Plugin",
* version: "1.0.0",
* description: "Does something cool",
* },
* hooks: {
* onLoad: async (ctx) => {
* ctx.logger.info("Plugin loaded!");
* },
* onTaskCompleted: async (task, ctx) => {
* ctx.logger.info(`Task ${task.id} completed!`);
* },
* },
* tools: [
* {
* name: "my_tool",
* description: "Does something useful",
* parameters: { type: "object", properties: { input: { type: "string" } } },
* execute: async (params, ctx) => ({
* content: [{ type: "text", text: `Processed: ${params.input}` }],
* }),
* },
* ],
* });
* ```
*/
export function definePlugin(plugin: FusionPlugin): FusionPlugin {
return plugin;
}