🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(api): widget creation via MCP and API (#14750)
Nimarf73fd2575fb7
diff --git a/fern/apis/server/definition/unstable/dashboard-widgets.yml b/fern/apis/server/definition/unstable/dashboard-widgets.ymlnew file mode 100644index 0000000000..8a175b257d--- /dev/null+++ b/fern/apis/server/definition/unstable/dashboard-widgets.yml@@ -0,0 +1,212 @@+# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json+imports:+ errors: ./errors.yml++service:+ auth: true+ base-path: /api/public/unstable+ endpoints:+ create:+ docs: |+ Create a reusable dashboard widget.++ This endpoint creates the widget. It does not place the widget on a dashboard grid, this has to be done in the UI.++ Supported views are `observations`, `scores-numeric`, and `scores-categorical`.+ The legacy `traces` view is not supported by this unstable API, `minVersion` defaults to `2`; values below `2` are rejected.++ Unstable API note:+ - This surface may evolve while dashboard/widget APIs are being finalized.+ method: POST+ path: /dashboard-widgets+ request: CreateDashboardWidgetRequest+ response: DashboardWidget+ errors:+ - errors.BadRequestError+ - errors.UnauthorizedError+ - errors.AccessDeniedError+ - errors.MethodNotAllowedError+ - errors.TooManyRequestsError+ - errors.InternalServerError+ examples:+ - name: CreateCostWidget+ request:+ name: Total cost by model+ description: Total model cost grouped by provided model name.+ view: observations+ dimensions:+ - field: providedModelName+ metrics:+ - measure: totalCost+ agg: sum+ filters: []+ chartType: HORIZONTAL_BAR+ chartConfig:+ type: HORIZONTAL_BAR+ row_limit: 10+ minVersion: 2+ response:+ body:+ id: cm_dashboard_widget_123+ createdAt: "2026-07-03T09:00:00.000Z"+ updatedAt: "2026-07-03T09:00:00.000Z"+ name: Total cost by model+ description: Total model cost grouped by provided model name.+ view: observations+ dimensions:+ - field: providedModelName+ metrics:+ - measure: totalCost+ agg: sum+ filters: []+ chartType: HORIZONTAL_BAR+ chartConfig:+ type: HORIZONTAL_BAR+ row_limit: 10+ minVersion: 2++types:+ DashboardWidgetView:+ enum:+ - observations+ - name: ScoresNumeric+ value: scores-numeric+ - name: ScoresCategorical+ value: scores-categorical++ DashboardWidgetChartType:+ enum:+ - LINE_TIME_SERIES+ - AREA_TIME_SERIES+ - BAR_TIME_SERIES+ - HORIZONTAL_BAR+ - VERTICAL_BAR+ - PIE+ - NUMBER+ - HISTOGRAM+ - PIVOT_TABLE++ DashboardWidgetMetricAggregation:+ enum:+ - sum+ - avg+ - count+ - max+ - min+ - p50+ - p75+ - p90+ - p95+ - p99+ - histogram+ - uniq++ DashboardWidgetDimension:+ properties:+ field:+ type: string++ DashboardWidgetMetric:+ properties:+ measure:+ type: string+ agg:+ type: DashboardWidgetMetricAggregation++ DashboardWidgetFilter:+ docs: |+ A dashboard widget filter in Langfuse filter-state shape.++ Filter shapes depend on `type`, for example string filters use a string `value`,+ option filters use a list of strings, and object filters include `key`.+ properties:+ column:+ type: string+ operator:+ type: string+ type:+ type: string+ value:+ type: optional<unknown>+ key:+ type: optional<string>++ DashboardWidgetChartConfig:+ docs: |+ Chart-specific widget configuration.++ `type` must match the top-level `chartType`.+ `row_limit` applies to total-value charts and pivot tables.+ `bins` applies to histograms.+ `defaultSort` applies to pivot tables.+ properties:+ type:+ type: DashboardWidgetChartType+ row_limit:+ type: optional<integer>+ show_value_labels:+ type: optional<boolean>+ bins:+ type: optional<integer>+ defaultSort:+ type: optional<DashboardWidgetDefaultSort>++ DashboardWidgetDefaultSort:+ properties:+ column:+ type: string+ order:+ type: DashboardWidgetSortOrder++ DashboardWidgetSortOrder:+ enum:+ - ASC+ - DESC++ CreateDashboardWidgetRequest:+ properties:+ name:+ type: string+ description:+ type: string+ view:+ type: DashboardWidgetView+ dimensions:+ type: list<DashboardWidgetDimension>+ metrics:+ type: list<DashboardWidgetMetric>+ filters:+ type: list<DashboardWidgetFilter>+ chartType:+ type: DashboardWidgetChartType+ chartConfig:+ type: DashboardWidgetChartConfig+ minVersion:+ type: optional<integer>++ DashboardWidget:+ properties:+ id:+ type: string+ createdAt:+ type: datetime+ updatedAt:+ type: datetime+ name:+ type: string+ description:+ type: string+ view:+ type: DashboardWidgetView+ dimensions:+ type: list<DashboardWidgetDimension>+ metrics:+ type: list<DashboardWidgetMetric>+ filters:+ type: list<DashboardWidgetFilter>+ chartType:+ type: DashboardWidgetChartType+ chartConfig:+ type: DashboardWidgetChartConfig+ minVersion:+ type: integerdiff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.ymlindex d9b65253e0..94548cfcd1 100644--- a/web/public/generated/api/openapi.yml+++ b/web/public/generated/api/openapi.yml@@ -6274,6 +6274,82 @@ paths:description: List of trace IDs to deleterequired:- traceIds+ /api/public/unstable/dashboard-widgets:+ post:+ description: >-+ Create a reusable dashboard widget.+++ This endpoint creates the widget. It does not place the widget on a+ dashboard grid, this has to be done in the UI.+++ Supported views are `observations`, `scores-numeric`, and+ `scores-categorical`.++ The legacy `traces` view is not supported by this unstable API,+ `minVersion` defaults to `2`; values below `2` are rejected.+++ Unstable API note:++ - This surface may evolve while dashboard/widget APIs are being+ finalized.+ operationId: unstable_dashboardWidgets_create+ tags:+ - UnstableDashboardWidgets+ parameters: []+ responses:+ '200':+ description: ''+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/unstableDashboardWidget'+ '400':+ description: ''+ content:+ application/json:+ schema: {}+ '401':+ description: ''+ content:+ application/json:+ schema: {}+ '403':+ description: ''+ content:+ application/json:+ schema: {}+ '404':+ description: ''+ content:+ application/json:+ schema: {}+ '405':+ description: ''+ content:+ application/json:+ schema: {}+ '429':+ description: ''+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/unstablePublicApiError'+ '500':+ description: ''+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/unstablePublicApiError'+ security: *ref_0+ requestBody:+ required: true+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/unstableCreateDashboardWidgetRequest'/api/public/unstable/evaluation-rules:post:description: >-@@ -8891,6 +8967,13 @@ components:updatedAt:type: stringformat: date-time+ mediaReferences:+ type: array+ items:+ $ref: '#/components/schemas/DatasetItemMediaReference'+ description: >-+ Resolved Langfuse media references found in input, expectedOutput,+ and metadata.required:- id- status@@ -8903,6 +8986,64 @@ components:- datasetName- createdAt- updatedAt+ - mediaReferences+ DatasetItemMediaReference:+ title: DatasetItemMediaReference+ type: object+ properties:+ field:+ $ref: '#/components/schemas/DatasetItemMediaReferenceField'+ description: The dataset item field containing the reference+ referenceString:+ type: string+ description: >-+ The Langfuse media reference string, e.g.+ `@@@langfuseMedia:type=image/png|id=...|source=bytes@@@`+ jsonPath:+ type: string+ description: >-+ JSONPath of the string holding the reference within the field, e.g.+ `$['image']`+ media:+ $ref: '#/components/schemas/DatasetItemMediaReferenceMedia'+ description: The resolved media record.+ required:+ - field+ - referenceString+ - jsonPath+ - media+ DatasetItemMediaReferenceField:+ title: DatasetItemMediaReferenceField+ type: string+ enum:+ - input+ - expectedOutput+ - metadata+ DatasetItemMediaReferenceMedia:+ title: DatasetItemMediaReferenceMedia+ type: object+ properties:+ mediaId:+ type: string+ description: The unique langfuse identifier of the media record+ contentType:+ type: string+ description: The MIME type of the media record+ contentLength:+ type: integer+ description: The size of the media record in bytes+ url:+ type: string+ description: The signed download URL of the media record+ urlExpiry:+ type: string+ description: The expiry date and time of the download URL+ required:+ - mediaId+ - contentType+ - contentLength+ - url+ - urlExpiryDatasetRunItem:title: DatasetRunItemtype: object@@ -10743,16 +10884,35 @@ components:GetMediaUploadUrlRequest:title: GetMediaUploadUrlRequesttype: object+ description: >-+ Request a presigned media upload URL. Provide exactly one context: a+ trace (traceId, optionally observationId) or a dataset item (datasetId ++ datasetItemId). field is required and must match the chosen context.properties:traceId:type: string- description: The trace ID associated with the media record+ nullable: true+ description: >-+ The trace the media is associated with. Null for dataset item media+ uploads.observationId:type: stringnullable: truedescription: >-The observation ID associated with the media record. If the mediarecord is associated directly with a trace, this will be null.+ datasetId:+ type: string+ nullable: true+ description: >-+ The dataset the media belongs to. Null for trace/observation media+ uploads.+ datasetItemId:+ type: string+ nullable: true+ description: >-+ The dataset item the media is associated with (need not exist yet).+ Null for trace/observation media uploads.contentType:$ref: '#/components/schemas/MediaContentType'contentLength:@@ -10764,10 +10924,9 @@ components:field:type: stringdescription: >-- The trace / observation field the media record is associated with.- This can be one of `input`, `output`, `metadata`+ The item field the media is in: `input`/`output`/`metadata` (trace)+ or `input`/`expectedOutput`/`metadata` (dataset item).required:- - traceId- contentType- contentLength- sha256Hash@@ -13411,6 +13570,219 @@ components:- `invalid_filter_value` for `column=datasetId`: call `GET/api/public/v2/datasets`, then retry with dataset `id` values from thatresponse.+ unstableDashboardWidgetView:+ title: unstableDashboardWidgetView+ type: string+ enum:+ - observations+ - scores-numeric+ - scores-categorical+ unstableDashboardWidgetChartType:+ title: unstableDashboardWidgetChartType+ type: string+ enum:+ - LINE_TIME_SERIES+ - AREA_TIME_SERIES+ - BAR_TIME_SERIES+ - HORIZONTAL_BAR+ - VERTICAL_BAR+ - PIE+ - NUMBER+ - HISTOGRAM+ - PIVOT_TABLE+ unstableDashboardWidgetMetricAggregation:+ title: unstableDashboardWidgetMetricAggregation+ type: string+ enum:+ - sum+ - avg+ - count+ - max+ - min+ - p50+ - p75+ - p90+ - p95+ - p99+ - histogram+ - uniq+ unstableDashboardWidgetDimension:+ title: unstableDashboardWidgetDimension+ type: object+ properties:+ field:+ type: string+ required:+ - field+ unstableDashboardWidgetMetric:+ title: unstableDashboardWidgetMetric+ type: object+ properties:+ measure:+ type: string+ agg:+ $ref: '#/components/schemas/unstableDashboardWidgetMetricAggregation'+ required:+ - measure+ - agg+ unstableDashboardWidgetFilter:+ title: unstableDashboardWidgetFilter+ type: object+ description: >-+ A dashboard widget filter in Langfuse filter-state shape.+++ Filter shapes depend on `type`, for example string filters use a string+ `value`,++ option filters use a list of strings, and object filters include `key`.+ properties:+ column:+ type: string+ operator:+ type: string+ type:+ type: string+ value:+ nullable: true+ key:+ type: string+ nullable: true+ required:+ - column+ - operator+ - type+ unstableDashboardWidgetChartConfig:+ title: unstableDashboardWidgetChartConfig+ type: object+ description: |-+ Chart-specific widget configuration.++ `type` must match the top-level `chartType`.+ `row_limit` applies to total-value charts and pivot tables.+ `bins` applies to histograms.+ `defaultSort` applies to pivot tables.+ properties:+ type:+ $ref: '#/components/schemas/unstableDashboardWidgetChartType'+ row_limit:+ type: integer+ nullable: true+ show_value_labels:+ type: boolean+ nullable: true+ bins:+ type: integer+ nullable: true+ defaultSort:+ $ref: '#/components/schemas/unstableDashboardWidgetDefaultSort'+ nullable: true+ required:+ - type+ unstableDashboardWidgetDefaultSort:+ title: unstableDashboardWidgetDefaultSort+ type: object+ properties:+ column:+ type: string+ order:+ $ref: '#/components/schemas/unstableDashboardWidgetSortOrder'+ required:+ - column+ - order+ unstableDashboardWidgetSortOrder:+ title: unstableDashboardWidgetSortOrder+ type: string+ enum:+ - ASC+ - DESC+ unstableCreateDashboardWidgetRequest:+ title: unstableCreateDashboardWidgetRequest+ type: object+ properties:+ name:+ type: string+ description:+ type: string+ view:+ $ref: '#/components/schemas/unstableDashboardWidgetView'+ dimensions:+ type: array+ items:+ $ref: '#/components/schemas/unstableDashboardWidgetDimension'+ metrics:+ type: array+ items:+ $ref: '#/components/schemas/unstableDashboardWidgetMetric'+ filters:+ type: array+ items:+ $ref: '#/components/schemas/unstableDashboardWidgetFilter'+ chartType:+ $ref: '#/components/schemas/unstableDashboardWidgetChartType'+ chartConfig:+ $ref: '#/components/schemas/unstableDashboardWidgetChartConfig'+ minVersion:+ type: integer+ nullable: true+ required:+ - name+ - description+ - view+ - dimensions+ - metrics+ - filters+ - chartType+ - chartConfig+ unstableDashboardWidget:+ title: unstableDashboardWidget+ type: object+ properties:+ id:+ type: string+ createdAt:+ type: string+ format: date-time+ updatedAt:+ type: string+ format: date-time+ name:+ type: string+ description:+ type: string+ view:+ $ref: '#/components/schemas/unstableDashboardWidgetView'+ dimensions:+ type: array+ items:+ $ref: '#/components/schemas/unstableDashboardWidgetDimension'+ metrics:+ type: array+ items:+ $ref: '#/components/schemas/unstableDashboardWidgetMetric'+ filters:+ type: array+ items:+ $ref: '#/components/schemas/unstableDashboardWidgetFilter'+ chartType:+ $ref: '#/components/schemas/unstableDashboardWidgetChartType'+ chartConfig:+ $ref: '#/components/schemas/unstableDashboardWidgetChartConfig'+ minVersion:+ type: integer+ required:+ - id+ - createdAt+ - updatedAt+ - name+ - description+ - view+ - dimensions+ - metrics+ - filters+ - chartType+ - chartConfig+ - minVersionunstablePublicApiErrorCode:title: unstablePublicApiErrorCodetype: stringdiff --git a/web/src/__tests__/server/in-app-agent-stream.servertest.ts b/web/src/__tests__/server/in-app-agent-stream.servertest.tsindex 545d75d028..b000faa150 100644--- a/web/src/__tests__/server/in-app-agent-stream.servertest.ts+++ b/web/src/__tests__/server/in-app-agent-stream.servertest.ts@@ -713,6 +713,18 @@ describe("createAgUiStream", () => {href: "/project/project-1/traces/trace-1",});+ await expect(+ redirectTool?.execute?.({+ label: "Open widget",+ destination: "dashboardWidget",+ params: { widgetId: "widget-1" },+ }),+ ).resolves.toEqual({+ type: "redirectAction",+ label: "Open widget",+ href: "/project/project-1/widgets/widget-1",+ });+expect(promptMocks.getPrompt).toHaveBeenCalledWith("in-app-agent-system-prompt",undefined,diff --git a/web/src/__tests__/server/mcp-public-api-tools.servertest.ts b/web/src/__tests__/server/mcp-public-api-tools.servertest.tsindex 9205792373..d762b165a7 100644--- a/web/src/__tests__/server/mcp-public-api-tools.servertest.ts+++ b/web/src/__tests__/server/mcp-public-api-tools.servertest.ts@@ -154,6 +154,7 @@ describe("MCP public API tools", () => {"listEvaluationRules","getEvaluationRule","createEvaluationRule",+ "createDashboardWidget","listDatasets","getHealth","listScores",@@ -189,6 +190,9 @@ describe("MCP public API tools", () => {await expect(toolRegistry.getEnabledTool("createModel", context),).resolves.toBeUndefined();+ await expect(+ toolRegistry.getEnabledTool("createDashboardWidget", context),+ ).resolves.toBeUndefined();});it("resolves only the overridden mutating tool for in-app agent keys", async () => {@@ -210,6 +214,22 @@ describe("MCP public API tools", () => {).resolves.toBeUndefined();});+ it("resolves the dashboard widget creation override for in-app agent keys", async () => {+ const context = mockServerContext({+ inAppAgent: {+ permissions: "single-tool-override",+ allowedToolName: "createDashboardWidget",+ },+ });++ await expect(+ toolRegistry.getEnabledTool("createDashboardWidget", context),+ ).resolves.toBeTruthy();+ await expect(+ toolRegistry.getEnabledTool("upsertDataset", context),+ ).resolves.toBeUndefined();+ });+it("marks destructive public API tools", async () => {const toolNames = await getToolNames();@@ -223,6 +243,7 @@ describe("MCP public API tools", () => {expect(destructiveToolNames).toEqual(["createChatPrompt",+ "createDashboardWidget","createEvaluationRule","upsertEvaluator","createScore",diff --git a/web/src/__tests__/server/mcp-tools-write.servertest.ts b/web/src/__tests__/server/mcp-tools-write.servertest.tsindex 3fc21b49d5..f715d4abe4 100644--- a/web/src/__tests__/server/mcp-tools-write.servertest.ts+++ b/web/src/__tests__/server/mcp-tools-write.servertest.ts@@ -81,6 +81,10 @@ import {handleDeleteEvaluator,} from "@/src/features/mcp/features/evals/tools/deleteEvaluator";import { handleGetEvaluationRule } from "@/src/features/mcp/features/evals/tools/getEvaluationRule";+import {+ createDashboardWidgetTool,+ handleCreateDashboardWidget,+} from "@/src/features/mcp/features/dashboardWidgets/tools/createDashboardWidget";const createScoreConfig = async (projectId: string) =>prisma.scoreConfig.create({@@ -416,6 +420,60 @@ describe("MCP Write Tools", () => {});});+ describe("createDashboardWidget tool", () => {+ it("should have destructiveHint annotation", () => {+ verifyToolAnnotations(createDashboardWidgetTool, {+ destructiveHint: true,+ });+ });++ it("should create a dashboard widget and audit the write", async () => {+ const setup = await createMcpTestSetup();+ const { projectId, apiKeyId } = setup;++ const result = (await handleCreateDashboardWidget(+ {+ name: `mcp-widget-${nanoid()}`,+ description: "Created by MCP",+ view: "observations",+ dimensions: [],+ metrics: [{ measure: "count", agg: "count" }],+ filters: [],+ chartType: "NUMBER",+ chartConfig: { type: "NUMBER" },+ minVersion: 2,+ },+ setup.context,+ )) as { id: string; name: string; url: string };++ expect(result).toMatchObject({+ id: expect.any(String),+ name: expect.stringContaining("mcp-widget-"),+ url: expect.stringContaining(`/project/${projectId}/widgets/`),+ });++ await expect(+ prisma.dashboardWidget.findFirst({+ where: { id: result.id, projectId },+ }),+ ).resolves.toMatchObject({+ id: result.id,+ projectId,+ view: "OBSERVATIONS",+ });++ await expect(+ verifyAuditLog({+ projectId,+ apiKeyId,+ resourceType: "dashboardWidget",+ resourceId: result.id,+ action: "create",+ }),+ ).resolves.toMatchObject({ resourceId: result.id, action: "create" });+ });+ });+describe("createTextPrompt tool", () => {it("should create a simple text prompt", async () => {const { context } = await createMcpTestSetup();diff --git a/web/src/__tests__/server/unstable-dashboard-widgets-api.servertest.ts b/web/src/__tests__/server/unstable-dashboard-widgets-api.servertest.tsnew file mode 100644index 0000000000..cf6ece15b4--- /dev/null+++ b/web/src/__tests__/server/unstable-dashboard-widgets-api.servertest.ts@@ -0,0 +1,202 @@+import {+ makeAPICall,+ makeZodVerifiedAPICall,+} from "@/src/__tests__/test-utils";+import { PostUnstableDashboardWidgetResponse } from "@/src/features/public-api/types/unstable-dashboard-widgets";+import { UnstablePublicApiErrorResponse } from "@/src/features/public-api/types/unstable-public-evals-contract";+import { prisma } from "@langfuse/shared/src/db";+import { createOrgProjectAndApiKey } from "@langfuse/shared/src/server";+import type { z } from "zod";++const baseWidgetBody = {+ name: "API widget",+ description: "Created via unstable API",+ view: "observations" as const,+ dimensions: [],+ metrics: [{ measure: "count", agg: "count" as const }],+ filters: [],+ chartType: "NUMBER" as const,+ chartConfig: { type: "NUMBER" as const },+ minVersion: 2,+};++const expectUnstableError = (+ response: Awaited<ReturnType<typeof makeAPICall>>,+ params: {+ status: number;+ code: z.infer<typeof UnstablePublicApiErrorResponse>["code"];+ },+) => {+ expect(response.status).toBe(params.status);+ const body = UnstablePublicApiErrorResponse.parse(response.body);+ expect(body.code).toBe(params.code);+ return body;+};++describe("/api/public/unstable/dashboard-widgets API", () => {+ it("creates a dashboard widget and writes an API-key audit log", async () => {+ const { auth, projectId } = await createOrgProjectAndApiKey();++ const response = await makeZodVerifiedAPICall(+ PostUnstableDashboardWidgetResponse,+ "POST",+ "/api/public/unstable/dashboard-widgets",+ baseWidgetBody,+ auth,+ );++ expect(response.body).toMatchObject({+ id: expect.any(String),+ name: "API widget",+ view: "observations",+ chartType: "NUMBER",+ minVersion: 2,+ });++ await expect(+ prisma.dashboardWidget.findFirst({+ where: { id: response.body.id, projectId },+ }),+ ).resolves.toMatchObject({+ id: response.body.id,+ projectId,+ name: "API widget",+ view: "OBSERVATIONS",+ });++ await expect(+ prisma.auditLog.findFirst({+ where: {+ projectId,+ resourceType: "dashboardWidget",+ resourceId: response.body.id,+ action: "create",+ },+ }),+ ).resolves.toMatchObject({+ resourceId: response.body.id,+ type: "API_KEY",+ });+ });++ it("defaults supported views to minVersion 2", async () => {+ const { auth } = await createOrgProjectAndApiKey();+ const { minVersion: _minVersion, ...bodyWithoutMinVersion } =+ baseWidgetBody;++ const response = await makeZodVerifiedAPICall(+ PostUnstableDashboardWidgetResponse,+ "POST",+ "/api/public/unstable/dashboard-widgets",+ bodyWithoutMinVersion,+ auth,+ );++ expect(response.body.minVersion).toBe(2);+ });++ it("rejects traces widgets", async () => {+ const { auth } = await createOrgProjectAndApiKey();++ const response = await makeAPICall(+ "POST",+ "/api/public/unstable/dashboard-widgets",+ {+ ...baseWidgetBody,+ view: "traces",+ minVersion: 2,+ },+ auth,+ );++ expectUnstableError(response, {+ status: 400,+ code: "invalid_body",+ });+ });++ it("rejects legacy minVersion values", async () => {+ const { auth } = await createOrgProjectAndApiKey();++ const response = await makeAPICall(+ "POST",+ "/api/public/unstable/dashboard-widgets",+ {+ ...baseWidgetBody,+ minVersion: 1,+ },+ auth,+ );++ expectUnstableError(response, {+ status: 400,+ code: "invalid_body",+ });+ });++ it("returns unstable invalid_body errors for malformed widget JSON", async () => {+ const { auth } = await createOrgProjectAndApiKey();++ const response = await makeAPICall(+ "POST",+ "/api/public/unstable/dashboard-widgets",+ {+ ...baseWidgetBody,+ chartConfig: { type: "LINE_TIME_SERIES" },+ },+ auth,+ );++ expectUnstableError(response, {+ status: 400,+ code: "invalid_body",+ });+ });++ it("returns unstable invalid_request errors for semantically invalid widgets", async () => {+ const { auth } = await createOrgProjectAndApiKey();++ const response = await makeAPICall(+ "POST",+ "/api/public/unstable/dashboard-widgets",+ {+ ...baseWidgetBody,+ metrics: [{ measure: "uniqueUserIds", agg: "avg" }],+ },+ auth,+ );++ const body = expectUnstableError(response, {+ status: 400,+ code: "invalid_request",+ });+ expect(body.details).toMatchObject({ field: "metrics[0].agg" });+ });++ it("rejects filter columns that widget JSON import would remove", async () => {+ const { auth } = await createOrgProjectAndApiKey();++ const response = await makeAPICall(+ "POST",+ "/api/public/unstable/dashboard-widgets",+ {+ ...baseWidgetBody,+ filters: [+ {+ type: "string",+ column: "notAWidgetFilterColumn",+ operator: "=",+ value: "value",+ },+ ],+ },+ auth,+ );++ const body = expectUnstableError(response, {+ status: 400,+ code: "invalid_request",+ });+ expect(body.details).toMatchObject({ field: "filters" });+ });+});diff --git a/web/src/ee/features/in-app-agent/server/tools.ts b/web/src/ee/features/in-app-agent/server/tools.tsindex 2239d986ae..57145ecdfc 100644--- a/web/src/ee/features/in-app-agent/server/tools.ts+++ b/web/src/ee/features/in-app-agent/server/tools.ts@@ -4,6 +4,7 @@ import { hasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { assertUnreachable } from "@/src/utils/types";import {buildDashboardsPath,+ buildDashboardWidgetPath,buildDatasetsPath,buildEvalsPath,buildExperimentsPath,@@ -292,6 +293,10 @@ export const IN_APP_AGENT_LANGFUSE_MCP_TOOL_POLICIES: Record<approval: "approval",availability: { scope: "scoreConfigs:CUD" },},+ createDashboardWidget: {+ approval: "approval",+ availability: { scope: "dashboards:CUD" },+ },};export const IN_APP_AGENT_LANGFUSE_MCP_TOOL_NAMES = new Set<McpToolName>(@@ -384,6 +389,7 @@ function isInAppAgentAutoApprovedToolName(toolName: string): boolean {}const InAppAgentRedirectDestinationSchema = z.enum([+ "dashboardWidget","dashboards","datasets","evals",@@ -488,6 +494,10 @@ const InAppAgentProjectSettingsPageSchema = z.enum([const InAppAgentRedirectToolInputStrictSchema = z.discriminatedUnion("destination",[+ InAppAgentRedirectBaseSchema.extend({+ destination: z.literal("dashboardWidget"),+ params: z.object({ widgetId: z.string().min(1).max(200) }),+ }),InAppAgentRedirectBaseSchema.extend({destination: z.literal("dashboards"),}),@@ -547,6 +557,7 @@ const InAppAgentRedirectParamsSchema = z.object({sessionId: z.string().min(1).max(200).optional(),timestamp: z.iso.datetime().optional(),traceId: z.string().min(1).max(200).optional(),+ widgetId: z.string().min(1).max(200).optional(),filters: InAppAgentTracingFiltersSchema.optional(),orderBy: InAppAgentTracesParamsSchema.shape.orderBy,search: InAppAgentTracesParamsSchema.shape.search,@@ -617,6 +628,13 @@ function getRedirectHref(projectId: string,isV4Enabled: boolean,): string {+ if (input.destination === "dashboardWidget") {+ return buildDashboardWidgetPath({+ projectId,+ widgetId: input.params.widgetId,+ });+ }+if (input.destination === "dashboards") {return buildDashboardsPath({ projectId });}diff --git a/web/src/features/audit-logs/auditLog.ts b/web/src/features/audit-logs/auditLog.tsindex dcda765c30..26e24e3d70 100644--- a/web/src/features/audit-logs/auditLog.ts+++ b/web/src/features/audit-logs/auditLog.ts@@ -42,6 +42,7 @@ export type AuditableResource =| "batchAction"| "automation"| "action"+ | "dashboardWidget"| "slackIntegration"| "cloudSpendAlert"| "verifiedDomain"diff --git a/web/src/features/mcp/features/dashboardWidgets/index.ts b/web/src/features/mcp/features/dashboardWidgets/index.tsnew file mode 100644index 0000000000..47f2ba0ca3--- /dev/null+++ b/web/src/features/mcp/features/dashboardWidgets/index.ts@@ -0,0 +1,16 @@+import type { McpFeatureModule } from "../../server/registry";+import {+ createDashboardWidgetTool,+ handleCreateDashboardWidget,+} from "./tools/createDashboardWidget";++export const dashboardWidgetsFeature = {+ name: "dashboardWidgets",+ description: "Manage dashboard widgets in the current Langfuse project",+ tools: [+ {+ definition: createDashboardWidgetTool,+ handler: handleCreateDashboardWidget,+ },+ ],+} as const satisfies McpFeatureModule;diff --git a/web/src/features/mcp/features/dashboardWidgets/tools/createDashboardWidget.ts b/web/src/features/mcp/features/dashboardWidgets/tools/createDashboardWidget.tsnew file mode 100644index 0000000000..b1bf4979f1--- /dev/null+++ b/web/src/features/mcp/features/dashboardWidgets/tools/createDashboardWidget.ts@@ -0,0 +1,111 @@+import { z } from "zod";+import { DashboardWidgetChartType } from "@langfuse/shared";+import { metricAggregations } from "@langfuse/shared/query";+import { defineTool } from "@/src/features/mcp/core/define-tool";+import { runMcpTool } from "@/src/features/mcp/core/run-mcp-tool";+import { createPublicDashboardWidget } from "@/src/features/widgets/server/public-dashboard-widget-service";+import {+ PostUnstableDashboardWidgetBody,+ PostUnstableDashboardWidgetView,+} from "@/src/features/public-api/types/unstable-dashboard-widgets";+import { buildDashboardWidgetUrl } from "@/src/utils/product-url";++const DashboardWidgetFilterBaseSchema = z+ .object({+ column: z.string(),+ operator: z.string(),+ type: z.string(),+ value: z.any().optional(),+ key: z.string().optional(),+ })+ .loose();++const DashboardWidgetChartConfigBaseSchema = z.object({+ type: z.enum(DashboardWidgetChartType),+ row_limit: z.number().int().positive().max(1000).optional(),+ show_value_labels: z.boolean().optional(),+ bins: z.number().int().min(1).max(100).optional(),+ defaultSort: z+ .object({+ column: z.string(),+ order: z.enum(["ASC", "DESC"]),+ })+ .optional(),+});++const CreateDashboardWidgetBaseSchema = z.object({+ name: z.string().min(1).describe("Human-readable widget name."),+ description: z.string().describe("Human-readable widget description."),+ view: PostUnstableDashboardWidgetView.describe(+ "Data view for the widget. Traces widgets are not supported by this unstable API.",+ ),+ dimensions: z+ .array(z.object({ field: z.string().min(1) }))+ .describe(+ "Breakdown dimensions. Non-pivot charts support at most one dimension.",+ ),+ metrics: z+ .array(+ z.object({+ measure: z.string().min(1),+ agg: metricAggregations,+ }),+ )+ .min(1)+ .describe("Measures and aggregations to plot."),+ filters: z+ .array(DashboardWidgetFilterBaseSchema)+ .describe(+ "Widget filters in the same shape as exported dashboard widget JSON.",+ ),+ chartType: z.enum(DashboardWidgetChartType),+ chartConfig: DashboardWidgetChartConfigBaseSchema.describe(+ "Chart-specific config. chartConfig.type must match chartType.",+ ),+ minVersion: z+ .number()+ .int()+ .min(2)+ .optional()+ .describe("Widget data-model version. Defaults to 2."),+});++export const [createDashboardWidgetTool, handleCreateDashboardWidget] =+ defineTool({+ name: "createDashboardWidget",+ description: [+ "Create a reusable dashboard widget.",+ "Widgets are useful to visualize Langfuse project data and give informative breakdowns to the user.",+ "This creates the widget only; placing it on a dashboard requires updating that dashboard's definition in the Langfuse UI.",+ "The result includes a url field; use it to link to the created widget.",+ ].join(" "),+ baseSchema: CreateDashboardWidgetBaseSchema,+ inputSchema: PostUnstableDashboardWidgetBody,+ destructiveHint: true,+ handler: async (input, context) =>+ runMcpTool({+ spanName: "mcp.dashboard_widgets.create",+ context,+ attributes: {+ "mcp.dashboard_widget_name": input.name,+ "mcp.dashboard_widget_view": input.view,+ },+ fn: async (span) => {+ const widget = await createPublicDashboardWidget({+ projectId: context.projectId,+ input,+ auditScope: context,+ });++ span.setAttribute("mcp.dashboard_widget_id", widget.id);++ return {+ ...widget,+ url: buildDashboardWidgetUrl({+ projectId: context.projectId,+ widgetId: widget.id,+ }),+ };+ },+ }),+ });diff --git a/web/src/features/mcp/server/bootstrap.ts b/web/src/features/mcp/server/bootstrap.tsindex b8da0c2c41..b7d7716b34 100644--- a/web/src/features/mcp/server/bootstrap.ts+++ b/web/src/features/mcp/server/bootstrap.ts@@ -23,6 +23,7 @@ import { metricsFeature } from "../features/metrics";import { modelsFeature } from "../features/models";import { mediaFeature } from "../features/media";import { evalsFeature } from "../features/evals";+import { dashboardWidgetsFeature } from "../features/dashboardWidgets";const MCP_FEATURES = [promptsFeature,@@ -36,6 +37,7 @@ const MCP_FEATURES = [modelsFeature,mediaFeature,evalsFeature,+ dashboardWidgetsFeature,] as const satisfies readonly McpFeatureModule[];export type McpFeature = (typeof MCP_FEATURES)[number];diff --git a/web/src/features/public-api/server/unstable-public-evals-route.ts b/web/src/features/public-api/server/unstable-public-api-route.tssimilarity index 78%rename from web/src/features/public-api/server/unstable-public-evals-route.tsrename to web/src/features/public-api/server/unstable-public-api-route.tsindex 6a232ebe7f..659c7fd324 100644--- a/web/src/features/public-api/server/unstable-public-evals-route.ts+++ b/web/src/features/public-api/server/unstable-public-api-route.ts@@ -10,7 +10,7 @@ import {} from "@/src/features/public-api/server/withMiddlewares";import { unstablePublicEvalsErrorContract } from "@/src/features/public-api/server/unstable-public-api-error-contract";-type UnstablePublicEvalsRouteConfig<+type UnstablePublicApiRouteConfig<TQuery extends ZodType<any>,TBody extends ZodType<any>,TResponse extends ZodType<any>,@@ -19,27 +19,27 @@ type UnstablePublicEvalsRouteConfig<"errorContract">;-type UnstablePublicEvalsHandlers = {+type UnstablePublicApiHandlers = {[Method in HttpMethod]?: (req: NextApiRequest,res: NextApiResponse,) => Promise<void>;};-export const createUnstablePublicEvalsRoute = <+export const createUnstablePublicApiRoute = <TQuery extends ZodType<any>,TBody extends ZodType<any>,TResponse extends ZodType<any>,>(- routeConfig: UnstablePublicEvalsRouteConfig<TQuery, TBody, TResponse>,+ routeConfig: UnstablePublicApiRouteConfig<TQuery, TBody, TResponse>,) =>createAuthedProjectAPIRoute({...routeConfig,errorContract: unstablePublicEvalsErrorContract,});-export const withUnstablePublicEvalsMiddlewares = (- handlers: UnstablePublicEvalsHandlers,+export const withUnstablePublicApiMiddlewares = (+ handlers: UnstablePublicApiHandlers,) =>withMiddlewares(handlers, {errorContract: unstablePublicEvalsErrorContract,diff --git a/web/src/features/public-api/types/unstable-dashboard-widgets.ts b/web/src/features/public-api/types/unstable-dashboard-widgets.tsnew file mode 100644index 0000000000..eeaeaea696--- /dev/null+++ b/web/src/features/public-api/types/unstable-dashboard-widgets.ts@@ -0,0 +1,69 @@+import { z } from "zod";+import {+ ChartConfigSchema,+ DashboardWidgetChartType,+ DimensionSchema,+ MetricSchema,+ singleFilter,+} from "@langfuse/shared";+import { metricAggregations } from "@langfuse/shared/query";++export const PostUnstableDashboardWidgetView = z.enum([+ "observations",+ "scores-numeric",+ "scores-categorical",+]);++const DashboardWidgetMetricSchema = MetricSchema.extend({+ measure: z.string().min(1),+ agg: metricAggregations,+});++const DashboardWidgetDimensionSchema = DimensionSchema.extend({+ field: z.string().min(1),+});++export const PostUnstableDashboardWidgetBody = z+ .object({+ name: z.string().min(1, "Widget name is required"),+ description: z.string(),+ view: PostUnstableDashboardWidgetView,+ dimensions: z.array(DashboardWidgetDimensionSchema),+ metrics: z.array(DashboardWidgetMetricSchema).min(1),+ filters: z.array(singleFilter),+ chartType: z.enum(DashboardWidgetChartType),+ chartConfig: ChartConfigSchema,+ minVersion: z.number().int().min(2).optional(),+ })+ .superRefine((widget, ctx) => {+ if (widget.chartConfig.type !== widget.chartType) {+ ctx.addIssue({+ code: "custom",+ path: ["chartConfig", "type"],+ message: "chartConfig.type must match chartType",+ });+ }+ });++export const PublicDashboardWidget = z+ .object({+ id: z.string(),+ createdAt: z.coerce.date(),+ updatedAt: z.coerce.date(),+ name: z.string(),+ description: z.string(),+ view: PostUnstableDashboardWidgetView,+ dimensions: z.array(DashboardWidgetDimensionSchema),+ metrics: z.array(DashboardWidgetMetricSchema),+ filters: z.array(singleFilter),+ chartType: z.enum(DashboardWidgetChartType),+ chartConfig: ChartConfigSchema,+ minVersion: z.number().int().min(2),+ })+ .strict();++export const PostUnstableDashboardWidgetResponse = PublicDashboardWidget;++export type PostUnstableDashboardWidgetBodyType = z.infer<+ typeof PostUnstableDashboardWidgetBody+>;diff --git a/web/src/features/widgets/server/public-dashboard-widget-service.ts b/web/src/features/widgets/server/public-dashboard-widget-service.tsnew file mode 100644index 0000000000..690d24c966--- /dev/null+++ b/web/src/features/widgets/server/public-dashboard-widget-service.ts@@ -0,0 +1,250 @@+import type { z } from "zod";+import {+ DashboardWidgetChartType,+ DashboardWidgetViews,+} from "@langfuse/shared/src/db";+import {+ DashboardService,+ type WidgetDomain,+} from "@langfuse/shared/src/server";+import type { ApiAccessScope } from "@langfuse/shared/src/server";+import {+ getValidAggregationsForMeasureType,+ getViewDeclaration,+ type views,+ type ViewVersion,+} from "@langfuse/shared/query";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { createUnstablePublicApiError } from "@/src/features/public-api/server/unstable-public-api-error-contract";+import {+ PostUnstableDashboardWidgetResponse,+ type PostUnstableDashboardWidgetBodyType,+} from "@/src/features/public-api/types/unstable-dashboard-widgets";+import {+ getWidgetImportFilterConfig,+ partitionStoredUiTableFiltersToView,+} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";+import {+ MAX_PIVOT_TABLE_DIMENSIONS,+ MAX_PIVOT_TABLE_METRICS,+} from "@/src/features/widgets/utils/pivot-table-utils";++const viewMapping: Record<+ PostUnstableDashboardWidgetBodyType["view"],+ DashboardWidgetViews+> = {+ observations: DashboardWidgetViews.OBSERVATIONS,+ "scores-numeric": DashboardWidgetViews.SCORES_NUMERIC,+ "scores-categorical": DashboardWidgetViews.SCORES_CATEGORICAL,+};++const reverseViewMapping: Record<+ DashboardWidgetViews,+ z.infer<typeof views>+> = {+ [DashboardWidgetViews.TRACES]: "traces",+ [DashboardWidgetViews.OBSERVATIONS]: "observations",+ [DashboardWidgetViews.SCORES_NUMERIC]: "scores-numeric",+ [DashboardWidgetViews.SCORES_CATEGORICAL]: "scores-categorical",+};++const throwInvalidWidget = (params: {+ message: string;+ field?: string;+ allowedValues?: string[];+}): never => {+ throw createUnstablePublicApiError({+ httpCode: 400,+ code: "invalid_request",+ message: params.message,+ details:+ params.field || params.allowedValues+ ? {+ field: params.field,+ allowedValues: params.allowedValues,+ }+ : undefined,+ });+};++function getWidgetViewVersion(+ widget: PostUnstableDashboardWidgetBodyType,+): ViewVersion {+ return (widget.minVersion ?? 2) >= 2 ? "v2" : "v1";+}++function getPublicDashboardWidgetViewDeclaration(+ widget: PostUnstableDashboardWidgetBodyType,+): ReturnType<typeof getViewDeclaration> {+ const viewVersion = getWidgetViewVersion(widget);++ try {+ return getViewDeclaration(widget.view, viewVersion);+ } catch (error) {+ return throwInvalidWidget({+ message: error instanceof Error ? error.message : "Invalid widget view",+ field: "view",+ });+ }+}++export function normalizePublicDashboardWidgetInput(+ input: PostUnstableDashboardWidgetBodyType,+): PostUnstableDashboardWidgetBodyType {+ const { mappedFilters, unsupportedFilters } =+ partitionStoredUiTableFiltersToView(input.view, input.filters);+ const { allowedColumns, columnAliases } = getWidgetImportFilterConfig(+ input.view,+ );++ if (unsupportedFilters.length > 0) {+ throwInvalidWidget({+ message: `Unsupported filter column for view "${input.view}": ${unsupportedFilters.map((filter) => filter.column).join(", ")}`,+ field: "filters",+ });+ }++ const invalidFilterColumns = mappedFilters.flatMap((filter) => {+ const normalizedColumn = columnAliases[filter.column] ?? filter.column;+ return allowedColumns.has(normalizedColumn) ? [] : [filter.column];+ });++ if (invalidFilterColumns.length > 0) {+ throwInvalidWidget({+ message: `Unsupported filter column for view "${input.view}": ${invalidFilterColumns.join(", ")}`,+ field: "filters",+ });+ }++ return {+ ...input,+ filters: mappedFilters.map((filter) => ({+ ...filter,+ column: columnAliases[filter.column] ?? filter.column,+ })),+ minVersion: input.minVersion ?? 2,+ };+}++export function validatePublicDashboardWidgetInput(+ widget: PostUnstableDashboardWidgetBodyType,+): void {+ const viewVersion = getWidgetViewVersion(widget);+ const viewDeclaration = getPublicDashboardWidgetViewDeclaration(widget);++ for (const [index, dimension] of widget.dimensions.entries()) {+ const dimensionDefinition = viewDeclaration.dimensions[dimension.field];++ if (!dimensionDefinition) {+ throwInvalidWidget({+ message: `Dimension "${dimension.field}" is not available for view "${widget.view}" in version "${viewVersion}"`,+ field: `dimensions[${index}].field`,+ allowedValues: Object.keys(viewDeclaration.dimensions),+ });+ }++ if (dimensionDefinition.uiHidden) {+ throwInvalidWidget({+ message: `Dimension "${dimension.field}" is not available for widgets`,+ field: `dimensions[${index}].field`,+ });+ }+ }++ for (const [index, metric] of widget.metrics.entries()) {+ const measureDefinition = viewDeclaration.measures[metric.measure];++ if (!measureDefinition) {+ throwInvalidWidget({+ message: `Measure "${metric.measure}" is not available for view "${widget.view}" in version "${viewVersion}"`,+ field: `metrics[${index}].measure`,+ allowedValues: Object.keys(viewDeclaration.measures),+ });+ }++ const validAggregations = getValidAggregationsForMeasureType(+ measureDefinition.type,+ );++ if (!validAggregations.includes(metric.agg)) {+ throwInvalidWidget({+ message: `Aggregation "${metric.agg}" is not valid for measure "${metric.measure}"`,+ field: `metrics[${index}].agg`,+ allowedValues: validAggregations,+ });+ }+ }++ if (+ widget.chartType !== DashboardWidgetChartType.PIVOT_TABLE &&+ widget.dimensions.length > 1+ ) {+ throwInvalidWidget({+ message: "Only pivot table widgets can have multiple dimensions",+ field: "dimensions",+ });+ }++ if (+ widget.chartType === DashboardWidgetChartType.PIVOT_TABLE &&+ widget.dimensions.length > MAX_PIVOT_TABLE_DIMENSIONS+ ) {+ throwInvalidWidget({+ message: `Pivot table widgets can have at most ${MAX_PIVOT_TABLE_DIMENSIONS} dimensions`,+ field: "dimensions",+ });+ }++ if (+ widget.chartType === DashboardWidgetChartType.PIVOT_TABLE &&+ widget.metrics.length > MAX_PIVOT_TABLE_METRICS+ ) {+ throwInvalidWidget({+ message: `Pivot table widgets can have at most ${MAX_PIVOT_TABLE_METRICS} metrics`,+ field: "metrics",+ });+ }+}++export function toApiDashboardWidget(widget: WidgetDomain) {+ return PostUnstableDashboardWidgetResponse.parse({+ id: widget.id,+ createdAt: widget.createdAt,+ updatedAt: widget.updatedAt,+ name: widget.name,+ description: widget.description,+ view: reverseViewMapping[widget.view],+ dimensions: widget.dimensions,+ metrics: widget.metrics,+ filters: widget.filters,+ chartType: widget.chartType,+ chartConfig: widget.chartConfig,+ minVersion: widget.minVersion,+ });+}++export async function createPublicDashboardWidget(params: {+ projectId: string;+ input: PostUnstableDashboardWidgetBodyType;+ auditScope: Pick<ApiAccessScope, "orgId" | "apiKeyId">;+}) {+ const input = normalizePublicDashboardWidgetInput(params.input);+ validatePublicDashboardWidgetInput(input);++ const widget = await DashboardService.createWidget(params.projectId, {+ ...input,+ view: viewMapping[input.view],+ });++ await auditLog({+ action: "create",+ resourceType: "dashboardWidget",+ resourceId: widget.id,+ projectId: params.projectId,+ orgId: params.auditScope.orgId,+ apiKeyId: params.auditScope.apiKeyId,+ after: toApiDashboardWidget(widget),+ });++ return toApiDashboardWidget(widget);+}diff --git a/web/src/pages/api/public/unstable/dashboard-widgets/index.ts b/web/src/pages/api/public/unstable/dashboard-widgets/index.tsnew file mode 100644index 0000000000..4d9b887aa7--- /dev/null+++ b/web/src/pages/api/public/unstable/dashboard-widgets/index.ts@@ -0,0 +1,23 @@+import {+ createUnstablePublicApiRoute,+ withUnstablePublicApiMiddlewares,+} from "@/src/features/public-api/server/unstable-public-api-route";+import {+ PostUnstableDashboardWidgetBody,+ PostUnstableDashboardWidgetResponse,+} from "@/src/features/public-api/types/unstable-dashboard-widgets";+import { createPublicDashboardWidget } from "@/src/features/widgets/server/public-dashboard-widget-service";++export default withUnstablePublicApiMiddlewares({+ POST: createUnstablePublicApiRoute({+ name: "Create Unstable Dashboard Widget",+ bodySchema: PostUnstableDashboardWidgetBody,+ responseSchema: PostUnstableDashboardWidgetResponse,+ fn: async ({ body, auth }) =>+ createPublicDashboardWidget({+ projectId: auth.scope.projectId,+ input: body,+ auditScope: auth.scope,+ }),+ }),+});diff --git a/web/src/pages/api/public/unstable/evaluation-rules/[evaluationRuleId].ts b/web/src/pages/api/public/unstable/evaluation-rules/[evaluationRuleId].tsindex fa7c25d956..74f4c94951 100644--- a/web/src/pages/api/public/unstable/evaluation-rules/[evaluationRuleId].ts+++ b/web/src/pages/api/public/unstable/evaluation-rules/[evaluationRuleId].ts@@ -4,9 +4,9 @@ import {updatePublicEvaluationRule,} from "@/src/features/evals/server/unstable-public-api";import {- createUnstablePublicEvalsRoute,- withUnstablePublicEvalsMiddlewares,-} from "@/src/features/public-api/server/unstable-public-evals-route";+ createUnstablePublicApiRoute,+ withUnstablePublicApiMiddlewares,+} from "@/src/features/public-api/server/unstable-public-api-route";import {DeleteUnstableEvaluationRuleQuery,DeleteUnstableEvaluationRuleResponse,@@ -17,8 +17,8 @@ import {PatchUnstableEvaluationRuleResponse,} from "@/src/features/public-api/types/unstable-evaluation-rules";-export default withUnstablePublicEvalsMiddlewares({- GET: createUnstablePublicEvalsRoute({+export default withUnstablePublicApiMiddlewares({+ GET: createUnstablePublicApiRoute({name: "Get Unstable Evaluation Rule",querySchema: GetUnstableEvaluationRuleQuery,responseSchema: GetUnstableEvaluationRuleResponse,@@ -28,7 +28,7 @@ export default withUnstablePublicEvalsMiddlewares({evaluationRuleId: query.evaluationRuleId,}),}),- PATCH: createUnstablePublicEvalsRoute({+ PATCH: createUnstablePublicApiRoute({name: "Update Unstable Evaluation Rule",querySchema: PatchUnstableEvaluationRuleQuery,bodySchema: PatchUnstableEvaluationRuleBody,@@ -42,7 +42,7 @@ export default withUnstablePublicEvalsMiddlewares({auditScope: auth.scope,}),}),- DELETE: createUnstablePublicEvalsRoute({+ DELETE: createUnstablePublicApiRoute({name: "Delete Unstable Evaluation Rule",querySchema: DeleteUnstableEvaluationRuleQuery,responseSchema: DeleteUnstableEvaluationRuleResponse,diff --git a/web/src/pages/api/public/unstable/evaluation-rules/index.ts b/web/src/pages/api/public/unstable/evaluation-rules/index.tsindex f5089c7e8e..cd80772165 100644--- a/web/src/pages/api/public/unstable/evaluation-rules/index.ts+++ b/web/src/pages/api/public/unstable/evaluation-rules/index.ts@@ -3,9 +3,9 @@ import {listPublicEvaluationRules,} from "@/src/features/evals/server/unstable-public-api";import {- createUnstablePublicEvalsRoute,- withUnstablePublicEvalsMiddlewares,-} from "@/src/features/public-api/server/unstable-public-evals-route";+ createUnstablePublicApiRoute,+ withUnstablePublicApiMiddlewares,+} from "@/src/features/public-api/server/unstable-public-api-route";import {GetUnstableEvaluationRulesQuery,GetUnstableEvaluationRulesResponse,@@ -13,8 +13,8 @@ import {PostUnstableEvaluationRuleResponse,} from "@/src/features/public-api/types/unstable-evaluation-rules";-export default withUnstablePublicEvalsMiddlewares({- GET: createUnstablePublicEvalsRoute({+export default withUnstablePublicApiMiddlewares({+ GET: createUnstablePublicApiRoute({name: "List Unstable Evaluation Rules",querySchema: GetUnstableEvaluationRulesQuery,responseSchema: GetUnstableEvaluationRulesResponse,@@ -25,7 +25,7 @@ export default withUnstablePublicEvalsMiddlewares({limit: query.limit,}),}),- POST: createUnstablePublicEvalsRoute({+ POST: createUnstablePublicApiRoute({name: "Create Unstable Evaluation Rule",bodySchema: PostUnstableEvaluationRuleBody,responseSchema: PostUnstableEvaluationRuleResponse,diff --git a/web/src/pages/api/public/unstable/evaluators/[evaluatorId].ts b/web/src/pages/api/public/unstable/evaluators/[evaluatorId].tsindex d4b3db880b..43ab658f59 100644--- a/web/src/pages/api/public/unstable/evaluators/[evaluatorId].ts+++ b/web/src/pages/api/public/unstable/evaluators/[evaluatorId].ts@@ -3,9 +3,9 @@ import {getPublicEvaluator,} from "@/src/features/evals/server/unstable-public-api";import {- createUnstablePublicEvalsRoute,- withUnstablePublicEvalsMiddlewares,-} from "@/src/features/public-api/server/unstable-public-evals-route";+ createUnstablePublicApiRoute,+ withUnstablePublicApiMiddlewares,+} from "@/src/features/public-api/server/unstable-public-api-route";import {DeleteUnstableEvaluatorQuery,DeleteUnstableEvaluatorResponse,@@ -13,8 +13,8 @@ import {GetUnstableEvaluatorResponse,} from "@/src/features/public-api/types/unstable-evaluators";-export default withUnstablePublicEvalsMiddlewares({- GET: createUnstablePublicEvalsRoute({+export default withUnstablePublicApiMiddlewares({+ GET: createUnstablePublicApiRoute({name: "Get Unstable Evaluator",querySchema: GetUnstableEvaluatorQuery,responseSchema: GetUnstableEvaluatorResponse,@@ -24,7 +24,7 @@ export default withUnstablePublicEvalsMiddlewares({evaluatorId: query.evaluatorId,}),}),- DELETE: createUnstablePublicEvalsRoute({+ DELETE: createUnstablePublicApiRoute({name: "Delete Unstable Evaluator",querySchema: DeleteUnstableEvaluatorQuery,responseSchema: DeleteUnstableEvaluatorResponse,diff --git a/web/src/pages/api/public/unstable/evaluators/index.ts b/web/src/pages/api/public/unstable/evaluators/index.tsindex 7bae197d2f..073b4c4d16 100644--- a/web/src/pages/api/public/unstable/evaluators/index.ts+++ b/web/src/pages/api/public/unstable/evaluators/index.ts@@ -3,9 +3,9 @@ import {listPublicEvaluators,} from "@/src/features/evals/server/unstable-public-api";import {- createUnstablePublicEvalsRoute,- withUnstablePublicEvalsMiddlewares,-} from "@/src/features/public-api/server/unstable-public-evals-route";+ createUnstablePublicApiRoute,+ withUnstablePublicApiMiddlewares,+} from "@/src/features/public-api/server/unstable-public-api-route";import {GetUnstableEvaluatorsQuery,GetUnstableEvaluatorsResponse,@@ -13,8 +13,8 @@ import {PostUnstableEvaluatorResponse,} from "@/src/features/public-api/types/unstable-evaluators";-export default withUnstablePublicEvalsMiddlewares({- GET: createUnstablePublicEvalsRoute({+export default withUnstablePublicApiMiddlewares({+ GET: createUnstablePublicApiRoute({name: "List Unstable Evaluators",querySchema: GetUnstableEvaluatorsQuery,responseSchema: GetUnstableEvaluatorsResponse,@@ -25,7 +25,7 @@ export default withUnstablePublicEvalsMiddlewares({limit: query.limit,}),}),- POST: createUnstablePublicEvalsRoute({+ POST: createUnstablePublicApiRoute({name: "Create Unstable Evaluator",bodySchema: PostUnstableEvaluatorBody,responseSchema: PostUnstableEvaluatorResponse,diff --git a/web/src/utils/product-url.ts b/web/src/utils/product-url.tsindex 61ef8859fb..6cfd3e34b8 100644--- a/web/src/utils/product-url.ts+++ b/web/src/utils/product-url.ts@@ -97,6 +97,15 @@ export const buildProjectPath = (params: { projectId: string }) =>export const buildDashboardsPath = (params: { projectId: string }) =>`${buildProjectPath(params)}/dashboards`;+export const buildDashboardWidgetsPath = (params: { projectId: string }) =>+ `${buildProjectPath(params)}/widgets`;++export const buildDashboardWidgetPath = (params: {+ projectId: string;+ widgetId: string;+}) =>+ `${buildDashboardWidgetsPath(params)}/${encodeURIComponent(params.widgetId)}`;+export const buildDatasetsPath = (params: {projectId: string;folder?: string;@@ -453,6 +462,11 @@ export const buildModelUrl = (params: { projectId: string; modelId: string }) =>`/project/${encodeURIComponent(params.projectId)}/settings/models/${encodeURIComponent(params.modelId)}`,);+export const buildDashboardWidgetUrl = (params: {+ projectId: string;+ widgetId: string;+}) => buildProductUrl(buildDashboardWidgetPath(params));+export const buildEvaluatorUrl = (params: {projectId: string;evaluatorId: string;