Initial commit: Paperclip plugin for Legal AI integration

16 agent tools, event handler for auto-linking, sync job every 15m.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 08:03:43 +00:00
commit 587a2a76ca
1183 changed files with 629235 additions and 0 deletions

View File

@@ -0,0 +1,257 @@
/**
* Shared UI component declarations for plugin frontends.
*
* These components are exported from `@paperclipai/plugin-sdk/ui` and are
* provided by the host at runtime. They match the host's design tokens and
* visual language, reducing the boilerplate needed to build consistent plugin UIs.
*
* **Plugins are not required to use these components.** They exist to reduce
* boilerplate and keep visual consistency. A plugin may render entirely custom
* UI using any React component library.
*
* Component implementations are provided by the host — plugin bundles contain
* only the type declarations; the runtime implementations are injected via the
* host module registry.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components In `@paperclipai/plugin-sdk/ui`
*/
import type React from "react";
/**
* A trend value that can accompany a metric.
* Positive values indicate upward trends; negative values indicate downward trends.
*/
export interface MetricTrend {
/** Direction of the trend. */
direction: "up" | "down" | "flat";
/** Percentage change value (e.g. `12.5` for 12.5%). */
percentage?: number;
}
/** Props for `MetricCard`. */
export interface MetricCardProps {
/** Short label describing the metric (e.g. `"Synced Issues"`). */
label: string;
/** The metric value to display. */
value: number | string;
/** Optional trend indicator. */
trend?: MetricTrend;
/** Optional sparkline data (array of numbers, latest last). */
sparkline?: number[];
/** Optional unit suffix (e.g. `"%"`, `"ms"`). */
unit?: string;
}
/** Status variants for `StatusBadge`. */
export type StatusBadgeVariant = "ok" | "warning" | "error" | "info" | "pending";
/** Props for `StatusBadge`. */
export interface StatusBadgeProps {
/** Human-readable label. */
label: string;
/** Visual variant determining colour. */
status: StatusBadgeVariant;
}
/** A single column definition for `DataTable`. */
export interface DataTableColumn<T = Record<string, unknown>> {
/** Column key, matching a field on the row object. */
key: keyof T & string;
/** Column header label. */
header: string;
/** Optional custom cell renderer. */
render?: (value: unknown, row: T) => React.ReactNode;
/** Whether this column is sortable. */
sortable?: boolean;
/** CSS width (e.g. `"120px"`, `"20%"`). */
width?: string;
}
/** Props for `DataTable`. */
export interface DataTableProps<T = Record<string, unknown>> {
/** Column definitions. */
columns: DataTableColumn<T>[];
/** Row data. Each row should have a stable `id` field. */
rows: T[];
/** Whether the table is currently loading. */
loading?: boolean;
/** Message shown when `rows` is empty. */
emptyMessage?: string;
/** Total row count for pagination (if different from `rows.length`). */
totalCount?: number;
/** Current page (0-based, for pagination). */
page?: number;
/** Rows per page (for pagination). */
pageSize?: number;
/** Callback when page changes. */
onPageChange?: (page: number) => void;
/** Callback when a column header is clicked to sort. */
onSort?: (key: string, direction: "asc" | "desc") => void;
}
/** A single data point for `TimeseriesChart`. */
export interface TimeseriesDataPoint {
/** ISO 8601 timestamp. */
timestamp: string;
/** Numeric value. */
value: number;
/** Optional label for the point. */
label?: string;
}
/** Props for `TimeseriesChart`. */
export interface TimeseriesChartProps {
/** Series data. */
data: TimeseriesDataPoint[];
/** Chart title. */
title?: string;
/** Y-axis label. */
yLabel?: string;
/** Chart type. Defaults to `"line"`. */
type?: "line" | "bar";
/** Height of the chart in pixels. Defaults to `200`. */
height?: number;
/** Whether the chart is currently loading. */
loading?: boolean;
}
/** Props for `MarkdownBlock`. */
export interface MarkdownBlockProps {
/** Markdown content to render. */
content: string;
}
/** A single key-value pair for `KeyValueList`. */
export interface KeyValuePair {
/** Label for the key. */
label: string;
/** Value to display. May be a string, number, or a React node. */
value: React.ReactNode;
}
/** Props for `KeyValueList`. */
export interface KeyValueListProps {
/** Pairs to render in the list. */
pairs: KeyValuePair[];
}
/** A single action button for `ActionBar`. */
export interface ActionBarItem {
/** Button label. */
label: string;
/** Action key to call via the plugin bridge. */
actionKey: string;
/** Optional parameters to pass to the action handler. */
params?: Record<string, unknown>;
/** Button variant. Defaults to `"default"`. */
variant?: "default" | "primary" | "destructive";
/** Whether to show a confirmation dialog before executing. */
confirm?: boolean;
/** Text for the confirmation dialog (used when `confirm` is true). */
confirmMessage?: string;
}
/** Props for `ActionBar`. */
export interface ActionBarProps {
/** Action definitions. */
actions: ActionBarItem[];
/** Called after an action succeeds. Use to trigger data refresh. */
onSuccess?: (actionKey: string, result: unknown) => void;
/** Called when an action fails. */
onError?: (actionKey: string, error: unknown) => void;
}
/** A single log line for `LogView`. */
export interface LogViewEntry {
/** ISO 8601 timestamp. */
timestamp: string;
/** Log level. */
level: "info" | "warn" | "error" | "debug";
/** Log message. */
message: string;
/** Optional structured metadata. */
meta?: Record<string, unknown>;
}
/** Props for `LogView`. */
export interface LogViewProps {
/** Log entries to display. */
entries: LogViewEntry[];
/** Maximum height of the scrollable container (CSS value). Defaults to `"400px"`. */
maxHeight?: string;
/** Whether to auto-scroll to the latest entry. */
autoScroll?: boolean;
/** Whether the log is currently loading. */
loading?: boolean;
}
/** Props for `JsonTree`. */
export interface JsonTreeProps {
/** The data to render as a collapsible JSON tree. */
data: unknown;
/** Initial depth to expand. Defaults to `2`. */
defaultExpandDepth?: number;
}
/** Props for `Spinner`. */
export interface SpinnerProps {
/** Size of the spinner. Defaults to `"md"`. */
size?: "sm" | "md" | "lg";
/** Accessible label for the spinner (used as `aria-label`). */
label?: string;
}
/** Props for `ErrorBoundary`. */
export interface ErrorBoundaryProps {
/** Content to render inside the error boundary. */
children: React.ReactNode;
/** Optional custom fallback to render when an error is caught. */
fallback?: React.ReactNode;
/** Called when an error is caught, for logging or reporting. */
onError?: (error: Error, info: React.ErrorInfo) => void;
}
export declare const MetricCard: React.ComponentType<MetricCardProps>;
/**
* Displays an inline status badge (ok / warning / error / info / pending).
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const StatusBadge: React.ComponentType<StatusBadgeProps>;
/**
* Sortable, paginated data table.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const DataTable: React.ComponentType<DataTableProps<Record<string, unknown>>>;
/**
* Line or bar chart for time-series data.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const TimeseriesChart: React.ComponentType<TimeseriesChartProps>;
/**
* Renders Markdown text as HTML.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const MarkdownBlock: React.ComponentType<MarkdownBlockProps>;
/**
* Renders a definition-list of label/value pairs.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const KeyValueList: React.ComponentType<KeyValueListProps>;
/**
* Row of action buttons wired to the plugin bridge's `performAction` handlers.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const ActionBar: React.ComponentType<ActionBarProps>;
/**
* Scrollable, timestamped log output viewer.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const LogView: React.ComponentType<LogViewProps>;
/**
* Collapsible JSON tree for debugging or raw data inspection.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const JsonTree: React.ComponentType<JsonTreeProps>;
/**
* Loading indicator.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export declare const Spinner: React.ComponentType<SpinnerProps>;
/**
* React error boundary that prevents plugin rendering errors from crashing
* the host page.
*
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*/
export declare const ErrorBoundary: React.ComponentType<ErrorBoundaryProps>;
//# sourceMappingURL=components.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/ui/components.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,8BAA8B;IAC9B,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,8BAA8B;AAC9B,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,gCAAgC;IACh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AAO,CAAC;IACd,gDAAgD;IAChD,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,2BAA2B;AAC3B,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,iCAAiC;AACjC,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,gEAAgE;IAChE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,KAAK,IAAI,CAAC;CACzD;AAqBD,eAAO,MAAM,UAAU,sCAAsD,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,WAAW,uCAAwD,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,SAAS,8DAAoD,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,eAAe,2CAAgE,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,aAAa,yCAA4D,CAAC;AAEvF;;;;GAIG;AACH,eAAO,MAAM,YAAY,wCAA0D,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,SAAS,qCAAoD,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,OAAO,mCAAgD,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,oCAAkD,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,OAAO,mCAAgD,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,yCAA4D,CAAC"}

