openclaw-grafana-lens
Version:
OpenClaw plugin that gives AI agents full Grafana access — 18 composable tools for PromQL/LogQL/TraceQL queries, dashboard creation, alerting, SRE investigation, security monitoring, data collection pipeline management via Grafana Alloy (29 recipes), and
101 lines (100 loc) • 3.04 kB
TypeScript
/**
* grafana_share_dashboard tool
*
* Renders dashboard panels as PNG images and delivers them via the MEDIA:
* pattern so they appear inline in the user's messaging channel.
*
* Three-tier fallback: render PNG → snapshot URL → deep link.
* This ensures the user always gets *something*, even if the Grafana
* Image Renderer plugin isn't installed.
*
* imageResult() is NOT exported from plugin-sdk — we construct the
* AgentToolResult manually with both text (MEDIA: prefix) and image content.
*/
import { GrafanaClientRegistry } from "../grafana-client-registry.js";
/**
* Extract width/height from a PNG IHDR chunk (bytes 16-23, big-endian).
* Returns null if the buffer is too small or not a valid PNG.
*/
export declare function getPNGDimensions(buffer: ArrayBuffer): {
width: number;
height: number;
} | null;
export type RenderFailureInfo = {
rendererAvailable: boolean;
renderFailureReason: string;
remediation?: string;
};
/**
* Classify a render error into actionable information for the agent.
* Infers renderer availability from the error type — 502 means the
* Image Renderer plugin is missing; other errors mean the renderer
* exists but something else went wrong.
*/
export declare function classifyRenderFailure(err: unknown): RenderFailureInfo;
export declare function createShareDashboardToolFactory(registry: GrafanaClientRegistry): (_ctx: unknown) => {
name: string;
label: string;
description: string;
parameters: {
type: "object";
properties: {
dashboardUid: {
type: string;
description: string;
};
panelId: {
type: string;
description: string;
};
from: {
type: string;
description: string;
};
to: {
type: string;
description: string;
};
width: {
type: string;
description: string;
};
height: {
type: string;
description: string;
};
theme: {
type: string;
enum: string[];
description: string;
};
};
required: string[];
};
execute(_toolCallId: string, params: Record<string, unknown>): Promise<{
content: Array<{
type: "text";
text: string;
}>;
details: unknown;
} | {
content: ({
type: "text";
text: string;
data?: undefined;
mimeType?: undefined;
} | {
type: "image";
data: string;
mimeType: string;
text?: undefined;
})[];
details: {
dashboardUid: string;
panelId: number;
path: string;
deliveryTier: "image";
rendererAvailable: boolean;
};
}>;
};