Add plugin framework and settings UI

This commit is contained in:
Dotta
2026-03-13 16:22:34 -05:00
parent 7e288d20fc
commit 80cdbdbd47
103 changed files with 31760 additions and 35 deletions

View File

@@ -0,0 +1,2 @@
export { default as manifest } from "./manifest.js";
export { default as worker } from "./worker.js";

View File

@@ -0,0 +1,39 @@
import type { PaperclipPluginManifestV1 } from "@paperclipai/plugin-sdk";
/**
* Stable plugin ID used by host registration and namespacing.
*/
const PLUGIN_ID = "paperclip.hello-world-example";
const PLUGIN_VERSION = "0.1.0";
const DASHBOARD_WIDGET_SLOT_ID = "hello-world-dashboard-widget";
const DASHBOARD_WIDGET_EXPORT_NAME = "HelloWorldDashboardWidget";
/**
* Minimal manifest demonstrating a UI-only plugin with one dashboard widget slot.
*/
const manifest: PaperclipPluginManifestV1 = {
id: PLUGIN_ID,
apiVersion: 1,
version: PLUGIN_VERSION,
displayName: "Hello World Widget (Example)",
description: "Reference UI plugin that adds a simple Hello World widget to the Paperclip dashboard.",
author: "Paperclip",
categories: ["ui"],
capabilities: ["ui.dashboardWidget.register"],
entrypoints: {
worker: "./dist/worker.js",
ui: "./dist/ui",
},
ui: {
slots: [
{
type: "dashboardWidget",
id: DASHBOARD_WIDGET_SLOT_ID,
displayName: "Hello World",
exportName: DASHBOARD_WIDGET_EXPORT_NAME,
},
],
},
};
export default manifest;

View File

@@ -0,0 +1,17 @@
import type { PluginWidgetProps } from "@paperclipai/plugin-sdk/ui";
const WIDGET_LABEL = "Hello world plugin widget";
/**
* Example dashboard widget showing the smallest possible UI contribution.
*/
export function HelloWorldDashboardWidget({ context }: PluginWidgetProps) {
return (
<section aria-label={WIDGET_LABEL}>
<strong>Hello world</strong>
<div>This widget was added by @paperclipai/plugin-hello-world-example.</div>
{/* Include host context so authors can see where scoped IDs come from. */}
<div>Company context: {context.companyId}</div>
</section>
);
}

View File

@@ -0,0 +1,27 @@
import { definePlugin, runWorker } from "@paperclipai/plugin-sdk";
const PLUGIN_NAME = "hello-world-example";
const HEALTH_MESSAGE = "Hello World example plugin ready";
/**
* Worker lifecycle hooks for the Hello World reference plugin.
* This stays intentionally small so new authors can copy the shape quickly.
*/
const plugin = definePlugin({
/**
* Called when the host starts the plugin worker.
*/
async setup(ctx) {
ctx.logger.info(`${PLUGIN_NAME} plugin setup complete`);
},
/**
* Called by the host health probe endpoint.
*/
async onHealth() {
return { status: "ok", message: HEALTH_MESSAGE };
},
});
export default plugin;
runWorker(plugin, import.meta.url);