View File

@@ -0,0 +1,97 @@
/**
* Shared UI component declarations for plugin frontends.
*
* These components are exported from `@paperclipai/plugin-sdk/ui` and are
* provided by the host at runtime. They match the host's design tokens and
* visual language, reducing the boilerplate needed to build consistent plugin UIs.
*
* **Plugins are not required to use these components.** They exist to reduce
* boilerplate and keep visual consistency. A plugin may render entirely custom
* UI using any React component library.
*
* Component implementations are provided by the host — plugin bundles contain
* only the type declarations; the runtime implementations are injected via the
* host module registry.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components In `@paperclipai/plugin-sdk/ui`
*/
import { renderSdkUiComponent } from "./runtime.js";
// ---------------------------------------------------------------------------
// Component declarations (provided by host at runtime)
// ---------------------------------------------------------------------------
// These are declared as ambient values so plugin TypeScript code can import
// and use them with full type-checking. The host's module registry provides
// the concrete React component implementations at bundle load time.
/**
* Displays a single metric with an optional trend indicator and sparkline.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
function createSdkUiComponent(name) {
return function PaperclipSdkUiComponent(props) {
return renderSdkUiComponent(name, props);
};
}
export const MetricCard = createSdkUiComponent("MetricCard");
/**
* Displays an inline status badge (ok / warning / error / info / pending).
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const StatusBadge = createSdkUiComponent("StatusBadge");
/**
* Sortable, paginated data table.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const DataTable = createSdkUiComponent("DataTable");
/**
* Line or bar chart for time-series data.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const TimeseriesChart = createSdkUiComponent("TimeseriesChart");
/**
* Renders Markdown text as HTML.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const MarkdownBlock = createSdkUiComponent("MarkdownBlock");
/**
* Renders a definition-list of label/value pairs.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const KeyValueList = createSdkUiComponent("KeyValueList");
/**
* Row of action buttons wired to the plugin bridge's `performAction` handlers.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const ActionBar = createSdkUiComponent("ActionBar");
/**
* Scrollable, timestamped log output viewer.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const LogView = createSdkUiComponent("LogView");
/**
* Collapsible JSON tree for debugging or raw data inspection.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const JsonTree = createSdkUiComponent("JsonTree");
/**
* Loading indicator.
*
* @see PLUGIN_SPEC.md §19.6 — Shared Components
*/
export const Spinner = createSdkUiComponent("Spinner");
/**
* React error boundary that prevents plugin rendering errors from crashing
* the host page.
*
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*/
export const ErrorBoundary = createSdkUiComponent("ErrorBoundary");
//# sourceMappingURL=components.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/ui/components.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAwMpD,8EAA8E;AAC9E,uDAAuD;AACvD,8EAA8E;AAE9E,4EAA4E;AAC5E,4EAA4E;AAC5E,oEAAoE;AAEpE;;;;GAIG;AACH,SAAS,oBAAoB,CAAS,IAAY;IAChD,OAAO,SAAS,uBAAuB,CAAC,KAAa;QACnD,OAAO,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAoB,CAAC;IAC9D,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAkB,YAAY,CAAC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAmB,aAAa,CAAC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,oBAAoB,CAAiB,WAAW,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,CAAuB,iBAAiB,CAAC,CAAC;AAE7F;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAqB,eAAe,CAAC,CAAC;AAEvF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAoB,cAAc,CAAC,CAAC;AAEpF;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,oBAAoB,CAAiB,WAAW,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,oBAAoB,CAAe,SAAS,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,oBAAoB,CAAgB,UAAU,CAAC,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,oBAAoB,CAAe,SAAS,CAAC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAqB,eAAe,CAAC,CAAC"}

