@ai-gui/plugin-sdk
v0.29.2
Published
Minimal plugin authoring and testing helpers for AIGUI.
Maintainers
Readme
@ai-gui/plugin-sdk
Minimal authoring and test helpers for AIGUI plugins. The package has no test-runner dependency and is safe to import in Node.js.
Install
pnpm add @ai-gui/core @ai-gui/plugin-sdkAuthor a plugin
import { definePlugin } from "@ai-gui/plugin-sdk"
export const example = definePlugin({
name: "example",
nodeRenderers: {
example: (node) => ({ kind: "html", html: node.content ?? "" }),
},
})definePlugin is an identity helper: it validates the plugin shape while preserving its concrete inferred type.
Test a plugin
import { createTestNode, renderPluginNode } from "@ai-gui/plugin-sdk"
const output = await renderPluginNode(example, createTestNode("example", { content: "Hello" }))For mount outputs, supply your own element and clean up safely:
import { mountOutputForTest } from "@ai-gui/plugin-sdk"
const cleanup = mountOutputForTest(output, element, optionalMountContext)
cleanup()
cleanup() // harmless; an underlying disposer runs at most onceExports
- Core authoring types:
AIGuiPlugin,ASTNode,CardDef,CollectNodeRendererOptions,JSONSchema,NodeRenderer,PluginCommitContext,RenderOutput. - Core helpers:
collectNodeRenderers,pluginNodeTypes. - SDK helpers:
definePlugin,createTestNode,getPluginRenderer,renderPluginNode,mountOutputForTest.