120
node_modules/@paperclipai/plugin-sdk/dist/ui/hooks.d.ts generated vendored Normal file
View File

@@ -0,0 +1,120 @@
import type { PluginDataResult, PluginActionFn, PluginHostContext, PluginStreamResult, PluginToastFn } from "./types.js";
/**
* Fetch data from the plugin worker's registered `getData` handler.
*
* Calls `ctx.data.register(key, handler)` in the worker and returns the
* result as reactive state. Re-fetches when `params` changes.
*
* @template T The expected shape of the returned data
* @param key - The data key matching the handler registered with `ctx.data.register()`
* @param params - Optional parameters forwarded to the handler
* @returns `PluginDataResult<T>` with `data`, `loading`, `error`, and `refresh`
*
* @example
* ```tsx
* function SyncWidget({ context }: PluginWidgetProps) {
* const { data, loading, error } = usePluginData<SyncHealth>("sync-health", {
* companyId: context.companyId,
* });
*
* if (loading) return <div>Loading…</div>;
* if (error) return <div>Error: {error.message}</div>;
* return <div>Synced Issues: {data!.syncedCount}</div>;
* }
* ```
*
* @see PLUGIN_SPEC.md §13.8 — `getData`
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*/
export declare function usePluginData<T = unknown>(key: string, params?: Record<string, unknown>): PluginDataResult<T>;
/**
* Get a callable function that invokes the plugin worker's registered
* `performAction` handler.
*
* The returned function is async and throws a `PluginBridgeError` on failure.
*
* @param key - The action key matching the handler registered with `ctx.actions.register()`
* @returns An async function that sends the action to the worker and resolves with the result
*
* @example
* ```tsx
* function ResyncButton({ context }: PluginWidgetProps) {
* const resync = usePluginAction("resync");
* const [error, setError] = useState<string | null>(null);
*
* async function handleClick() {
* try {
* await resync({ companyId: context.companyId });
* } catch (err) {
* setError((err as PluginBridgeError).message);
* }
* }
*
* return <button onClick={handleClick}>Resync Now</button>;
* }
* ```
*
* @see PLUGIN_SPEC.md §13.9 — `performAction`
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*/
export declare function usePluginAction(key: string): PluginActionFn;
/**
* Read the current host context (active company, project, entity, user).
*
* Use this to know which context the plugin component is being rendered in
* so you can scope data requests and actions accordingly.
*
* @returns The current `PluginHostContext`
*
* @example
* ```tsx
* function IssueTab() {
* const { companyId, entityId } = useHostContext();
* const { data } = usePluginData("linear-link", { issueId: entityId });
* return <div>{data?.linearIssueUrl}</div>;
* }
* ```
*
* @see PLUGIN_SPEC.md §19 — UI Extension Model
*/
export declare function useHostContext(): PluginHostContext;
/**
* Subscribe to a real-time event stream pushed from the plugin worker.
*
* Opens an SSE connection to `GET /api/plugins/:pluginId/bridge/stream/:channel`
* and accumulates events as they arrive. The worker pushes events using
* `ctx.streams.emit(channel, event)`.
*
* @template T The expected shape of each streamed event
* @param channel - The stream channel name (must match what the worker uses in `ctx.streams.emit`)
* @param options - Optional configuration for the stream
* @returns `PluginStreamResult<T>` with `events`, `lastEvent`, connection status, and `close()`
*
* @example
* ```tsx
* function ChatMessages() {
* const { events, connected, close } = usePluginStream<ChatToken>("chat-stream");
*
* return (
* <div>
* {events.map((e, i) => <span key={i}>{e.text}</span>)}
* {connected && <span className="pulse" />}
* <button onClick={close}>Stop</button>
* </div>
* );
* }
* ```
*
* @see PLUGIN_SPEC.md §19.8 — Real-Time Streaming
*/
export declare function usePluginStream<T = unknown>(channel: string, options?: {
companyId?: string;
}): PluginStreamResult<T>;
/**
* Trigger a host toast notification from plugin UI.
*
* This lets plugin pages and widgets surface user-facing feedback through the
* same toast system as the host app without reaching into host internals.
*/
export declare function usePluginToast(): PluginToastFn;
//# sourceMappingURL=hooks.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/ui/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACd,MAAM,YAAY,CAAC;AAOpB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EACvC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,gBAAgB,CAAC,CAAC,CAAC,CAKrB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAG3D;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,CAGlD;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,OAAO,EACzC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B,kBAAkB,CAAC,CAAC,CAAC,CAKvB;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,aAAa,CAG9C"}

148
node_modules/@paperclipai/plugin-sdk/dist/ui/hooks.js generated vendored Normal file
View File

@@ -0,0 +1,148 @@
import { getSdkUiRuntimeValue } from "./runtime.js";
// ---------------------------------------------------------------------------
// usePluginData
// ---------------------------------------------------------------------------
/**
* Fetch data from the plugin worker's registered `getData` handler.
*
* Calls `ctx.data.register(key, handler)` in the worker and returns the
* result as reactive state. Re-fetches when `params` changes.
*
* @template T The expected shape of the returned data
* @param key - The data key matching the handler registered with `ctx.data.register()`
* @param params - Optional parameters forwarded to the handler
* @returns `PluginDataResult<T>` with `data`, `loading`, `error`, and `refresh`
*
* @example
* ```tsx
* function SyncWidget({ context }: PluginWidgetProps) {
* const { data, loading, error } = usePluginData<SyncHealth>("sync-health", {
* companyId: context.companyId,
* });
*
* if (loading) return <div>Loading…</div>;
* if (error) return <div>Error: {error.message}</div>;
* return <div>Synced Issues: {data!.syncedCount}</div>;
* }
* ```
*
* @see PLUGIN_SPEC.md §13.8 — `getData`
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*/
export function usePluginData(key, params) {
const impl = getSdkUiRuntimeValue("usePluginData");
return impl(key, params);
}
// ---------------------------------------------------------------------------
// usePluginAction
// ---------------------------------------------------------------------------
/**
* Get a callable function that invokes the plugin worker's registered
* `performAction` handler.
*
* The returned function is async and throws a `PluginBridgeError` on failure.
*
* @param key - The action key matching the handler registered with `ctx.actions.register()`
* @returns An async function that sends the action to the worker and resolves with the result
*
* @example
* ```tsx
* function ResyncButton({ context }: PluginWidgetProps) {
* const resync = usePluginAction("resync");
* const [error, setError] = useState<string | null>(null);
*
* async function handleClick() {
* try {
* await resync({ companyId: context.companyId });
* } catch (err) {
* setError((err as PluginBridgeError).message);
* }
* }
*
* return <button onClick={handleClick}>Resync Now</button>;
* }
* ```
*
* @see PLUGIN_SPEC.md §13.9 — `performAction`
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*/
export function usePluginAction(key) {
const impl = getSdkUiRuntimeValue("usePluginAction");
return impl(key);
}
// ---------------------------------------------------------------------------
// useHostContext
// ---------------------------------------------------------------------------
/**
* Read the current host context (active company, project, entity, user).
*
* Use this to know which context the plugin component is being rendered in
* so you can scope data requests and actions accordingly.
*
* @returns The current `PluginHostContext`
*
* @example
* ```tsx
* function IssueTab() {
* const { companyId, entityId } = useHostContext();
* const { data } = usePluginData("linear-link", { issueId: entityId });
* return <div>{data?.linearIssueUrl}</div>;
* }
* ```
*
* @see PLUGIN_SPEC.md §19 — UI Extension Model
*/
export function useHostContext() {
const impl = getSdkUiRuntimeValue("useHostContext");
return impl();
}
// ---------------------------------------------------------------------------
// usePluginStream
// ---------------------------------------------------------------------------
/**
* Subscribe to a real-time event stream pushed from the plugin worker.
*
* Opens an SSE connection to `GET /api/plugins/:pluginId/bridge/stream/:channel`
* and accumulates events as they arrive. The worker pushes events using
* `ctx.streams.emit(channel, event)`.
*
* @template T The expected shape of each streamed event
* @param channel - The stream channel name (must match what the worker uses in `ctx.streams.emit`)
* @param options - Optional configuration for the stream
* @returns `PluginStreamResult<T>` with `events`, `lastEvent`, connection status, and `close()`
*
* @example
* ```tsx
* function ChatMessages() {
* const { events, connected, close } = usePluginStream<ChatToken>("chat-stream");
*
* return (
* <div>
* {events.map((e, i) => <span key={i}>{e.text}</span>)}
* {connected && <span className="pulse" />}
* <button onClick={close}>Stop</button>
* </div>
* );
* }
* ```
*
* @see PLUGIN_SPEC.md §19.8 — Real-Time Streaming
*/
export function usePluginStream(channel, options) {
const impl = getSdkUiRuntimeValue("usePluginStream");
return impl(channel, options);
}
// ---------------------------------------------------------------------------
// usePluginToast
// ---------------------------------------------------------------------------
/**
* Trigger a host toast notification from plugin UI.
*
* This lets plugin pages and widgets surface user-facing feedback through the
* same toast system as the host app without reaching into host internals.
*/
export function usePluginToast() {
const impl = getSdkUiRuntimeValue("usePluginToast");
return impl();
}
//# sourceMappingURL=hooks.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/ui/hooks.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAW,EACX,MAAgC;IAEhC,MAAM,IAAI,GAAG,oBAAoB,CAE/B,eAAe,CAAC,CAAC;IACnB,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,IAAI,GAAG,oBAAoB,CAAsC,iBAAiB,CAAC,CAAC;IAC1F,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAED,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,IAAI,GAAG,oBAAoB,CAA0B,gBAAgB,CAAC,CAAC;IAC7E,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,OAAgC;IAEhC,MAAM,IAAI,GAAG,oBAAoB,CAE/B,iBAAiB,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,IAAI,GAAG,oBAAoB,CAAsB,gBAAgB,CAAC,CAAC;IACzE,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC"}

View File

@@ -0,0 +1,50 @@
/**
* `@paperclipai/plugin-sdk/ui` — Paperclip plugin UI SDK.
*
* Import this subpath from plugin UI bundles (React components that run in
* the host frontend). Do **not** import this from plugin worker code.
*
* The worker-side SDK is available from `@paperclipai/plugin-sdk` (root).
*
* @see PLUGIN_SPEC.md §19.0.1 — Plugin UI SDK
* @see PLUGIN_SPEC.md §29.2 — SDK Versioning
*
* @example
* ```tsx
* // Plugin UI bundle entry (dist/ui/index.tsx)
* import { usePluginData, usePluginAction } from "@paperclipai/plugin-sdk/ui";
* import type { PluginWidgetProps } from "@paperclipai/plugin-sdk/ui";
*
* export function DashboardWidget({ context }: PluginWidgetProps) {
* const { data, loading, error } = usePluginData("sync-health", {
* companyId: context.companyId,
* });
* const resync = usePluginAction("resync");
*
* if (loading) return <div>Loading…</div>;
* if (error) return <div>Error: {error.message}</div>;
*
* return (
* <div style={{ display: "grid", gap: 8 }}>
* <strong>Synced Issues</strong>
* <div>{data!.syncedCount}</div>
* <button onClick={() => resync({ companyId: context.companyId })}>
* Resync Now
* </button>
* </div>
* );
* }
* ```
*/
/**
* Bridge hooks for plugin UI components to communicate with the plugin worker.
*
* - `usePluginData(key, params)` — fetch data from the worker's `getData` handler
* - `usePluginAction(key)` — get a callable that invokes the worker's `performAction` handler
* - `useHostContext()` — read the current active company, project, entity, and user IDs
* - `usePluginStream(channel)` — subscribe to real-time SSE events from the worker
*/
export { usePluginData, usePluginAction, useHostContext, usePluginStream, usePluginToast, } from "./hooks.js";
export type { PluginBridgeError, PluginBridgeErrorCode, PluginHostContext, PluginModalBoundsRequest, PluginRenderCloseEvent, PluginRenderCloseHandler, PluginRenderCloseLifecycle, PluginRenderEnvironmentContext, PluginLauncherBounds, PluginLauncherRenderEnvironment, PluginDataResult, PluginActionFn, PluginStreamResult, PluginToastTone, PluginToastAction, PluginToastInput, PluginToastFn, } from "./types.js";
export type { PluginPageProps, PluginWidgetProps, PluginDetailTabProps, PluginSidebarProps, PluginProjectSidebarItemProps, PluginCommentAnnotationProps, PluginCommentContextMenuItemProps, PluginSettingsPageProps, } from "./types.js";
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;GAOG;AACH,OAAO,EACL,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,EAC9B,oBAAoB,EACpB,+BAA+B,EAC/B,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,iCAAiC,EACjC,uBAAuB,GACxB,MAAM,YAAY,CAAC"}

48
node_modules/@paperclipai/plugin-sdk/dist/ui/index.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
/**
* `@paperclipai/plugin-sdk/ui` — Paperclip plugin UI SDK.
*
* Import this subpath from plugin UI bundles (React components that run in
* the host frontend). Do **not** import this from plugin worker code.
*
* The worker-side SDK is available from `@paperclipai/plugin-sdk` (root).
*
* @see PLUGIN_SPEC.md §19.0.1 — Plugin UI SDK
* @see PLUGIN_SPEC.md §29.2 — SDK Versioning
*
* @example
* ```tsx
* // Plugin UI bundle entry (dist/ui/index.tsx)
* import { usePluginData, usePluginAction } from "@paperclipai/plugin-sdk/ui";
* import type { PluginWidgetProps } from "@paperclipai/plugin-sdk/ui";
*
* export function DashboardWidget({ context }: PluginWidgetProps) {
* const { data, loading, error } = usePluginData("sync-health", {
* companyId: context.companyId,
* });
* const resync = usePluginAction("resync");
*
* if (loading) return <div>Loading…</div>;
* if (error) return <div>Error: {error.message}</div>;
*
* return (
* <div style={{ display: "grid", gap: 8 }}>
* <strong>Synced Issues</strong>
* <div>{data!.syncedCount}</div>
* <button onClick={() => resync({ companyId: context.companyId })}>
* Resync Now
* </button>
* </div>
* );
* }
* ```
*/
/**
* Bridge hooks for plugin UI components to communicate with the plugin worker.
*
* - `usePluginData(key, params)` — fetch data from the worker's `getData` handler
* - `usePluginAction(key)` — get a callable that invokes the worker's `performAction` handler
* - `useHostContext()` — read the current active company, project, entity, and user IDs
* - `usePluginStream(channel)` — subscribe to real-time SSE events from the worker
*/
export { usePluginData, usePluginAction, useHostContext, usePluginStream, usePluginToast, } from "./hooks.js";
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;GAOG;AACH,OAAO,EACL,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC"}

View File

@@ -0,0 +1,3 @@
export declare function getSdkUiRuntimeValue<T>(name: string): T;
export declare function renderSdkUiComponent<TProps>(name: string, props: TProps): unknown;
//# sourceMappingURL=runtime.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/ui/runtime.ts"],"names":[],"mappings":"AAsBA,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAMvD;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EACzC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAiBT"}

View File

@@ -0,0 +1,30 @@
function getBridgeRegistry() {
return globalThis.__paperclipPluginBridge__;
}
function missingBridgeValueError(name) {
return new Error(`Paperclip plugin UI runtime is not initialized for "${name}". ` +
'Ensure the host loaded the plugin bridge before rendering this UI module.');
}
export function getSdkUiRuntimeValue(name) {
const value = getBridgeRegistry()?.sdkUi?.[name];
if (value === undefined) {
throw missingBridgeValueError(name);
}
return value;
}
export function renderSdkUiComponent(name, props) {
const registry = getBridgeRegistry();
const component = registry?.sdkUi?.[name];
if (component === undefined) {
throw missingBridgeValueError(name);
}
const createElement = registry?.react?.createElement;
if (typeof createElement === "function") {
return createElement(component, props);
}
if (typeof component === "function") {
return component(props);
}
throw new Error(`Paperclip plugin UI component "${name}" is not callable`);
}
//# sourceMappingURL=runtime.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/ui/runtime.ts"],"names":[],"mappings":"AAWA,SAAS,iBAAiB;IACxB,OAAQ,UAA2B,CAAC,yBAAyB,CAAC;AAChE,CAAC;AAED,SAAS,uBAAuB,CAAC,IAAY;IAC3C,OAAO,IAAI,KAAK,CACd,uDAAuD,IAAI,KAAK;QAC9D,2EAA2E,CAC9E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAI,IAAY;IAClD,MAAM,KAAK,GAAG,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,KAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,KAAa;IAEb,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IACrC,MAAM,SAAS,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,aAAa,GAAG,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC;IACrD,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;QACxC,OAAO,aAAa,CAAC,SAAS,EAAE,KAAgC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;QACpC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,mBAAmB,CAAC,CAAC;AAC7E,CAAC"}

308
node_modules/@paperclipai/plugin-sdk/dist/ui/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,308 @@
/**
* Paperclip plugin UI SDK — types for plugin frontend components.
*
* Plugin UI bundles import from `@paperclipai/plugin-sdk/ui`. This subpath
* provides the bridge hooks, component prop interfaces, and error types that
* plugin React components use to communicate with the host.
*
* Plugin UI bundles are loaded as ES modules into designated extension slots.
* All communication with the plugin worker goes through the host bridge — plugin
* components must NOT access host internals or call host APIs directly.
*
* @see PLUGIN_SPEC.md §19 — UI Extension Model
* @see PLUGIN_SPEC.md §19.0.1 — Plugin UI SDK
* @see PLUGIN_SPEC.md §29.2 — SDK Versioning
*/
import type { PluginBridgeErrorCode } from "@paperclipai/shared";
import type { PluginLauncherRenderContextSnapshot, PluginModalBoundsRequest, PluginRenderCloseEvent } from "../protocol.js";
export type { PluginBridgeErrorCode, PluginLauncherBounds, PluginLauncherRenderEnvironment, } from "@paperclipai/shared";
export type { PluginLauncherRenderContextSnapshot, PluginModalBoundsRequest, PluginRenderCloseEvent, } from "../protocol.js";
/**
* Structured error returned by the bridge when a UI → worker call fails.
*
* Plugin components receive this in `usePluginData()` as the `error` field
* and may encounter it as a thrown value from `usePluginAction()`.
*
* Error codes:
* - `WORKER_UNAVAILABLE` — plugin worker is not running
* - `CAPABILITY_DENIED` — plugin lacks the required capability
* - `WORKER_ERROR` — worker returned an error from its handler
* - `TIMEOUT` — worker did not respond within the configured timeout
* - `UNKNOWN` — unexpected bridge-level failure
*
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*/
export interface PluginBridgeError {
/** Machine-readable error code. */
code: PluginBridgeErrorCode;
/** Human-readable error message. */
message: string;
/**
* Original error details from the worker, if available.
* Only present when `code === "WORKER_ERROR"`.
*/
details?: unknown;
}
/**
* Read-only host context passed to every plugin component via `useHostContext()`.
*
* Plugin components use this to know which company, project, or entity is
* currently active so they can scope their data requests accordingly.
*
* @see PLUGIN_SPEC.md §19 — UI Extension Model
*/
export interface PluginHostContext {
/** UUID of the currently active company, if any. */
companyId: string | null;
/** URL prefix for the current company (e.g. `"my-company"`). */
companyPrefix: string | null;
/** UUID of the currently active project, if any. */
projectId: string | null;
/** UUID of the current entity (for detail tab contexts), if any. */
entityId: string | null;
/** Type of the current entity (e.g. `"issue"`, `"agent"`). */
entityType: string | null;
/**
* UUID of the parent entity when rendering nested slots.
* For `commentAnnotation` slots this is the issue ID containing the comment.
*/
parentEntityId?: string | null;
/** UUID of the current authenticated user. */
userId: string | null;
/** Runtime metadata for the host container currently rendering this plugin UI. */
renderEnvironment?: PluginRenderEnvironmentContext | null;
}
/**
* Async-capable callback invoked during a host-managed close lifecycle.
*/
export type PluginRenderCloseHandler = (event: PluginRenderCloseEvent) => void | Promise<void>;
/**
* Close lifecycle hooks available when the plugin UI is rendered inside a
* host-managed launcher environment.
*/
export interface PluginRenderCloseLifecycle {
/** Register a callback before the host closes the current environment. */
onBeforeClose?(handler: PluginRenderCloseHandler): () => void;
/** Register a callback after the host closes the current environment. */
onClose?(handler: PluginRenderCloseHandler): () => void;
}
/**
* Runtime information about the host container currently rendering a plugin UI.
*/
export interface PluginRenderEnvironmentContext extends PluginLauncherRenderContextSnapshot {
/** Optional host callback for requesting new bounds while a modal is open. */
requestModalBounds?(request: PluginModalBoundsRequest): Promise<void>;
/** Optional close lifecycle callbacks for host-managed overlays. */
closeLifecycle?: PluginRenderCloseLifecycle | null;
}
/**
* Props passed to a plugin page component.
*
* A page is a full-page extension at `/plugins/:pluginId` or `/:company/plugins/:pluginId`.
*
* @see PLUGIN_SPEC.md §19.1 — Global Operator Routes
* @see PLUGIN_SPEC.md §19.2 — Company-Context Routes
*/
export interface PluginPageProps {
/** The current host context. */
context: PluginHostContext;
}
/**
* Props passed to a plugin dashboard widget component.
*
* A dashboard widget is rendered as a card or section on the main dashboard.
*
* @see PLUGIN_SPEC.md §19.4 — Dashboard Widgets
*/
export interface PluginWidgetProps {
/** The current host context. */
context: PluginHostContext;
}
/**
* Props passed to a plugin detail tab component.
*
* A detail tab is rendered as an additional tab on a project, issue, agent,
* goal, or run detail page.
*
* @see PLUGIN_SPEC.md §19.3 — Detail Tabs
*/
export interface PluginDetailTabProps {
/** The current host context, always including `entityId` and `entityType`. */
context: PluginHostContext & {
entityId: string;
entityType: string;
};
}
/**
* Props passed to a plugin sidebar component.
*
* A sidebar entry adds a link or section to the application sidebar.
*
* @see PLUGIN_SPEC.md §19.5 — Sidebar Entries
*/
export interface PluginSidebarProps {
/** The current host context. */
context: PluginHostContext;
}
/**
* Props passed to a plugin project sidebar item component.
*
* A project sidebar item is rendered **once per project** under that project's
* row in the sidebar Projects list. The host passes the current project's id
* in `context.entityId` and `context.entityType` is `"project"`.
*
* Use this slot to add a link (e.g. "Files", "Linear Sync") that navigates to
* the project detail with a plugin tab selected: `/projects/:projectRef?tab=plugin:key:slotId`.
*
* @see PLUGIN_SPEC.md §19.5.1 — Project sidebar items
*/
export interface PluginProjectSidebarItemProps {
/** Host context plus entityId (project id) and entityType "project". */
context: PluginHostContext & {
entityId: string;
entityType: "project";
};
}
/**
* Props passed to a plugin comment annotation component.
*
* A comment annotation is rendered below each individual comment in the
* issue detail timeline. The host passes the comment ID as `entityId`
* and `"comment"` as `entityType`, plus the parent issue ID as
* `parentEntityId` so the plugin can scope data fetches to both.
*
* Use this slot to augment comments with parsed file links, sentiment
* badges, inline actions, or any per-comment metadata.
*
* @see PLUGIN_SPEC.md §19.6 — Comment Annotations
*/
export interface PluginCommentAnnotationProps {
/** Host context with comment and parent issue identifiers. */
context: PluginHostContext & {
/** UUID of the comment being annotated. */
entityId: string;
/** Always `"comment"` for comment annotation slots. */
entityType: "comment";
/** UUID of the parent issue containing this comment. */
parentEntityId: string;
};
}
/**
* Props passed to a plugin comment context menu item component.
*
* A comment context menu item is rendered in a "more" dropdown menu on
* each comment in the issue detail timeline. The host passes the comment
* ID as `entityId` and `"comment"` as `entityType`, plus the parent
* issue ID as `parentEntityId`.
*
* Use this slot to add per-comment actions such as "Create sub-issue from
* comment", "Translate", "Flag for review", or any custom plugin action.
*
* @see PLUGIN_SPEC.md §19.7 — Comment Context Menu Items
*/
export interface PluginCommentContextMenuItemProps {
/** Host context with comment and parent issue identifiers. */
context: PluginHostContext & {
/** UUID of the comment this menu item acts on. */
entityId: string;
/** Always `"comment"` for comment context menu item slots. */
entityType: "comment";
/** UUID of the parent issue containing this comment. */
parentEntityId: string;
};
}
/**
* Props passed to a plugin settings page component.
*
* Overrides the auto-generated JSON Schema form when the plugin declares
* a `settingsPage` UI slot. The component is responsible for reading and
* writing config through the bridge.
*
* @see PLUGIN_SPEC.md §19.8 — Plugin Settings UI
*/
export interface PluginSettingsPageProps {
/** The current host context. */
context: PluginHostContext;
}
/**
* Return value of `usePluginData(key, params)`.
*
* Mirrors a standard async data-fetching hook pattern:
* exactly one of `data` or `error` is non-null at any time (unless `loading`).
*
* @template T The type of the data returned by the worker handler
*
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*/
export interface PluginDataResult<T = unknown> {
/** The data returned by the worker's `getData` handler. `null` while loading or on error. */
data: T | null;
/** `true` while the initial request or a refresh is in flight. */
loading: boolean;
/** Bridge error if the request failed. `null` on success or while loading. */
error: PluginBridgeError | null;
/**
* Manually trigger a data refresh.
* Useful for poll-based updates or post-action refreshes.
*/
refresh(): void;
}
export type PluginToastTone = "info" | "success" | "warn" | "error";
export interface PluginToastAction {
label: string;
href: string;
}
export interface PluginToastInput {
id?: string;
dedupeKey?: string;
title: string;
body?: string;
tone?: PluginToastTone;
ttlMs?: number;
action?: PluginToastAction;
}
export type PluginToastFn = (input: PluginToastInput) => string | null;
/**
* Return value of `usePluginStream<T>(channel)`.
*
* Provides a growing array of events pushed from the plugin worker via SSE,
* plus connection status metadata.
*
* @template T The type of each event emitted by the worker
*
* @see PLUGIN_SPEC.md §19.8 — Real-Time Streaming
*/
export interface PluginStreamResult<T = unknown> {
/** All events received so far, in arrival order. */
events: T[];
/** The most recently received event, or `null` if none yet. */
lastEvent: T | null;
/** `true` while the SSE connection is being established. */
connecting: boolean;
/** `true` once the SSE connection is open and receiving events. */
connected: boolean;
/** Error if the SSE connection failed or was interrupted. `null` otherwise. */
error: Error | null;
/** Close the SSE connection and stop receiving events. */
close(): void;
}
/**
* Return value of `usePluginAction(key)`.
*
* Returns an async function that, when called, sends an action request
* to the worker's `performAction` handler and returns the result.
*
* On failure, the async function throws a `PluginBridgeError`.
*
* @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
*
* @example
* ```tsx
* const resync = usePluginAction("resync");
* <button onClick={() => resync({ companyId }).catch(err => console.error(err))}>
* Resync Now
* </button>
* ```
*/
export type PluginActionFn = (params?: Record<string, unknown>) => Promise<unknown>;
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ui/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,qBAAqB,EAGtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,mCAAmC,EACnC,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,mCAAmC,EACnC,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAMxB;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD;;;;;;;GAOG;AACH,MAA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file
View File

@@ -0,0 +1,17 @@
/**
* Paperclip plugin UI SDK — types for plugin frontend components.
*
* Plugin UI bundles import from `@paperclipai/plugin-sdk/ui`. This subpath
* provides the bridge hooks, component prop interfaces, and error types that
* plugin React components use to communicate with the host.
*
* Plugin UI bundles are loaded as ES modules into designated extension slots.
* All communication with the plugin worker goes through the host bridge — plugin
* components must NOT access host internals or call host APIs directly.
*
* @see PLUGIN_SPEC.md §19 — UI Extension Model
* @see PLUGIN_SPEC.md §19.0.1 — Plugin UI SDK
* @see PLUGIN_SPEC.md §29.2 — SDK Versioning
*/
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ui/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}