agentic-ui-libs 1.2.0-beta.2 → 1.2.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/agentic-ui-libs.css +78 -4
- package/dist/features/dashboard/AnalyticsChart.d.ts.map +1 -1
- package/dist/features/dashboard/Dashboard.d.ts.map +1 -1
- package/dist/features/dashboard/DashboardSection.d.ts.map +1 -1
- package/dist/features/dashboard/MetricCard.d.ts.map +1 -1
- package/dist/features/dashboard/ModelListView.d.ts +1 -0
- package/dist/features/dashboard/ModelListView.d.ts.map +1 -1
- package/dist/features/dashboard/ToolListView.d.ts.map +1 -1
- package/dist/features/debug-logs/DebugPanel.d.ts.map +1 -1
- package/dist/features/debug-logs/components/DebugCard.d.ts.map +1 -1
- package/dist/features/debug-logs/index.d.ts +1 -1
- package/dist/features/debug-logs/index.d.ts.map +1 -1
- package/dist/features/debug-logs/services/ApiService.d.ts.map +1 -1
- package/dist/features/debug-logs/services/TreeBuilder.d.ts +3 -3
- package/dist/features/debug-logs/services/TreeBuilder.d.ts.map +1 -1
- package/dist/features/debug-logs/types.d.ts +13 -2
- package/dist/features/debug-logs/types.d.ts.map +1 -1
- package/dist/features/md-editor/MDEditor.d.ts.map +1 -1
- package/dist/features/md-editor/components/AIDesignPanel.d.ts.map +1 -1
- package/dist/features/md-editor/components/EmptyStatePlaceholder.d.ts +21 -0
- package/dist/features/md-editor/components/EmptyStatePlaceholder.d.ts.map +1 -0
- package/dist/features/md-editor/components/UnifiedToolbar.d.ts +4 -0
- package/dist/features/md-editor/components/UnifiedToolbar.d.ts.map +1 -1
- package/dist/features/md-editor/components/VariableMenu.d.ts.map +1 -1
- package/dist/features/md-editor/components/icons/CategoryIcons.d.ts +1 -0
- package/dist/features/md-editor/components/icons/CategoryIcons.d.ts.map +1 -1
- package/dist/features/md-editor/components/index.d.ts +2 -0
- package/dist/features/md-editor/components/index.d.ts.map +1 -1
- package/dist/features/md-editor/hooks/useAIRefinementSession.d.ts +3 -1
- package/dist/features/md-editor/hooks/useAIRefinementSession.d.ts.map +1 -1
- package/dist/features/md-editor/index.d.ts +1 -1
- package/dist/features/md-editor/index.d.ts.map +1 -1
- package/dist/features/md-editor/types.d.ts +58 -2
- package/dist/features/md-editor/types.d.ts.map +1 -1
- package/dist/features/md-editor/utils/index.d.ts +1 -0
- package/dist/features/md-editor/utils/index.d.ts.map +1 -1
- package/dist/features/md-editor/utils/variableContext.d.ts +38 -0
- package/dist/features/md-editor/utils/variableContext.d.ts.map +1 -0
- package/dist/features/tracing/components/SessionsList.d.ts.map +1 -1
- package/dist/features/tracing/components/TracesList.d.ts.map +1 -1
- package/dist/features/tracing/components/detail/DetailPage.d.ts +1 -1
- package/dist/features/tracing/components/detail/DetailPage.d.ts.map +1 -1
- package/dist/features/tracing/components/detail/NodeDetailPanel.d.ts +1 -1
- package/dist/features/tracing/components/detail/NodeDetailPanel.d.ts.map +1 -1
- package/dist/features/tracing/components/detail/ObservationNode.d.ts.map +1 -1
- package/dist/features/tracing/components/detail/TraceTree.d.ts +1 -1
- package/dist/features/tracing/components/detail/TraceTree.d.ts.map +1 -1
- package/dist/features/tracing/components/detail/config/observationFilterConfig.d.ts.map +1 -1
- package/dist/features/tracing/components/detail/services/DetailPageService.d.ts.map +1 -1
- package/dist/features/tracing/components/detail/types.d.ts +22 -0
- package/dist/features/tracing/components/detail/types.d.ts.map +1 -1
- package/dist/features/tracing/components/shared/CopyableId.d.ts +11 -0
- package/dist/features/tracing/components/shared/CopyableId.d.ts.map +1 -0
- package/dist/features/tracing/components/shared/TracingListHeader.d.ts +2 -1
- package/dist/features/tracing/components/shared/TracingListHeader.d.ts.map +1 -1
- package/dist/features/tracing/components/shared/TracingTable.d.ts.map +1 -1
- package/dist/features/tracing/components/shared/index.d.ts +1 -0
- package/dist/features/tracing/components/shared/index.d.ts.map +1 -1
- package/dist/features/tracing/services/TraceTreeService.d.ts +39 -2
- package/dist/features/tracing/services/TraceTreeService.d.ts.map +1 -1
- package/dist/features/tracing/services/TracingApiService.d.ts +13 -1
- package/dist/features/tracing/services/TracingApiService.d.ts.map +1 -1
- package/dist/features/tracing/types.d.ts +10 -0
- package/dist/features/tracing/types.d.ts.map +1 -1
- package/dist/index.angular.d.ts +1 -1
- package/dist/index.angular.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2089 -788
- package/dist/lib/dashboard-api.service.d.ts +1 -0
- package/dist/lib/dashboard-api.service.d.ts.map +1 -1
- package/dist/shared/types/index.d.ts +7 -0
- package/dist/shared/types/index.d.ts.map +1 -1
- package/dist/shared/ui/DataViewer.d.ts.map +1 -1
- package/dist/ui-libs.umd.js +2089 -788
- package/package.json +3 -2
package/dist/ui-libs.umd.js
CHANGED
|
@@ -4331,7 +4331,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4331
4331
|
onClick,
|
|
4332
4332
|
isFirst = false
|
|
4333
4333
|
}) => {
|
|
4334
|
-
const { title, value, change, info, highlighted } = data;
|
|
4334
|
+
const { title, value, change, info, highlighted, failedCount } = data;
|
|
4335
4335
|
const formatValue2 = (val) => {
|
|
4336
4336
|
if (typeof val === "number") {
|
|
4337
4337
|
return val.toLocaleString();
|
|
@@ -4385,6 +4385,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4385
4385
|
] }),
|
|
4386
4386
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-baseline gap-3", "data-test-id": `dashboard_metric_card_value_container_${data.metricType || data.title.toLowerCase().replace(/\s+/g, "_")}`, children: [
|
|
4387
4387
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-2xl font-semibold text-gray-900", "data-test-id": `dashboard_metric_card_value_${data.metricType || data.title.toLowerCase().replace(/\s+/g, "_")}`, children: formatValue2(value) }),
|
|
4388
|
+
(failedCount ?? 0) > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs font-medium text-red-500", "data-test-id": `dashboard_metric_card_failed_${data.metricType}`, children: [
|
|
4389
|
+
"(",
|
|
4390
|
+
failedCount,
|
|
4391
|
+
" failed)"
|
|
4392
|
+
] }),
|
|
4388
4393
|
change && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4389
4394
|
"div",
|
|
4390
4395
|
{
|
|
@@ -21395,7 +21400,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21395
21400
|
if ("object" != _typeof$i(i2)) return i2;
|
|
21396
21401
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
21397
21402
|
}
|
|
21398
|
-
return
|
|
21403
|
+
return String(t);
|
|
21399
21404
|
}
|
|
21400
21405
|
var Bar = /* @__PURE__ */ function(_PureComponent) {
|
|
21401
21406
|
function Bar2() {
|
|
@@ -28702,7 +28707,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
28702
28707
|
return null;
|
|
28703
28708
|
}
|
|
28704
28709
|
const filteredPayload = payload.filter(
|
|
28705
|
-
(entry) => entry.name && entry.name !== "" && entry.name !== entry.dataKey
|
|
28710
|
+
(entry) => entry.name && entry.name !== "" && entry.name !== entry.dataKey && entry.value != null && !(typeof entry.value === "number" && Number.isNaN(entry.value)) && !(entry.dataKey === "failedModelRuns" && Number(entry.value) === 0)
|
|
28706
28711
|
);
|
|
28707
28712
|
if (filteredPayload.length === 0) {
|
|
28708
28713
|
return null;
|
|
@@ -28802,6 +28807,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
28802
28807
|
agentRuns: 0,
|
|
28803
28808
|
toolRuns: 0,
|
|
28804
28809
|
modelRuns: 0,
|
|
28810
|
+
failedModelRuns: null,
|
|
28805
28811
|
codeTools: 0,
|
|
28806
28812
|
workflowTools: 0,
|
|
28807
28813
|
knowledgeTools: 0,
|
|
@@ -28904,6 +28910,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
28904
28910
|
label: config2.title,
|
|
28905
28911
|
strokeWidth: 2
|
|
28906
28912
|
}];
|
|
28913
|
+
const lineSeries = chartLines.filter((c2) => (c2.seriesType ?? "line") === "line");
|
|
28914
|
+
const barSeries = chartLines.filter((c2) => c2.seriesType === "bar");
|
|
28907
28915
|
if (isLoading) {
|
|
28908
28916
|
console.log("AnalyticsChart: Loading state active");
|
|
28909
28917
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(ChartSkeleton, { className, chartType: config2.type, height });
|
|
@@ -29010,7 +29018,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29010
29018
|
bottom: 20
|
|
29011
29019
|
},
|
|
29012
29020
|
children: [
|
|
29013
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("defs", { children:
|
|
29021
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("defs", { children: lineSeries.map((lineConfig, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("linearGradient", { id: `gradient-${lineConfig.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
29014
29022
|
/* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset: "5%", stopColor: lineConfig.color, stopOpacity: 0.08 }),
|
|
29015
29023
|
/* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset: "95%", stopColor: lineConfig.color, stopOpacity: 0.01 })
|
|
29016
29024
|
] }, `gradient-${index}`)) }),
|
|
@@ -29062,7 +29070,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29062
29070
|
allowEscapeViewBox: { x: false, y: false }
|
|
29063
29071
|
}
|
|
29064
29072
|
),
|
|
29065
|
-
|
|
29073
|
+
lineSeries.map((lineConfig) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29066
29074
|
Area,
|
|
29067
29075
|
{
|
|
29068
29076
|
type: "monotone",
|
|
@@ -29070,12 +29078,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29070
29078
|
stroke: "none",
|
|
29071
29079
|
fill: `url(#gradient-${lineConfig.dataKey})`,
|
|
29072
29080
|
fillOpacity: 1,
|
|
29081
|
+
connectNulls: false,
|
|
29073
29082
|
isAnimationActive: false,
|
|
29074
29083
|
name: ""
|
|
29075
29084
|
},
|
|
29076
29085
|
`area-${lineConfig.dataKey}`
|
|
29077
29086
|
)),
|
|
29078
|
-
|
|
29087
|
+
lineSeries.map((lineConfig) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29079
29088
|
Line,
|
|
29080
29089
|
{
|
|
29081
29090
|
type: "monotone",
|
|
@@ -29083,6 +29092,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29083
29092
|
stroke: lineConfig.color,
|
|
29084
29093
|
strokeWidth: 2.5,
|
|
29085
29094
|
strokeDasharray: lineConfig.strokeDasharray,
|
|
29095
|
+
connectNulls: false,
|
|
29086
29096
|
dot: false,
|
|
29087
29097
|
activeDot: {
|
|
29088
29098
|
r: 5,
|
|
@@ -29093,6 +29103,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29093
29103
|
name: lineConfig.label
|
|
29094
29104
|
},
|
|
29095
29105
|
lineConfig.dataKey
|
|
29106
|
+
)),
|
|
29107
|
+
barSeries.map((lineConfig) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29108
|
+
Bar,
|
|
29109
|
+
{
|
|
29110
|
+
dataKey: lineConfig.dataKey,
|
|
29111
|
+
fill: lineConfig.color,
|
|
29112
|
+
fillOpacity: 0.9,
|
|
29113
|
+
name: lineConfig.label,
|
|
29114
|
+
maxBarSize: 14,
|
|
29115
|
+
radius: [3, 3, 0, 0],
|
|
29116
|
+
isAnimationActive: false
|
|
29117
|
+
},
|
|
29118
|
+
`bar-${lineConfig.dataKey}`
|
|
29096
29119
|
))
|
|
29097
29120
|
]
|
|
29098
29121
|
}
|
|
@@ -29114,8 +29137,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29114
29137
|
})
|
|
29115
29138
|
] })
|
|
29116
29139
|
] }) }),
|
|
29117
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-4", "data-test-id": "dashboard_analytics_chart_legend", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-4 text-sm text-muted-foreground", "data-test-id": "dashboard_analytics_chart_legend_items", children: chartLines.map((lineConfig) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", "data-test-id": `dashboard_analytics_chart_legend_item_${lineConfig.dataKey}`, children: [
|
|
29118
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29140
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-4", "data-test-id": "dashboard_analytics_chart_legend", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-4 text-sm text-muted-foreground", "data-test-id": "dashboard_analytics_chart_legend_items", children: chartLines.filter((lineConfig) => !lineConfig.hideInLegend).map((lineConfig) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", "data-test-id": `dashboard_analytics_chart_legend_item_${lineConfig.dataKey}`, children: [
|
|
29141
|
+
lineConfig.seriesType === "bar" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29142
|
+
"div",
|
|
29143
|
+
{
|
|
29144
|
+
className: "w-2 h-2 rounded-[2px]",
|
|
29145
|
+
style: { backgroundColor: lineConfig.color },
|
|
29146
|
+
"data-test-id": `dashboard_analytics_chart_legend_color_${lineConfig.dataKey}`
|
|
29147
|
+
}
|
|
29148
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
29119
29149
|
"div",
|
|
29120
29150
|
{
|
|
29121
29151
|
className: "w-[8px] h-[8px] rounded-full",
|
|
@@ -29672,6 +29702,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29672
29702
|
return "bg-green-100 text-green-800 border-green-200";
|
|
29673
29703
|
if (["knowledge", "KNOWLEDGE", "knowledge tool"].includes(type) || ["knowledge", "knowledge tool"].includes(normalized))
|
|
29674
29704
|
return "bg-purple-100 text-purple-800 border-purple-200";
|
|
29705
|
+
if (["PRE_PROCESSOR", "POST_PROCESSOR", "INPUT_PROCESSOR", "input_processor", "pre_processor", "post_processor", "processor"].includes(type) || ["pre_processor", "post_processor", "processor", "input_processor"].includes(normalized))
|
|
29706
|
+
return "bg-yellow-100 text-yellow-800 border-yellow-200";
|
|
29675
29707
|
return "bg-gray-100 text-gray-800 border-gray-200";
|
|
29676
29708
|
}
|
|
29677
29709
|
function getToolTypeName(type) {
|
|
@@ -29680,6 +29712,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29680
29712
|
if (["toollibrary", "workflow tool"].includes(normalized)) return "Workflow Tool";
|
|
29681
29713
|
if (["mcp", "mcptool"].includes(normalized)) return "MCP Tool";
|
|
29682
29714
|
if (["knowledge", "knowledge tool", "knowledge"].includes(normalized) || type === "KNOWLEDGE") return "Knowledge";
|
|
29715
|
+
if (["pre_processor", "post_processor", "processor", "input_processor"].includes(normalized) || type === "PRE_PROCESSOR" || type === "POST_PROCESSOR" || type === "INPUT_PROCESSOR" || type === "input_processor")
|
|
29716
|
+
return "Processor";
|
|
29683
29717
|
if (type === "inlineTool") return "Code Tool";
|
|
29684
29718
|
if (type === "toolLibrary") return "Workflow Tool";
|
|
29685
29719
|
if (type === "KNOWLEDGE") return "Knowledge";
|
|
@@ -29906,7 +29940,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
29906
29940
|
model.provider && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 truncate", "data-test-id": `dashboard_model_list_view_row_provider_${index}`, children: getProviderDisplayName(model.provider) })
|
|
29907
29941
|
] })
|
|
29908
29942
|
] }),
|
|
29909
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
29943
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center font-medium text-xs text-gray-700 flex items-center justify-center gap-1", "data-test-id": `dashboard_model_list_view_row_runs_${index}`, children: [
|
|
29944
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: formatValue2(model.runs || 0) }),
|
|
29945
|
+
(model.failedRuns ?? 0) > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-red-500 text-[10px] font-medium", "data-test-id": `dashboard_model_list_view_row_failed_${index}`, children: [
|
|
29946
|
+
"(",
|
|
29947
|
+
model.failedRuns,
|
|
29948
|
+
" failed)"
|
|
29949
|
+
] })
|
|
29950
|
+
] }),
|
|
29910
29951
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center font-medium text-xs text-gray-700", "data-test-id": `dashboard_model_list_view_row_tokens_${index}`, children: formatValue2(model.tokens || model.totalTokens || 0) }),
|
|
29911
29952
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center font-medium text-xs text-gray-700", "data-test-id": `dashboard_model_list_view_row_response_time_${index}`, children: model.responseTime || (model.avgResponseTime ? `${model.avgResponseTime}ms` : "N/A") })
|
|
29912
29953
|
]
|
|
@@ -30586,6 +30627,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30586
30627
|
{
|
|
30587
30628
|
title: "Model Runs",
|
|
30588
30629
|
value: data.data.modelRuns,
|
|
30630
|
+
failedCount: data.data.failedModelRuns || 0,
|
|
30589
30631
|
metricType: "modelRuns",
|
|
30590
30632
|
icon: "cpu",
|
|
30591
30633
|
info: "Number of times the AI agents called various language models to generate responses",
|
|
@@ -30662,8 +30704,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30662
30704
|
basePoint.toolRuns = point2.count || 0;
|
|
30663
30705
|
break;
|
|
30664
30706
|
case "modelRuns":
|
|
30707
|
+
case "modelruns": {
|
|
30708
|
+
const failed = point2.failedModelRuns;
|
|
30665
30709
|
basePoint.modelRuns = point2.count || 0;
|
|
30710
|
+
basePoint.failedModelRuns = typeof failed === "number" && failed >= 0 ? failed : 0;
|
|
30666
30711
|
break;
|
|
30712
|
+
}
|
|
30667
30713
|
default:
|
|
30668
30714
|
basePoint.users = point2.count || 0;
|
|
30669
30715
|
basePoint.sessions = point2.count || 0;
|
|
@@ -30672,6 +30718,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30672
30718
|
basePoint.agentRuns = point2.count || 0;
|
|
30673
30719
|
basePoint.toolRuns = point2.count || 0;
|
|
30674
30720
|
basePoint.modelRuns = point2.count || 0;
|
|
30721
|
+
{
|
|
30722
|
+
const failed = point2.failedModelRuns;
|
|
30723
|
+
basePoint.failedModelRuns = typeof failed === "number" && failed >= 0 ? failed : 0;
|
|
30724
|
+
}
|
|
30675
30725
|
}
|
|
30676
30726
|
console.log(`Transformed point ${index} for metric ${metricType}:`, basePoint);
|
|
30677
30727
|
return basePoint;
|
|
@@ -30756,22 +30806,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30756
30806
|
id: `model-${index + 1}`,
|
|
30757
30807
|
name: item.connectionName ? `${item.modelName} - ${item.connectionName}` : item.modelName || `Model ${index + 1}`,
|
|
30758
30808
|
modelName: item.modelName,
|
|
30759
|
-
// Keep original modelName field
|
|
30760
30809
|
provider: item.provider,
|
|
30761
|
-
// Include provider information
|
|
30762
30810
|
runs: item.count || 0,
|
|
30811
|
+
failedRuns: item.failedRuns || 0,
|
|
30763
30812
|
responseTime: item.avgResponseTime ? item.avgResponseTime < 1e3 ? `${Math.round(item.avgResponseTime)}ms` : `${(item.avgResponseTime / 1e3).toFixed(2)}s` : "0ms",
|
|
30764
30813
|
avgResponseTime: item.avgResponseTime,
|
|
30765
|
-
// Keep original avgResponseTime
|
|
30766
30814
|
tokens: item.tokens || item.totalTokens || Math.floor((item.count || 0) * 300),
|
|
30767
|
-
// Use actual token data when available
|
|
30768
30815
|
totalTokens: item.totalTokens || item.tokens,
|
|
30769
|
-
// Include totalTokens field
|
|
30770
30816
|
successRate: item.successRate ? `${Math.round(item.successRate)}%` : "98%",
|
|
30771
|
-
// Default success rate for models
|
|
30772
30817
|
lastRun: item.lastRun || new Date(Date.now() - Math.random() * 7 * 24 * 60 * 60 * 1e3).toLocaleDateString(),
|
|
30773
30818
|
icon: item.icon
|
|
30774
|
-
// Preserve original icon data if available
|
|
30775
30819
|
}));
|
|
30776
30820
|
}
|
|
30777
30821
|
// Extract control options from listView data for agents
|
|
@@ -30825,9 +30869,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30825
30869
|
if (["toollibrary", "workflow tool"].includes(normalized)) return "Workflow Tool";
|
|
30826
30870
|
if (["mcp", "mcptool"].includes(normalized)) return "MCP Tool";
|
|
30827
30871
|
if (["knowledge", "knowledge tool"].includes(normalized) || toolType === "KNOWLEDGE") return "Knowledge";
|
|
30872
|
+
if (["pre_processor", "post_processor", "processor", "input_processor"].includes(normalized)) return "Processor";
|
|
30828
30873
|
if (toolType === "inlineTool") return "Code Tool";
|
|
30829
30874
|
if (toolType === "toolLibrary") return "Workflow Tool";
|
|
30830
30875
|
if (toolType === "MCP" || toolType === "mcpTool") return "MCP Tool";
|
|
30876
|
+
if (toolType === "PRE_PROCESSOR" || toolType === "POST_PROCESSOR" || toolType === "INPUT_PROCESSOR" || toolType === "input_processor") return "Processor";
|
|
30831
30877
|
return "Code Tool";
|
|
30832
30878
|
};
|
|
30833
30879
|
options.push({
|
|
@@ -30900,7 +30946,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30900
30946
|
listViewData.forEach((item) => {
|
|
30901
30947
|
if (item.modelName) {
|
|
30902
30948
|
options.push({
|
|
30903
|
-
label: item.modelName,
|
|
30949
|
+
label: item.connectionName ? `${item.modelName} - ${item.connectionName}` : item.modelName,
|
|
30904
30950
|
value: item.modelName.replace(/[-\.]/g, ""),
|
|
30905
30951
|
icon: getModelIconPath2(item.provider),
|
|
30906
30952
|
// Use actual SVG icon path
|
|
@@ -30954,6 +31000,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30954
31000
|
if (aggregated.has(key)) {
|
|
30955
31001
|
const existing = aggregated.get(key);
|
|
30956
31002
|
existing.count = (existing.count || 0) + (item.count || 0);
|
|
31003
|
+
existing.failedRuns = (existing.failedRuns || 0) + (item.failedRuns || 0);
|
|
30957
31004
|
existing.avgResponseTime = existing.avgResponseTime && item.avgResponseTime ? (existing.avgResponseTime + item.avgResponseTime) / 2 : existing.avgResponseTime || item.avgResponseTime;
|
|
30958
31005
|
existing.tokens = (existing.tokens || 0) + (item.tokens || 0);
|
|
30959
31006
|
} else {
|
|
@@ -30965,11 +31012,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30965
31012
|
// Batch fetch enhanced data for all metrics with table and control data
|
|
30966
31013
|
async fetchEnhancedMetricsData(fromTimestamp, toTimestamp, timeDimension, filters = []) {
|
|
30967
31014
|
try {
|
|
30968
|
-
const
|
|
31015
|
+
const results = await Promise.allSettled([
|
|
30969
31016
|
this.fetchTimeSeriesDataWithTableData("agent-runs", "runs", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
30970
31017
|
this.fetchTimeSeriesDataWithTableData("tool-runs", "runs", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
30971
31018
|
this.fetchTimeSeriesDataWithTableData("model-runs", "runs", fromTimestamp, toTimestamp, timeDimension, filters)
|
|
30972
31019
|
]);
|
|
31020
|
+
if (results[0].status === "rejected") {
|
|
31021
|
+
console.error("Error fetching agent runs enhanced data:", results[0].reason);
|
|
31022
|
+
}
|
|
31023
|
+
if (results[1].status === "rejected") {
|
|
31024
|
+
console.error("Error fetching tool runs enhanced data:", results[1].reason);
|
|
31025
|
+
}
|
|
31026
|
+
if (results[2].status === "rejected") {
|
|
31027
|
+
console.error("Error fetching model runs enhanced data:", results[2].reason);
|
|
31028
|
+
}
|
|
31029
|
+
const emptyData = { chartData: [], tableData: [], controlOptions: [] };
|
|
31030
|
+
const agentsData = results[0].status === "fulfilled" ? results[0].value : emptyData;
|
|
31031
|
+
const toolsData = results[1].status === "fulfilled" ? results[1].value : emptyData;
|
|
31032
|
+
const modelsData = results[2].status === "fulfilled" ? results[2].value : emptyData;
|
|
30973
31033
|
return {
|
|
30974
31034
|
agents: agentsData,
|
|
30975
31035
|
tools: toolsData,
|
|
@@ -30986,13 +31046,30 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
30986
31046
|
const getChangeType = (changePercent) => {
|
|
30987
31047
|
return changePercent > 0 ? "increase" : "decrease";
|
|
30988
31048
|
};
|
|
30989
|
-
const
|
|
31049
|
+
const results = await Promise.allSettled([
|
|
30990
31050
|
this.fetchTimeSeriesDataWithTableData("agent-runs", "runs", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
30991
31051
|
this.fetchTimeSeriesDataWithTableData("tool-runs", "runs", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
30992
31052
|
this.fetchTimeSeriesDataWithTableData("model-runs", "runs", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
30993
31053
|
this.fetchTimeSeriesData("tool-runs", "runs", fromTimestamp, toTimestamp, timeDimension, filters)
|
|
30994
31054
|
]);
|
|
30995
|
-
|
|
31055
|
+
if (results[0].status === "rejected") {
|
|
31056
|
+
console.error("Error fetching agent runs data:", results[0].reason);
|
|
31057
|
+
}
|
|
31058
|
+
if (results[1].status === "rejected") {
|
|
31059
|
+
console.error("Error fetching tool runs data:", results[1].reason);
|
|
31060
|
+
}
|
|
31061
|
+
if (results[2].status === "rejected") {
|
|
31062
|
+
console.error("Error fetching model runs data:", results[2].reason);
|
|
31063
|
+
}
|
|
31064
|
+
if (results[3].status === "rejected") {
|
|
31065
|
+
console.error("Error fetching tool runs time series data:", results[3].reason);
|
|
31066
|
+
}
|
|
31067
|
+
const emptyEnhancedData = { chartData: [], tableData: [], controlOptions: [] };
|
|
31068
|
+
const agentsData = results[0].status === "fulfilled" ? results[0].value : emptyEnhancedData;
|
|
31069
|
+
const toolsData = results[1].status === "fulfilled" ? results[1].value : emptyEnhancedData;
|
|
31070
|
+
const modelsData = results[2].status === "fulfilled" ? results[2].value : emptyEnhancedData;
|
|
31071
|
+
const toolRunsTimeSeriesData = results[3].status === "fulfilled" ? results[3].value : void 0;
|
|
31072
|
+
const enhancedToolRunsChartData = toolRunsTimeSeriesData ? this.transformTimeSeriesDataForToolRuns(toolRunsTimeSeriesData) : [];
|
|
30996
31073
|
return [
|
|
30997
31074
|
{
|
|
30998
31075
|
title: "Agent Runs",
|
|
@@ -31006,68 +31083,70 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31006
31083
|
value: Math.abs(trends.agentRuns.changePercent),
|
|
31007
31084
|
type: getChangeType(trends.agentRuns.changePercent)
|
|
31008
31085
|
} : void 0,
|
|
31009
|
-
|
|
31010
|
-
|
|
31011
|
-
|
|
31012
|
-
|
|
31013
|
-
|
|
31014
|
-
|
|
31015
|
-
|
|
31016
|
-
|
|
31017
|
-
|
|
31018
|
-
|
|
31019
|
-
|
|
31020
|
-
|
|
31021
|
-
|
|
31022
|
-
|
|
31023
|
-
|
|
31024
|
-
|
|
31025
|
-
|
|
31026
|
-
},
|
|
31027
|
-
table: {
|
|
31028
|
-
title: "Agent Runs",
|
|
31029
|
-
data: agentsData.tableData,
|
|
31030
|
-
columns: [
|
|
31031
|
-
{
|
|
31032
|
-
key: "name",
|
|
31033
|
-
title: "Name",
|
|
31034
|
-
width: 200,
|
|
31035
|
-
align: "left"
|
|
31036
|
-
},
|
|
31037
|
-
{
|
|
31038
|
-
key: "runs",
|
|
31039
|
-
title: "Runs",
|
|
31040
|
-
width: 100,
|
|
31041
|
-
align: "right",
|
|
31042
|
-
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31043
|
-
},
|
|
31044
|
-
{
|
|
31045
|
-
key: "responseTime",
|
|
31046
|
-
title: "Response Time",
|
|
31047
|
-
width: 120,
|
|
31048
|
-
align: "right"
|
|
31049
|
-
},
|
|
31050
|
-
{
|
|
31051
|
-
key: "tokens",
|
|
31052
|
-
title: "Tokens",
|
|
31053
|
-
width: 100,
|
|
31054
|
-
align: "right",
|
|
31055
|
-
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31086
|
+
...agentsData && {
|
|
31087
|
+
view: {
|
|
31088
|
+
type: "chart",
|
|
31089
|
+
chart: {
|
|
31090
|
+
type: "line",
|
|
31091
|
+
title: "Agent Runs",
|
|
31092
|
+
data: agentsData.chartData,
|
|
31093
|
+
dataKey: "agentRuns",
|
|
31094
|
+
color: "#0BA5EC",
|
|
31095
|
+
yAxisLabel: "Number of Agent Runs",
|
|
31096
|
+
height: 300,
|
|
31097
|
+
showGrid: true,
|
|
31098
|
+
curve: "monotone",
|
|
31099
|
+
tooltip: { show: true, style: "dark" },
|
|
31100
|
+
dateRange: {
|
|
31101
|
+
start: fromTimestamp.split("T")[0],
|
|
31102
|
+
end: toTimestamp.split("T")[0]
|
|
31056
31103
|
}
|
|
31057
|
-
|
|
31058
|
-
|
|
31059
|
-
|
|
31060
|
-
|
|
31061
|
-
|
|
31062
|
-
|
|
31063
|
-
|
|
31064
|
-
|
|
31065
|
-
|
|
31066
|
-
|
|
31104
|
+
},
|
|
31105
|
+
table: {
|
|
31106
|
+
title: "Agent Runs",
|
|
31107
|
+
data: agentsData.tableData,
|
|
31108
|
+
columns: [
|
|
31109
|
+
{
|
|
31110
|
+
key: "name",
|
|
31111
|
+
title: "Name",
|
|
31112
|
+
width: 200,
|
|
31113
|
+
align: "left"
|
|
31114
|
+
},
|
|
31115
|
+
{
|
|
31116
|
+
key: "runs",
|
|
31117
|
+
title: "Runs",
|
|
31118
|
+
width: 100,
|
|
31119
|
+
align: "right",
|
|
31120
|
+
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31121
|
+
},
|
|
31122
|
+
{
|
|
31123
|
+
key: "responseTime",
|
|
31124
|
+
title: "Response Time",
|
|
31125
|
+
width: 120,
|
|
31126
|
+
align: "right"
|
|
31127
|
+
},
|
|
31128
|
+
{
|
|
31129
|
+
key: "tokens",
|
|
31130
|
+
title: "Tokens",
|
|
31131
|
+
width: 100,
|
|
31132
|
+
align: "right",
|
|
31133
|
+
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31134
|
+
}
|
|
31135
|
+
]
|
|
31136
|
+
}
|
|
31067
31137
|
},
|
|
31068
|
-
|
|
31069
|
-
|
|
31070
|
-
|
|
31138
|
+
controls: {
|
|
31139
|
+
dropdown: {
|
|
31140
|
+
label: "All Agents",
|
|
31141
|
+
options: agentsData.controlOptions,
|
|
31142
|
+
defaultValue: ["all"],
|
|
31143
|
+
multiSelect: true,
|
|
31144
|
+
searchable: true
|
|
31145
|
+
},
|
|
31146
|
+
toggle: {
|
|
31147
|
+
chartView: true,
|
|
31148
|
+
tableView: true
|
|
31149
|
+
}
|
|
31071
31150
|
}
|
|
31072
31151
|
}
|
|
31073
31152
|
},
|
|
@@ -31082,99 +31161,107 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31082
31161
|
value: Math.abs(trends.toolRuns.changePercent.total),
|
|
31083
31162
|
type: getChangeType(trends.toolRuns.changePercent.total)
|
|
31084
31163
|
} : void 0,
|
|
31085
|
-
|
|
31086
|
-
|
|
31087
|
-
|
|
31088
|
-
|
|
31089
|
-
|
|
31090
|
-
|
|
31091
|
-
|
|
31092
|
-
|
|
31093
|
-
|
|
31094
|
-
|
|
31095
|
-
|
|
31096
|
-
|
|
31097
|
-
|
|
31098
|
-
|
|
31099
|
-
|
|
31100
|
-
|
|
31101
|
-
|
|
31102
|
-
|
|
31103
|
-
|
|
31104
|
-
|
|
31105
|
-
|
|
31106
|
-
|
|
31107
|
-
|
|
31108
|
-
|
|
31109
|
-
|
|
31110
|
-
|
|
31111
|
-
|
|
31112
|
-
|
|
31113
|
-
|
|
31114
|
-
|
|
31115
|
-
|
|
31116
|
-
|
|
31164
|
+
...toolsData && {
|
|
31165
|
+
view: {
|
|
31166
|
+
type: "chart",
|
|
31167
|
+
chart: {
|
|
31168
|
+
type: "line",
|
|
31169
|
+
title: "Tool Runs",
|
|
31170
|
+
data: enhancedToolRunsChartData,
|
|
31171
|
+
yAxisLabel: "Number of Tool Runs",
|
|
31172
|
+
lines: [
|
|
31173
|
+
{
|
|
31174
|
+
dataKey: "toolRuns",
|
|
31175
|
+
color: "#667085",
|
|
31176
|
+
label: "Tool Runs"
|
|
31177
|
+
},
|
|
31178
|
+
{
|
|
31179
|
+
dataKey: "codeTools",
|
|
31180
|
+
color: "#F38744",
|
|
31181
|
+
label: "Code Tools"
|
|
31182
|
+
},
|
|
31183
|
+
{
|
|
31184
|
+
dataKey: "workflowTools",
|
|
31185
|
+
color: "#2970FF",
|
|
31186
|
+
label: "Workflow Tools"
|
|
31187
|
+
},
|
|
31188
|
+
{
|
|
31189
|
+
dataKey: "knowledgeTools",
|
|
31190
|
+
color: "#7A5AF8",
|
|
31191
|
+
label: "Knowledge"
|
|
31192
|
+
},
|
|
31193
|
+
{
|
|
31194
|
+
dataKey: "mcpTools",
|
|
31195
|
+
color: "#47CD89",
|
|
31196
|
+
label: "MCP Tools"
|
|
31197
|
+
},
|
|
31198
|
+
{
|
|
31199
|
+
dataKey: "processors",
|
|
31200
|
+
color: "#EAB308",
|
|
31201
|
+
label: "Processors"
|
|
31202
|
+
}
|
|
31203
|
+
],
|
|
31204
|
+
height: 300,
|
|
31205
|
+
showGrid: true,
|
|
31206
|
+
showLegend: true,
|
|
31207
|
+
curve: "monotone",
|
|
31208
|
+
tooltip: { show: true, style: "dark" },
|
|
31209
|
+
dateRange: {
|
|
31210
|
+
start: fromTimestamp.split("T")[0],
|
|
31211
|
+
end: toTimestamp.split("T")[0]
|
|
31117
31212
|
}
|
|
31118
|
-
|
|
31119
|
-
|
|
31120
|
-
|
|
31121
|
-
|
|
31122
|
-
|
|
31123
|
-
|
|
31124
|
-
|
|
31125
|
-
|
|
31126
|
-
|
|
31213
|
+
},
|
|
31214
|
+
table: {
|
|
31215
|
+
title: "Tool Runs",
|
|
31216
|
+
data: toolsData.tableData,
|
|
31217
|
+
columns: [
|
|
31218
|
+
{
|
|
31219
|
+
key: "name",
|
|
31220
|
+
title: "Name",
|
|
31221
|
+
width: 200,
|
|
31222
|
+
align: "left"
|
|
31223
|
+
},
|
|
31224
|
+
{
|
|
31225
|
+
key: "type",
|
|
31226
|
+
title: "Type",
|
|
31227
|
+
width: 150,
|
|
31228
|
+
align: "left"
|
|
31229
|
+
},
|
|
31230
|
+
{
|
|
31231
|
+
key: "runs",
|
|
31232
|
+
title: "Runs",
|
|
31233
|
+
width: 100,
|
|
31234
|
+
align: "right",
|
|
31235
|
+
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31236
|
+
},
|
|
31237
|
+
{
|
|
31238
|
+
key: "responseTime",
|
|
31239
|
+
title: "Response Time",
|
|
31240
|
+
width: 120,
|
|
31241
|
+
align: "right"
|
|
31242
|
+
}
|
|
31243
|
+
]
|
|
31127
31244
|
}
|
|
31128
31245
|
},
|
|
31129
|
-
|
|
31130
|
-
|
|
31131
|
-
|
|
31132
|
-
|
|
31133
|
-
|
|
31134
|
-
|
|
31135
|
-
|
|
31136
|
-
|
|
31137
|
-
|
|
31138
|
-
|
|
31139
|
-
|
|
31140
|
-
|
|
31141
|
-
title: "Type",
|
|
31142
|
-
width: 150,
|
|
31143
|
-
align: "left"
|
|
31144
|
-
},
|
|
31145
|
-
{
|
|
31146
|
-
key: "runs",
|
|
31147
|
-
title: "Runs",
|
|
31148
|
-
width: 100,
|
|
31149
|
-
align: "right",
|
|
31150
|
-
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31151
|
-
},
|
|
31152
|
-
{
|
|
31153
|
-
key: "responseTime",
|
|
31154
|
-
title: "Response Time",
|
|
31155
|
-
width: 120,
|
|
31156
|
-
align: "right"
|
|
31157
|
-
}
|
|
31158
|
-
]
|
|
31159
|
-
}
|
|
31160
|
-
},
|
|
31161
|
-
controls: {
|
|
31162
|
-
dropdown: {
|
|
31163
|
-
label: "All Tools",
|
|
31164
|
-
options: toolsData.controlOptions,
|
|
31165
|
-
defaultValue: ["all"],
|
|
31166
|
-
multiSelect: true,
|
|
31167
|
-
searchable: true
|
|
31168
|
-
},
|
|
31169
|
-
toggle: {
|
|
31170
|
-
chartView: true,
|
|
31171
|
-
tableView: true
|
|
31246
|
+
controls: {
|
|
31247
|
+
dropdown: {
|
|
31248
|
+
label: "All Tools",
|
|
31249
|
+
options: toolsData.controlOptions,
|
|
31250
|
+
defaultValue: ["all"],
|
|
31251
|
+
multiSelect: true,
|
|
31252
|
+
searchable: true
|
|
31253
|
+
},
|
|
31254
|
+
toggle: {
|
|
31255
|
+
chartView: true,
|
|
31256
|
+
tableView: true
|
|
31257
|
+
}
|
|
31172
31258
|
}
|
|
31173
31259
|
}
|
|
31174
31260
|
},
|
|
31175
31261
|
{
|
|
31176
31262
|
title: "Model Runs",
|
|
31177
31263
|
value: data.data.modelRuns,
|
|
31264
|
+
failedCount: data.data.failedModelRuns || 0,
|
|
31178
31265
|
metricType: "modelRuns",
|
|
31179
31266
|
icon: "cpu",
|
|
31180
31267
|
highlighted: false,
|
|
@@ -31183,68 +31270,79 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31183
31270
|
value: Math.abs(trends.modelRuns.changePercent),
|
|
31184
31271
|
type: getChangeType(trends.modelRuns.changePercent)
|
|
31185
31272
|
} : void 0,
|
|
31186
|
-
|
|
31187
|
-
|
|
31188
|
-
|
|
31189
|
-
|
|
31190
|
-
|
|
31191
|
-
|
|
31192
|
-
|
|
31193
|
-
|
|
31194
|
-
|
|
31195
|
-
|
|
31196
|
-
|
|
31197
|
-
|
|
31198
|
-
|
|
31199
|
-
|
|
31200
|
-
|
|
31201
|
-
|
|
31202
|
-
|
|
31203
|
-
|
|
31204
|
-
|
|
31205
|
-
|
|
31206
|
-
|
|
31207
|
-
|
|
31208
|
-
{
|
|
31209
|
-
|
|
31210
|
-
|
|
31211
|
-
|
|
31212
|
-
align: "left"
|
|
31213
|
-
},
|
|
31214
|
-
{
|
|
31215
|
-
key: "runs",
|
|
31216
|
-
title: "Runs",
|
|
31217
|
-
width: 100,
|
|
31218
|
-
align: "right",
|
|
31219
|
-
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31220
|
-
},
|
|
31221
|
-
{
|
|
31222
|
-
key: "tokens",
|
|
31223
|
-
title: "Tokens",
|
|
31224
|
-
width: 120,
|
|
31225
|
-
align: "right",
|
|
31226
|
-
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31227
|
-
},
|
|
31228
|
-
{
|
|
31229
|
-
key: "responseTime",
|
|
31230
|
-
title: "Response Time",
|
|
31231
|
-
width: 120,
|
|
31232
|
-
align: "right"
|
|
31273
|
+
...modelsData && {
|
|
31274
|
+
view: {
|
|
31275
|
+
type: "chart",
|
|
31276
|
+
chart: {
|
|
31277
|
+
type: "line",
|
|
31278
|
+
title: "Model Runs",
|
|
31279
|
+
data: modelsData.chartData,
|
|
31280
|
+
yAxisLabel: "Number of Model Runs",
|
|
31281
|
+
lines: [
|
|
31282
|
+
{ dataKey: "modelRuns", color: "#47CD89", label: "Model Runs" },
|
|
31283
|
+
{
|
|
31284
|
+
dataKey: "failedModelRuns",
|
|
31285
|
+
color: "#ef4444",
|
|
31286
|
+
label: "Failed",
|
|
31287
|
+
seriesType: "bar",
|
|
31288
|
+
hideInLegend: true
|
|
31289
|
+
}
|
|
31290
|
+
],
|
|
31291
|
+
height: 300,
|
|
31292
|
+
showGrid: true,
|
|
31293
|
+
showLegend: true,
|
|
31294
|
+
curve: "monotone",
|
|
31295
|
+
tooltip: { show: true, style: "dark" },
|
|
31296
|
+
dateRange: {
|
|
31297
|
+
start: fromTimestamp.split("T")[0],
|
|
31298
|
+
end: toTimestamp.split("T")[0]
|
|
31233
31299
|
}
|
|
31234
|
-
|
|
31235
|
-
|
|
31236
|
-
|
|
31237
|
-
|
|
31238
|
-
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
31300
|
+
},
|
|
31301
|
+
table: {
|
|
31302
|
+
title: "Model Runs",
|
|
31303
|
+
data: modelsData.tableData,
|
|
31304
|
+
columns: [
|
|
31305
|
+
{
|
|
31306
|
+
key: "name",
|
|
31307
|
+
title: "Model Name",
|
|
31308
|
+
width: 200,
|
|
31309
|
+
align: "left"
|
|
31310
|
+
},
|
|
31311
|
+
{
|
|
31312
|
+
key: "runs",
|
|
31313
|
+
title: "Runs",
|
|
31314
|
+
width: 100,
|
|
31315
|
+
align: "right",
|
|
31316
|
+
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31317
|
+
},
|
|
31318
|
+
{
|
|
31319
|
+
key: "tokens",
|
|
31320
|
+
title: "Tokens",
|
|
31321
|
+
width: 120,
|
|
31322
|
+
align: "right",
|
|
31323
|
+
formatter: (value) => `${Math.floor(value / 1e3)}k`
|
|
31324
|
+
},
|
|
31325
|
+
{
|
|
31326
|
+
key: "responseTime",
|
|
31327
|
+
title: "Response Time",
|
|
31328
|
+
width: 120,
|
|
31329
|
+
align: "right"
|
|
31330
|
+
}
|
|
31331
|
+
]
|
|
31332
|
+
}
|
|
31244
31333
|
},
|
|
31245
|
-
|
|
31246
|
-
|
|
31247
|
-
|
|
31334
|
+
controls: {
|
|
31335
|
+
dropdown: {
|
|
31336
|
+
label: "All Models",
|
|
31337
|
+
options: modelsData.controlOptions,
|
|
31338
|
+
defaultValue: ["all"],
|
|
31339
|
+
multiSelect: true,
|
|
31340
|
+
searchable: true
|
|
31341
|
+
},
|
|
31342
|
+
toggle: {
|
|
31343
|
+
chartView: true,
|
|
31344
|
+
tableView: true
|
|
31345
|
+
}
|
|
31248
31346
|
}
|
|
31249
31347
|
}
|
|
31250
31348
|
}
|
|
@@ -31256,12 +31354,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31256
31354
|
const getChangeType = (changePercent) => {
|
|
31257
31355
|
return changePercent > 0 ? "increase" : "decrease";
|
|
31258
31356
|
};
|
|
31259
|
-
const
|
|
31357
|
+
const results = await Promise.allSettled([
|
|
31260
31358
|
this.fetchTimeSeriesData("users", "usage-analytics", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
31261
31359
|
this.fetchTimeSeriesData("sessions", "usage-analytics", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
31262
31360
|
this.fetchTimeSeriesData("messages", "usage-analytics", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
31263
31361
|
this.fetchTimeSeriesData("tokens", "usage-analytics", fromTimestamp, toTimestamp, timeDimension, filters)
|
|
31264
31362
|
]);
|
|
31363
|
+
if (results[0].status === "rejected") {
|
|
31364
|
+
console.error("Error fetching users data:", results[0].reason);
|
|
31365
|
+
}
|
|
31366
|
+
if (results[1].status === "rejected") {
|
|
31367
|
+
console.error("Error fetching sessions data:", results[1].reason);
|
|
31368
|
+
}
|
|
31369
|
+
if (results[2].status === "rejected") {
|
|
31370
|
+
console.error("Error fetching messages data:", results[2].reason);
|
|
31371
|
+
}
|
|
31372
|
+
if (results[3].status === "rejected") {
|
|
31373
|
+
console.error("Error fetching tokens data:", results[3].reason);
|
|
31374
|
+
}
|
|
31375
|
+
const emptyTimeSeries = {
|
|
31376
|
+
type: "time-series",
|
|
31377
|
+
category: "usage-analytics",
|
|
31378
|
+
metric: "",
|
|
31379
|
+
data: []
|
|
31380
|
+
};
|
|
31381
|
+
const usersData = results[0].status === "fulfilled" ? results[0].value : { ...emptyTimeSeries, metric: "users" };
|
|
31382
|
+
const sessionsData = results[1].status === "fulfilled" ? results[1].value : { ...emptyTimeSeries, metric: "sessions" };
|
|
31383
|
+
const messagesData = results[2].status === "fulfilled" ? results[2].value : { ...emptyTimeSeries, metric: "messages" };
|
|
31384
|
+
const tokensData = results[3].status === "fulfilled" ? results[3].value : { ...emptyTimeSeries, metric: "tokens" };
|
|
31265
31385
|
return [
|
|
31266
31386
|
{
|
|
31267
31387
|
title: "Users",
|
|
@@ -31275,22 +31395,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31275
31395
|
value: Math.abs(trends.users.changePercent),
|
|
31276
31396
|
type: getChangeType(trends.users.changePercent)
|
|
31277
31397
|
} : void 0,
|
|
31278
|
-
|
|
31279
|
-
|
|
31280
|
-
|
|
31281
|
-
|
|
31282
|
-
|
|
31283
|
-
|
|
31284
|
-
|
|
31285
|
-
|
|
31286
|
-
|
|
31287
|
-
|
|
31288
|
-
|
|
31289
|
-
|
|
31290
|
-
|
|
31291
|
-
|
|
31292
|
-
|
|
31293
|
-
|
|
31398
|
+
...usersData && {
|
|
31399
|
+
view: {
|
|
31400
|
+
type: "chart",
|
|
31401
|
+
chart: {
|
|
31402
|
+
type: "line",
|
|
31403
|
+
title: "Total Users",
|
|
31404
|
+
data: this.transformTimeSeriesDataForMetric(usersData, "users"),
|
|
31405
|
+
dataKey: "users",
|
|
31406
|
+
color: "#4E5BA6",
|
|
31407
|
+
yAxisLabel: "Number of Users",
|
|
31408
|
+
height: 300,
|
|
31409
|
+
showGrid: true,
|
|
31410
|
+
curve: "monotone",
|
|
31411
|
+
tooltip: { show: true, style: "dark" },
|
|
31412
|
+
dateRange: {
|
|
31413
|
+
start: fromTimestamp.split("T")[0],
|
|
31414
|
+
end: toTimestamp.split("T")[0]
|
|
31415
|
+
}
|
|
31294
31416
|
}
|
|
31295
31417
|
}
|
|
31296
31418
|
}
|
|
@@ -31306,22 +31428,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31306
31428
|
value: Math.abs(trends.sessions.changePercent),
|
|
31307
31429
|
type: getChangeType(trends.sessions.changePercent)
|
|
31308
31430
|
} : void 0,
|
|
31309
|
-
|
|
31310
|
-
|
|
31311
|
-
|
|
31312
|
-
|
|
31313
|
-
|
|
31314
|
-
|
|
31315
|
-
|
|
31316
|
-
|
|
31317
|
-
|
|
31318
|
-
|
|
31319
|
-
|
|
31320
|
-
|
|
31321
|
-
|
|
31322
|
-
|
|
31323
|
-
|
|
31324
|
-
|
|
31431
|
+
...sessionsData && {
|
|
31432
|
+
view: {
|
|
31433
|
+
type: "chart",
|
|
31434
|
+
chart: {
|
|
31435
|
+
type: "line",
|
|
31436
|
+
title: "Total Sessions",
|
|
31437
|
+
data: this.transformTimeSeriesDataForMetric(sessionsData, "sessions"),
|
|
31438
|
+
dataKey: "sessions",
|
|
31439
|
+
color: "#0BA5EC",
|
|
31440
|
+
yAxisLabel: "Number of Sessions",
|
|
31441
|
+
height: 300,
|
|
31442
|
+
showGrid: true,
|
|
31443
|
+
curve: "monotone",
|
|
31444
|
+
tooltip: { show: true, style: "dark" },
|
|
31445
|
+
dateRange: {
|
|
31446
|
+
start: fromTimestamp.split("T")[0],
|
|
31447
|
+
end: toTimestamp.split("T")[0]
|
|
31448
|
+
}
|
|
31325
31449
|
}
|
|
31326
31450
|
}
|
|
31327
31451
|
}
|
|
@@ -31337,22 +31461,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31337
31461
|
value: Math.abs(trends.messages.changePercent.total),
|
|
31338
31462
|
type: getChangeType(trends.messages.changePercent.total)
|
|
31339
31463
|
} : void 0,
|
|
31340
|
-
|
|
31341
|
-
|
|
31342
|
-
|
|
31343
|
-
|
|
31344
|
-
|
|
31345
|
-
|
|
31346
|
-
|
|
31347
|
-
|
|
31348
|
-
|
|
31349
|
-
|
|
31350
|
-
|
|
31351
|
-
|
|
31352
|
-
|
|
31353
|
-
|
|
31354
|
-
|
|
31355
|
-
|
|
31464
|
+
...messagesData && {
|
|
31465
|
+
view: {
|
|
31466
|
+
type: "chart",
|
|
31467
|
+
chart: {
|
|
31468
|
+
type: "line",
|
|
31469
|
+
title: "Total Messages",
|
|
31470
|
+
data: this.transformTimeSeriesDataForMetric(messagesData, "messages"),
|
|
31471
|
+
dataKey: "messages",
|
|
31472
|
+
color: "#E478FA",
|
|
31473
|
+
yAxisLabel: "Number of Messages",
|
|
31474
|
+
height: 300,
|
|
31475
|
+
showGrid: true,
|
|
31476
|
+
curve: "monotone",
|
|
31477
|
+
tooltip: { show: true, style: "dark" },
|
|
31478
|
+
dateRange: {
|
|
31479
|
+
start: fromTimestamp.split("T")[0],
|
|
31480
|
+
end: toTimestamp.split("T")[0]
|
|
31481
|
+
}
|
|
31356
31482
|
}
|
|
31357
31483
|
}
|
|
31358
31484
|
}
|
|
@@ -31368,38 +31494,40 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31368
31494
|
value: Math.abs(trends.tokens.changePercent.total),
|
|
31369
31495
|
type: getChangeType(trends.tokens.changePercent.total)
|
|
31370
31496
|
} : void 0,
|
|
31371
|
-
|
|
31372
|
-
|
|
31373
|
-
|
|
31374
|
-
|
|
31375
|
-
|
|
31376
|
-
|
|
31377
|
-
|
|
31378
|
-
|
|
31379
|
-
|
|
31380
|
-
|
|
31381
|
-
|
|
31382
|
-
|
|
31383
|
-
|
|
31384
|
-
|
|
31385
|
-
|
|
31386
|
-
|
|
31387
|
-
|
|
31388
|
-
|
|
31389
|
-
|
|
31390
|
-
|
|
31391
|
-
|
|
31392
|
-
|
|
31497
|
+
...tokensData && {
|
|
31498
|
+
view: {
|
|
31499
|
+
type: "chart",
|
|
31500
|
+
chart: {
|
|
31501
|
+
type: "line",
|
|
31502
|
+
title: "Token Usage Breakdown",
|
|
31503
|
+
data: this.transformTimeSeriesDataForMetric(tokensData, "tokens"),
|
|
31504
|
+
yAxisLabel: "Number of Tokens",
|
|
31505
|
+
lines: [
|
|
31506
|
+
{
|
|
31507
|
+
dataKey: "totalTokens",
|
|
31508
|
+
color: "#FF692E",
|
|
31509
|
+
label: "Total Tokens"
|
|
31510
|
+
},
|
|
31511
|
+
{
|
|
31512
|
+
dataKey: "inputTokens",
|
|
31513
|
+
color: "#5925DC",
|
|
31514
|
+
label: "Input Tokens"
|
|
31515
|
+
},
|
|
31516
|
+
{
|
|
31517
|
+
dataKey: "outputTokens",
|
|
31518
|
+
color: "#E478FA",
|
|
31519
|
+
label: "Output Tokens"
|
|
31520
|
+
}
|
|
31521
|
+
],
|
|
31522
|
+
height: 300,
|
|
31523
|
+
showGrid: true,
|
|
31524
|
+
showLegend: true,
|
|
31525
|
+
curve: "monotone",
|
|
31526
|
+
tooltip: { show: true, style: "dark" },
|
|
31527
|
+
dateRange: {
|
|
31528
|
+
start: fromTimestamp.split("T")[0],
|
|
31529
|
+
end: toTimestamp.split("T")[0]
|
|
31393
31530
|
}
|
|
31394
|
-
],
|
|
31395
|
-
height: 300,
|
|
31396
|
-
showGrid: true,
|
|
31397
|
-
showLegend: true,
|
|
31398
|
-
curve: "monotone",
|
|
31399
|
-
tooltip: { show: true, style: "dark" },
|
|
31400
|
-
dateRange: {
|
|
31401
|
-
start: fromTimestamp.split("T")[0],
|
|
31402
|
-
end: toTimestamp.split("T")[0]
|
|
31403
31531
|
}
|
|
31404
31532
|
}
|
|
31405
31533
|
}
|
|
@@ -31427,35 +31555,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31427
31555
|
let workflowTools = 0;
|
|
31428
31556
|
let knowledgeTools = 0;
|
|
31429
31557
|
let mcpTools = 0;
|
|
31558
|
+
let processors = 0;
|
|
31430
31559
|
if (point2.listView && Array.isArray(point2.listView)) {
|
|
31431
31560
|
point2.listView.forEach((item) => {
|
|
31432
31561
|
const count = item.count || 0;
|
|
31433
|
-
const toolType =
|
|
31434
|
-
const toolName = (item.toolName || item.tool_name || "").toLowerCase();
|
|
31435
|
-
console.log(`Processing listView item:`, { toolType, toolName, count });
|
|
31562
|
+
const toolType = item.toolType || item.tool_type || "";
|
|
31436
31563
|
const normalizedToolType = toolType.toLowerCase();
|
|
31437
|
-
if (["inlinetool", "
|
|
31564
|
+
if (["inlinetool", "tool", "code", "codetool", "event"].includes(normalizedToolType)) {
|
|
31438
31565
|
codeTools += count;
|
|
31439
|
-
} else if (["toollibrary", "
|
|
31566
|
+
} else if (["toollibrary", "workflow"].includes(normalizedToolType)) {
|
|
31440
31567
|
workflowTools += count;
|
|
31441
|
-
} else if (["knowledge", "
|
|
31568
|
+
} else if (["knowledge", "knowledgetool"].includes(normalizedToolType) || toolType === "KNOWLEDGE") {
|
|
31442
31569
|
knowledgeTools += count;
|
|
31443
|
-
} else if (["mcp", "
|
|
31570
|
+
} else if (["mcp", "mcptool"].includes(normalizedToolType)) {
|
|
31444
31571
|
mcpTools += count;
|
|
31572
|
+
} else if (["pre_processor", "post_processor", "processor", "input_processor"].includes(normalizedToolType) || toolType === "INPUT_PROCESSOR" || toolType === "input_processor") {
|
|
31573
|
+
processors += count;
|
|
31445
31574
|
} else {
|
|
31446
|
-
console.log(`Unknown tool type '${toolType}' for tool '${toolName}', defaulting to code tools`);
|
|
31447
31575
|
codeTools += count;
|
|
31448
31576
|
}
|
|
31449
31577
|
});
|
|
31450
|
-
|
|
31451
|
-
codeTools,
|
|
31452
|
-
workflowTools,
|
|
31453
|
-
knowledgeTools,
|
|
31454
|
-
mcpTools,
|
|
31455
|
-
total: codeTools + workflowTools + knowledgeTools + mcpTools,
|
|
31456
|
-
expectedTotal: totalToolRuns
|
|
31457
|
-
});
|
|
31458
|
-
const calculatedTotal = codeTools + workflowTools + knowledgeTools + mcpTools;
|
|
31578
|
+
const calculatedTotal = codeTools + workflowTools + knowledgeTools + mcpTools + processors;
|
|
31459
31579
|
if (Math.abs(calculatedTotal - totalToolRuns) > 1) {
|
|
31460
31580
|
console.warn(`Breakdown total (${calculatedTotal}) doesn't match expected total (${totalToolRuns}) for point ${index}`);
|
|
31461
31581
|
const difference = totalToolRuns - calculatedTotal;
|
|
@@ -31463,7 +31583,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31463
31583
|
console.log(`Adjusted codeTools by ${difference} to balance total`);
|
|
31464
31584
|
}
|
|
31465
31585
|
} else {
|
|
31466
|
-
console.log(`No listView data for point ${index}, assigning all ${totalToolRuns} to codeTools`);
|
|
31467
31586
|
codeTools = totalToolRuns;
|
|
31468
31587
|
}
|
|
31469
31588
|
const basePoint = {
|
|
@@ -31474,11 +31593,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31474
31593
|
toolRuns: totalToolRuns,
|
|
31475
31594
|
value: totalToolRuns,
|
|
31476
31595
|
count: totalToolRuns,
|
|
31477
|
-
// Tool breakdown data for multi-line chart (using actual data)
|
|
31478
31596
|
codeTools,
|
|
31479
31597
|
workflowTools,
|
|
31480
31598
|
knowledgeTools,
|
|
31481
31599
|
mcpTools,
|
|
31600
|
+
processors,
|
|
31482
31601
|
// Token data
|
|
31483
31602
|
input_tokens: point2.input_tokens || 0,
|
|
31484
31603
|
output_tokens: point2.output_tokens || 0,
|
|
@@ -31516,14 +31635,33 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31516
31635
|
// Enhanced batch fetch method that returns complete MetricData with embedded view and controls
|
|
31517
31636
|
async fetchAllCardsDataWithEnhancedViews(fromTimestamp, toTimestamp, timeDimension, filters = []) {
|
|
31518
31637
|
try {
|
|
31519
|
-
const
|
|
31638
|
+
const cardsResults = await Promise.allSettled([
|
|
31520
31639
|
this.fetchUsageAnalyticsCards(fromTimestamp, toTimestamp, timeDimension, filters),
|
|
31521
31640
|
this.fetchRunsCards(fromTimestamp, toTimestamp, timeDimension, filters)
|
|
31522
31641
|
]);
|
|
31523
|
-
|
|
31524
|
-
|
|
31525
|
-
|
|
31642
|
+
if (cardsResults[0].status === "rejected") {
|
|
31643
|
+
console.error("Error fetching usage analytics cards:", cardsResults[0].reason);
|
|
31644
|
+
}
|
|
31645
|
+
if (cardsResults[1].status === "rejected") {
|
|
31646
|
+
console.error("Error fetching runs cards:", cardsResults[1].reason);
|
|
31647
|
+
}
|
|
31648
|
+
if (cardsResults[0].status === "rejected" && cardsResults[1].status === "rejected") {
|
|
31649
|
+
throw new Error("Both usage analytics and runs cards failed to load");
|
|
31650
|
+
}
|
|
31651
|
+
const usageAnalyticsCards = cardsResults[0].status === "fulfilled" ? cardsResults[0].value : void 0;
|
|
31652
|
+
const runsCards = cardsResults[1].status === "fulfilled" ? cardsResults[1].value : void 0;
|
|
31653
|
+
const enhancementResults = await Promise.allSettled([
|
|
31654
|
+
usageAnalyticsCards ? this.transformUsageAnalyticsCardsWithEnhancedData(usageAnalyticsCards, fromTimestamp, toTimestamp, timeDimension, filters) : Promise.resolve([]),
|
|
31655
|
+
runsCards ? this.transformRunsCardsWithEnhancedData(runsCards, fromTimestamp, toTimestamp, timeDimension, filters) : Promise.resolve([])
|
|
31526
31656
|
]);
|
|
31657
|
+
if (enhancementResults[0].status === "rejected") {
|
|
31658
|
+
console.error("Error transforming usage analytics cards:", enhancementResults[0].reason);
|
|
31659
|
+
}
|
|
31660
|
+
if (enhancementResults[1].status === "rejected") {
|
|
31661
|
+
console.error("Error transforming runs cards:", enhancementResults[1].reason);
|
|
31662
|
+
}
|
|
31663
|
+
const enhancedUsageAnalytics = enhancementResults[0].status === "fulfilled" ? enhancementResults[0].value : [];
|
|
31664
|
+
const enhancedRuns = enhancementResults[1].status === "fulfilled" ? enhancementResults[1].value : [];
|
|
31527
31665
|
return {
|
|
31528
31666
|
usageAnalytics: enhancedUsageAnalytics,
|
|
31529
31667
|
runs: enhancedRuns
|
|
@@ -31536,13 +31674,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31536
31674
|
// Batch fetch time series data for default selected metrics
|
|
31537
31675
|
async fetchDefaultTimeSeriesData(fromTimestamp, toTimestamp, timeDimension, filters = []) {
|
|
31538
31676
|
try {
|
|
31539
|
-
const
|
|
31677
|
+
const results = await Promise.allSettled([
|
|
31540
31678
|
this.fetchTimeSeriesData("sessions", "usage-analytics", fromTimestamp, toTimestamp, timeDimension, filters),
|
|
31541
31679
|
this.fetchTimeSeriesData("agent-runs", "runs", fromTimestamp, toTimestamp, timeDimension, filters)
|
|
31542
31680
|
]);
|
|
31681
|
+
if (results[0].status === "rejected") {
|
|
31682
|
+
console.error("Error fetching sessions data:", results[0].reason);
|
|
31683
|
+
}
|
|
31684
|
+
if (results[1].status === "rejected") {
|
|
31685
|
+
console.error("Error fetching agent runs data:", results[1].reason);
|
|
31686
|
+
}
|
|
31687
|
+
const sessionsData = results[0].status === "fulfilled" ? results[0].value : void 0;
|
|
31688
|
+
const agentRunsData = results[1].status === "fulfilled" ? results[1].value : void 0;
|
|
31543
31689
|
return {
|
|
31544
|
-
sessions: this.transformTimeSeriesData(sessionsData),
|
|
31545
|
-
agentRuns: this.transformTimeSeriesData(agentRunsData)
|
|
31690
|
+
sessions: sessionsData ? this.transformTimeSeriesData(sessionsData) : [],
|
|
31691
|
+
agentRuns: agentRunsData ? this.transformTimeSeriesData(agentRunsData) : []
|
|
31546
31692
|
};
|
|
31547
31693
|
} catch (error) {
|
|
31548
31694
|
console.error("Error fetching default time series data:", error);
|
|
@@ -32269,6 +32415,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32269
32415
|
] })
|
|
32270
32416
|
] });
|
|
32271
32417
|
};
|
|
32418
|
+
function modelListViewRowLabel(listItem) {
|
|
32419
|
+
if (!listItem.modelName) return "";
|
|
32420
|
+
return listItem.connectionName ? `${listItem.modelName} - ${listItem.connectionName}` : listItem.modelName;
|
|
32421
|
+
}
|
|
32272
32422
|
const DashboardSection = ({
|
|
32273
32423
|
section,
|
|
32274
32424
|
className,
|
|
@@ -32366,16 +32516,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32366
32516
|
});
|
|
32367
32517
|
return baseData.map((item) => {
|
|
32368
32518
|
let filteredValue = 0;
|
|
32519
|
+
let matchingItems = [];
|
|
32369
32520
|
if (item["listView"] && Array.isArray(item["listView"])) {
|
|
32370
|
-
|
|
32521
|
+
matchingItems = item["listView"].filter((listItem) => {
|
|
32371
32522
|
if (metricType === "agentRuns" && listItem.agentName) {
|
|
32372
32523
|
return listItem.agentName === selectedLabel || listItem.agentName.toLowerCase() === (selectedLabel == null ? void 0 : selectedLabel.toLowerCase());
|
|
32373
32524
|
}
|
|
32374
32525
|
if (metricType === "toolRuns" && listItem.toolName) {
|
|
32375
32526
|
return listItem.toolName === selectedLabel || listItem.toolName.toLowerCase() === (selectedLabel == null ? void 0 : selectedLabel.toLowerCase());
|
|
32376
32527
|
}
|
|
32377
|
-
if (metricType === "modelRuns" && listItem.modelName) {
|
|
32378
|
-
return listItem
|
|
32528
|
+
if (metricType === "modelRuns" && listItem.modelName && selectedLabel) {
|
|
32529
|
+
return modelListViewRowLabel(listItem) === selectedLabel;
|
|
32379
32530
|
}
|
|
32380
32531
|
return false;
|
|
32381
32532
|
});
|
|
@@ -32385,10 +32536,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32385
32536
|
);
|
|
32386
32537
|
}
|
|
32387
32538
|
console.log("📊 Filtered value for", selectedLabel, ":", filteredValue);
|
|
32539
|
+
const failedModelRunsSum = metricType === "modelRuns" ? matchingItems.reduce(
|
|
32540
|
+
(sum2, listItem) => sum2 + (Number(listItem.failedRuns) || 0),
|
|
32541
|
+
0
|
|
32542
|
+
) : 0;
|
|
32388
32543
|
const result = {
|
|
32389
32544
|
...item,
|
|
32390
32545
|
[metricType]: filteredValue
|
|
32391
32546
|
};
|
|
32547
|
+
if (metricType === "modelRuns") {
|
|
32548
|
+
result.failedModelRuns = failedModelRunsSum;
|
|
32549
|
+
}
|
|
32392
32550
|
return result;
|
|
32393
32551
|
});
|
|
32394
32552
|
}
|
|
@@ -32400,8 +32558,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32400
32558
|
const selectedLabels = selectedOptions.map((opt) => opt.label);
|
|
32401
32559
|
return baseData.map((item) => {
|
|
32402
32560
|
let aggregatedValue = 0;
|
|
32561
|
+
let matchingItems = [];
|
|
32403
32562
|
if (item["listView"] && Array.isArray(item["listView"])) {
|
|
32404
|
-
|
|
32563
|
+
matchingItems = item["listView"].filter((listItem) => {
|
|
32405
32564
|
if (metricType === "agentRuns" && listItem.agentName) {
|
|
32406
32565
|
return selectedLabels.some(
|
|
32407
32566
|
(label) => listItem.agentName === label || listItem.agentName.toLowerCase() === (label == null ? void 0 : label.toLowerCase())
|
|
@@ -32413,9 +32572,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32413
32572
|
);
|
|
32414
32573
|
}
|
|
32415
32574
|
if (metricType === "modelRuns" && listItem.modelName) {
|
|
32416
|
-
|
|
32417
|
-
|
|
32418
|
-
);
|
|
32575
|
+
const rowLabel = modelListViewRowLabel(listItem);
|
|
32576
|
+
return selectedLabels.some((label) => rowLabel === label);
|
|
32419
32577
|
}
|
|
32420
32578
|
return false;
|
|
32421
32579
|
});
|
|
@@ -32424,10 +32582,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32424
32582
|
0
|
|
32425
32583
|
);
|
|
32426
32584
|
}
|
|
32427
|
-
|
|
32585
|
+
const failedModelRunsMulti = metricType === "modelRuns" ? matchingItems.reduce(
|
|
32586
|
+
(sum2, listItem) => sum2 + (Number(listItem.failedRuns) || 0),
|
|
32587
|
+
0
|
|
32588
|
+
) : 0;
|
|
32589
|
+
const multiResult = {
|
|
32428
32590
|
...item,
|
|
32429
32591
|
[metricType]: aggregatedValue
|
|
32430
32592
|
};
|
|
32593
|
+
if (metricType === "modelRuns") {
|
|
32594
|
+
multiResult.failedModelRuns = failedModelRunsMulti;
|
|
32595
|
+
}
|
|
32596
|
+
return multiResult;
|
|
32431
32597
|
});
|
|
32432
32598
|
}
|
|
32433
32599
|
return baseData;
|
|
@@ -32659,35 +32825,30 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32659
32825
|
data: filteredData,
|
|
32660
32826
|
yAxisLabel: "Number of Tool Runs",
|
|
32661
32827
|
lines: [
|
|
32662
|
-
{
|
|
32663
|
-
dataKey: "toolRuns",
|
|
32664
|
-
color: "#06b6d4",
|
|
32665
|
-
// Blue for Tool Runs
|
|
32666
|
-
label: "Tool Runs"
|
|
32667
|
-
},
|
|
32668
32828
|
{
|
|
32669
32829
|
dataKey: "codeTools",
|
|
32670
32830
|
color: "#f97316",
|
|
32671
|
-
// Orange for Code Tools
|
|
32672
32831
|
label: "Code Tools"
|
|
32673
32832
|
},
|
|
32674
32833
|
{
|
|
32675
32834
|
dataKey: "workflowTools",
|
|
32676
32835
|
color: "#10b981",
|
|
32677
|
-
// Green for Workflow Tools
|
|
32678
32836
|
label: "Workflow Tools"
|
|
32679
32837
|
},
|
|
32680
32838
|
{
|
|
32681
32839
|
dataKey: "knowledgeTools",
|
|
32682
32840
|
color: "#8b5cf6",
|
|
32683
|
-
// Purple for Knowledge
|
|
32684
32841
|
label: "Knowledge"
|
|
32685
32842
|
},
|
|
32686
32843
|
{
|
|
32687
32844
|
dataKey: "mcpTools",
|
|
32688
32845
|
color: "#ef4444",
|
|
32689
|
-
// Red for MCP Tools
|
|
32690
32846
|
label: "MCP Tools"
|
|
32847
|
+
},
|
|
32848
|
+
{
|
|
32849
|
+
dataKey: "processors",
|
|
32850
|
+
color: "#eab308",
|
|
32851
|
+
label: "Processors"
|
|
32691
32852
|
}
|
|
32692
32853
|
],
|
|
32693
32854
|
height: 300,
|
|
@@ -32707,12 +32868,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32707
32868
|
type: "line",
|
|
32708
32869
|
title: getChartTitle("Model Runs"),
|
|
32709
32870
|
data: getFilteredData(baseData, "modelRuns"),
|
|
32710
|
-
dataKey: "modelRuns",
|
|
32711
|
-
color: "#10b981",
|
|
32712
|
-
// Green as shown in Figma
|
|
32713
32871
|
yAxisLabel: "Number of Model Runs",
|
|
32872
|
+
lines: [
|
|
32873
|
+
{ dataKey: "modelRuns", color: "#10b981", label: "Model Runs" },
|
|
32874
|
+
{
|
|
32875
|
+
dataKey: "failedModelRuns",
|
|
32876
|
+
color: "#ef4444",
|
|
32877
|
+
label: "Failed",
|
|
32878
|
+
seriesType: "bar",
|
|
32879
|
+
hideInLegend: true
|
|
32880
|
+
}
|
|
32881
|
+
],
|
|
32714
32882
|
height: 300,
|
|
32715
32883
|
showGrid: true,
|
|
32884
|
+
showLegend: true,
|
|
32716
32885
|
curve: "monotone",
|
|
32717
32886
|
tooltip: { show: true, style: "dark" },
|
|
32718
32887
|
dateRange: {
|
|
@@ -32725,12 +32894,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32725
32894
|
type: "line",
|
|
32726
32895
|
title: getChartTitle("Model Runs"),
|
|
32727
32896
|
data: filteredData,
|
|
32728
|
-
dataKey: "modelRuns",
|
|
32729
|
-
color: "#10b981",
|
|
32730
|
-
// Green as shown in Figma
|
|
32731
32897
|
yAxisLabel: "Number of Model Runs",
|
|
32898
|
+
lines: [
|
|
32899
|
+
{ dataKey: "modelRuns", color: "#10b981", label: "Model Runs" },
|
|
32900
|
+
{
|
|
32901
|
+
dataKey: "failedModelRuns",
|
|
32902
|
+
color: "#ef4444",
|
|
32903
|
+
label: "Failed",
|
|
32904
|
+
seriesType: "bar",
|
|
32905
|
+
hideInLegend: true
|
|
32906
|
+
}
|
|
32907
|
+
],
|
|
32732
32908
|
height: 300,
|
|
32733
32909
|
showGrid: true,
|
|
32910
|
+
showLegend: true,
|
|
32734
32911
|
curve: "monotone",
|
|
32735
32912
|
tooltip: { show: true, style: "dark" },
|
|
32736
32913
|
dateRange: {
|
|
@@ -34982,8 +35159,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
34982
35159
|
if (appConfig) {
|
|
34983
35160
|
try {
|
|
34984
35161
|
apiServiceRef.current = new DashboardApiService(appConfig);
|
|
34985
|
-
|
|
34986
|
-
|
|
35162
|
+
const initDashboard = async () => {
|
|
35163
|
+
await loadEnvironments();
|
|
35164
|
+
await loadInitialData();
|
|
35165
|
+
};
|
|
35166
|
+
initDashboard();
|
|
34987
35167
|
} catch (err) {
|
|
34988
35168
|
console.error("Failed to initialize API service:", err);
|
|
34989
35169
|
}
|
|
@@ -35549,6 +35729,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
35549
35729
|
traces: data.traces || []
|
|
35550
35730
|
};
|
|
35551
35731
|
}
|
|
35732
|
+
/**
|
|
35733
|
+
* Get total count of traces matching filters (for pagination)
|
|
35734
|
+
* Endpoint: /tracing/api/trpc/traces.countAll
|
|
35735
|
+
*/
|
|
35736
|
+
async fetchTracesCount(projectId, filters, options = {}) {
|
|
35737
|
+
const input = {
|
|
35738
|
+
json: {
|
|
35739
|
+
projectId,
|
|
35740
|
+
filter: filters,
|
|
35741
|
+
searchQuery: options.searchQuery ?? null,
|
|
35742
|
+
searchType: options.searchType ?? ["id"],
|
|
35743
|
+
page: 0,
|
|
35744
|
+
limit: 0,
|
|
35745
|
+
orderBy: options.orderBy ?? null
|
|
35746
|
+
},
|
|
35747
|
+
meta: {
|
|
35748
|
+
values: this.buildMetaValues(filters)
|
|
35749
|
+
}
|
|
35750
|
+
};
|
|
35751
|
+
const url = this.buildTrpcUrl("traces.countAll", input);
|
|
35752
|
+
const data = await this.makeRequest(url);
|
|
35753
|
+
return {
|
|
35754
|
+
totalCount: (data == null ? void 0 : data.totalCount) ?? 0
|
|
35755
|
+
};
|
|
35756
|
+
}
|
|
35552
35757
|
/**
|
|
35553
35758
|
* Fetch metrics for multiple traces (latency, tokens, cost)
|
|
35554
35759
|
* Endpoint: /tracing/api/trpc/traces.metrics
|
|
@@ -36622,6 +36827,140 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
36622
36827
|
] }) })
|
|
36623
36828
|
] });
|
|
36624
36829
|
}
|
|
36830
|
+
const CopyButton$1 = ({
|
|
36831
|
+
text,
|
|
36832
|
+
className = "",
|
|
36833
|
+
iconClassName = "",
|
|
36834
|
+
iconStyle,
|
|
36835
|
+
title = "Copy to clipboard",
|
|
36836
|
+
onCopySuccess,
|
|
36837
|
+
onCopyError,
|
|
36838
|
+
tooltipText = "Copied!",
|
|
36839
|
+
tooltipPosition = "bottom",
|
|
36840
|
+
size = "md"
|
|
36841
|
+
}) => {
|
|
36842
|
+
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
36843
|
+
const getSizeClasses = () => {
|
|
36844
|
+
switch (size) {
|
|
36845
|
+
case "sm":
|
|
36846
|
+
return {
|
|
36847
|
+
button: "p-1",
|
|
36848
|
+
icon: "w-[12px] h-[12px]",
|
|
36849
|
+
tooltip: "text-xs py-1 px-2"
|
|
36850
|
+
};
|
|
36851
|
+
case "lg":
|
|
36852
|
+
return {
|
|
36853
|
+
button: "p-2",
|
|
36854
|
+
icon: "w-[20px] h-[20px]",
|
|
36855
|
+
tooltip: "text-sm py-2 px-3"
|
|
36856
|
+
};
|
|
36857
|
+
default:
|
|
36858
|
+
return {
|
|
36859
|
+
button: "p-1.5",
|
|
36860
|
+
icon: "w-[16px] h-[16px]",
|
|
36861
|
+
tooltip: "text-xs py-1 px-2"
|
|
36862
|
+
};
|
|
36863
|
+
}
|
|
36864
|
+
};
|
|
36865
|
+
const getTooltipPositionClasses = () => {
|
|
36866
|
+
const baseClasses = "absolute bg-gray-800 text-white rounded whitespace-nowrap z-50";
|
|
36867
|
+
switch (tooltipPosition) {
|
|
36868
|
+
case "bottom":
|
|
36869
|
+
return `${baseClasses} top-full mt-1 left-1/2 -translate-x-1/2`;
|
|
36870
|
+
case "left":
|
|
36871
|
+
return `${baseClasses} right-full mr-1 top-1/2 -translate-y-1/2`;
|
|
36872
|
+
case "right":
|
|
36873
|
+
return `${baseClasses} left-full ml-1 top-1/2 -translate-y-1/2`;
|
|
36874
|
+
default:
|
|
36875
|
+
return `${baseClasses} bottom-full mb-1 left-1/2 -translate-x-1/2`;
|
|
36876
|
+
}
|
|
36877
|
+
};
|
|
36878
|
+
const sizeClasses2 = getSizeClasses();
|
|
36879
|
+
const showCopyTooltip = React.useCallback(() => {
|
|
36880
|
+
setShowTooltip(true);
|
|
36881
|
+
setTimeout(() => setShowTooltip(false), 1e3);
|
|
36882
|
+
}, []);
|
|
36883
|
+
const copyToClipboard2 = React.useCallback(async () => {
|
|
36884
|
+
try {
|
|
36885
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
36886
|
+
await navigator.clipboard.writeText(text);
|
|
36887
|
+
showCopyTooltip();
|
|
36888
|
+
onCopySuccess == null ? void 0 : onCopySuccess();
|
|
36889
|
+
return;
|
|
36890
|
+
}
|
|
36891
|
+
const textArea = document.createElement("textarea");
|
|
36892
|
+
textArea.value = text;
|
|
36893
|
+
textArea.style.position = "fixed";
|
|
36894
|
+
textArea.style.left = "-999999px";
|
|
36895
|
+
textArea.style.top = "-999999px";
|
|
36896
|
+
document.body.appendChild(textArea);
|
|
36897
|
+
textArea.focus();
|
|
36898
|
+
textArea.select();
|
|
36899
|
+
try {
|
|
36900
|
+
document.execCommand("copy");
|
|
36901
|
+
showCopyTooltip();
|
|
36902
|
+
onCopySuccess == null ? void 0 : onCopySuccess();
|
|
36903
|
+
} catch (err) {
|
|
36904
|
+
const error = err instanceof Error ? err : new Error("Copy failed");
|
|
36905
|
+
console.warn("Copy to clipboard failed:", error);
|
|
36906
|
+
onCopyError == null ? void 0 : onCopyError(error);
|
|
36907
|
+
} finally {
|
|
36908
|
+
document.body.removeChild(textArea);
|
|
36909
|
+
}
|
|
36910
|
+
} catch (err) {
|
|
36911
|
+
const error = err instanceof Error ? err : new Error("Copy failed");
|
|
36912
|
+
console.warn("Copy to clipboard failed:", error);
|
|
36913
|
+
onCopyError == null ? void 0 : onCopyError(error);
|
|
36914
|
+
}
|
|
36915
|
+
}, [text, showCopyTooltip, onCopySuccess, onCopyError]);
|
|
36916
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative inline-flex", children: [
|
|
36917
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
36918
|
+
"button",
|
|
36919
|
+
{
|
|
36920
|
+
onClick: copyToClipboard2,
|
|
36921
|
+
className: `${sizeClasses2.button} hover:bg-gray-100 rounded transition-colors ${className}`,
|
|
36922
|
+
title,
|
|
36923
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { className: `${sizeClasses2.icon} text-gray-400 ${iconClassName}`, style: iconStyle })
|
|
36924
|
+
}
|
|
36925
|
+
),
|
|
36926
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
36927
|
+
"div",
|
|
36928
|
+
{
|
|
36929
|
+
className: `${getTooltipPositionClasses()} ${sizeClasses2.tooltip} transition-opacity duration-150 ${showTooltip ? "opacity-100 animate-fade-in" : "opacity-0 pointer-events-none"}`,
|
|
36930
|
+
style: {
|
|
36931
|
+
visibility: showTooltip ? "visible" : "hidden"
|
|
36932
|
+
},
|
|
36933
|
+
children: tooltipText
|
|
36934
|
+
}
|
|
36935
|
+
)
|
|
36936
|
+
] });
|
|
36937
|
+
};
|
|
36938
|
+
function CopyableId({ value, truncateLength = 30 }) {
|
|
36939
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "copyable-id-wrapper", title: value, children: [
|
|
36940
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-medium text-gray-900 truncate", children: TracingUtils.truncate(value, truncateLength) }),
|
|
36941
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
36942
|
+
"span",
|
|
36943
|
+
{
|
|
36944
|
+
className: "copyable-id-btn",
|
|
36945
|
+
onClick: (e) => {
|
|
36946
|
+
e.stopPropagation();
|
|
36947
|
+
e.preventDefault();
|
|
36948
|
+
},
|
|
36949
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
36950
|
+
onMouseUp: (e) => e.stopPropagation(),
|
|
36951
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
36952
|
+
CopyButton$1,
|
|
36953
|
+
{
|
|
36954
|
+
text: value,
|
|
36955
|
+
size: "sm",
|
|
36956
|
+
title: "Copy to clipboard",
|
|
36957
|
+
iconClassName: "text-[#667085]"
|
|
36958
|
+
}
|
|
36959
|
+
)
|
|
36960
|
+
}
|
|
36961
|
+
)
|
|
36962
|
+
] });
|
|
36963
|
+
}
|
|
36625
36964
|
function Shimmer$2({ className = "", children }) {
|
|
36626
36965
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `animate-pulse bg-[#F2F4F7] rounded ${className}`, children });
|
|
36627
36966
|
}
|
|
@@ -104632,6 +104971,9 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
104632
104971
|
}, [columns]);
|
|
104633
104972
|
const handleRowClick = React.useCallback(
|
|
104634
104973
|
(event) => {
|
|
104974
|
+
var _a;
|
|
104975
|
+
const target = (_a = event.event) == null ? void 0 : _a.target;
|
|
104976
|
+
if (target == null ? void 0 : target.closest(".copyable-id-btn")) return;
|
|
104635
104977
|
if (onRowClick && event.data) {
|
|
104636
104978
|
onRowClick(event.data);
|
|
104637
104979
|
}
|
|
@@ -104728,9 +105070,10 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
104728
105070
|
onClick: goToFirstPage,
|
|
104729
105071
|
disabled: currentPage === 0,
|
|
104730
105072
|
className: "p-2 rounded hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
105073
|
+
style: { color: "var(--colors-gray-light-mode-700, #344054)" },
|
|
104731
105074
|
title: "First page",
|
|
104732
105075
|
"data-test-id": "tracing-table-first-page-btn",
|
|
104733
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronsLeft, {
|
|
105076
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronsLeft, { size: 16 })
|
|
104734
105077
|
}
|
|
104735
105078
|
),
|
|
104736
105079
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -104739,12 +105082,13 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
104739
105082
|
onClick: goToPreviousPage,
|
|
104740
105083
|
disabled: currentPage === 0,
|
|
104741
105084
|
className: "p-2 rounded hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
105085
|
+
style: { color: "var(--colors-gray-light-mode-700, #344054)" },
|
|
104742
105086
|
title: "Previous page",
|
|
104743
105087
|
"data-test-id": "tracing-table-prev-page-btn",
|
|
104744
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronLeft, {
|
|
105088
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronLeft, { size: 16 })
|
|
104745
105089
|
}
|
|
104746
105090
|
),
|
|
104747
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "px-4 py-2 text-sm
|
|
105091
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "px-4 py-2 text-sm", style: { color: "var(--colors-gray-light-mode-700, #344054)" }, "data-test-id": "tracing-table-page-info", children: [
|
|
104748
105092
|
"Page ",
|
|
104749
105093
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: currentPage + 1 }),
|
|
104750
105094
|
" of",
|
|
@@ -104757,9 +105101,10 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
104757
105101
|
onClick: goToNextPage,
|
|
104758
105102
|
disabled: currentPage >= totalPages - 1,
|
|
104759
105103
|
className: "p-2 rounded hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
105104
|
+
style: { color: "var(--colors-gray-light-mode-700, #344054)" },
|
|
104760
105105
|
title: "Next page",
|
|
104761
105106
|
"data-test-id": "tracing-table-next-page-btn",
|
|
104762
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, {
|
|
105107
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { size: 16 })
|
|
104763
105108
|
}
|
|
104764
105109
|
),
|
|
104765
105110
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -104768,13 +105113,14 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
104768
105113
|
onClick: goToLastPage,
|
|
104769
105114
|
disabled: currentPage >= totalPages - 1,
|
|
104770
105115
|
className: "p-2 rounded hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
105116
|
+
style: { color: "var(--colors-gray-light-mode-700, #344054)" },
|
|
104771
105117
|
title: "Last page",
|
|
104772
105118
|
"data-test-id": "tracing-table-last-page-btn",
|
|
104773
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronsRight, {
|
|
105119
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronsRight, { size: 16 })
|
|
104774
105120
|
}
|
|
104775
105121
|
)
|
|
104776
105122
|
] }),
|
|
104777
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center text-sm
|
|
105123
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center text-sm shrink-0 absolute right-[24px]", style: { color: "var(--colors-gray-light-mode-700, #344054)" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
104778
105124
|
"Showing ",
|
|
104779
105125
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold", children: startRow }),
|
|
104780
105126
|
" to",
|
|
@@ -104802,9 +105148,12 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
104802
105148
|
timeRangePresetLabel,
|
|
104803
105149
|
onTimeRangeChange,
|
|
104804
105150
|
filters,
|
|
105151
|
+
filterColumns: filterColumnsProp,
|
|
104805
105152
|
onFiltersClick,
|
|
104806
105153
|
onModifyColumnsClick,
|
|
104807
105154
|
showModifyColumns = true,
|
|
105155
|
+
onClearFilters,
|
|
105156
|
+
onRemoveFilter,
|
|
104808
105157
|
onRefresh,
|
|
104809
105158
|
isRefreshing = false
|
|
104810
105159
|
} = props;
|
|
@@ -104849,6 +105198,50 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
104849
105198
|
}
|
|
104850
105199
|
return `Searches in ${fields}.`;
|
|
104851
105200
|
};
|
|
105201
|
+
const activeFilters = filters.filter(TracingUtils.isFilterActive);
|
|
105202
|
+
const [filtersExpanded, setFiltersExpanded] = React.useState(false);
|
|
105203
|
+
const [isOverflowing, setIsOverflowing] = React.useState(false);
|
|
105204
|
+
const chipsContainerRef = React.useRef(null);
|
|
105205
|
+
const checkOverflow = React.useCallback(() => {
|
|
105206
|
+
const el = chipsContainerRef.current;
|
|
105207
|
+
if (!el) return;
|
|
105208
|
+
setIsOverflowing(el.scrollHeight > el.clientHeight);
|
|
105209
|
+
}, []);
|
|
105210
|
+
React.useEffect(() => {
|
|
105211
|
+
checkOverflow();
|
|
105212
|
+
window.addEventListener("resize", checkOverflow);
|
|
105213
|
+
return () => window.removeEventListener("resize", checkOverflow);
|
|
105214
|
+
}, [checkOverflow, activeFilters.length]);
|
|
105215
|
+
const getFilterChipLabel = (filter) => {
|
|
105216
|
+
const col = filterColumnsProp == null ? void 0 : filterColumnsProp.find((c2) => c2.field === filter.column);
|
|
105217
|
+
const label = (col == null ? void 0 : col.label) ?? filter.column;
|
|
105218
|
+
let valueText;
|
|
105219
|
+
if (filter.type === "datetime") {
|
|
105220
|
+
valueText = new Date(filter.value).toLocaleDateString();
|
|
105221
|
+
} else if (filter.type === "number") {
|
|
105222
|
+
valueText = parseFloat(filter.value).toLocaleString();
|
|
105223
|
+
} else if (Array.isArray(filter.value)) {
|
|
105224
|
+
valueText = filter.value.length <= 2 ? filter.value.join(", ") : `${filter.value.length} selected`;
|
|
105225
|
+
} else {
|
|
105226
|
+
valueText = String(filter.value ?? "");
|
|
105227
|
+
}
|
|
105228
|
+
const shortOp = {
|
|
105229
|
+
"=": "",
|
|
105230
|
+
"!=": "≠ ",
|
|
105231
|
+
">": "> ",
|
|
105232
|
+
">=": "≥ ",
|
|
105233
|
+
"<": "< ",
|
|
105234
|
+
"<=": "≤ ",
|
|
105235
|
+
"contains": "~ ",
|
|
105236
|
+
"does not contain": "!~ ",
|
|
105237
|
+
"starts with": "starts ",
|
|
105238
|
+
"ends with": "ends ",
|
|
105239
|
+
"any of": "",
|
|
105240
|
+
"none of": "not "
|
|
105241
|
+
};
|
|
105242
|
+
const op = shortOp[filter.operator] ?? `${filter.operator} `;
|
|
105243
|
+
return `${label}: ${op}${valueText}`;
|
|
105244
|
+
};
|
|
104852
105245
|
const handleDateRangeChange = (dateRange, presetLabel) => {
|
|
104853
105246
|
if (dateRange && dateRange.from && dateRange.to) {
|
|
104854
105247
|
const fromDate = dateRange.from;
|
|
@@ -105001,7 +105394,66 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
105001
105394
|
}
|
|
105002
105395
|
)
|
|
105003
105396
|
] })
|
|
105004
|
-
] })
|
|
105397
|
+
] }),
|
|
105398
|
+
activeFilters.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
105399
|
+
"div",
|
|
105400
|
+
{
|
|
105401
|
+
className: "flex items-start gap-[8px] border border-gray-200 rounded-[8px] px-[12px] py-[8px]",
|
|
105402
|
+
"data-test-id": "tracing-filter-chips",
|
|
105403
|
+
children: [
|
|
105404
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[12px] font-medium leading-[28px] text-gray-500 shrink-0", children: "Filters" }),
|
|
105405
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
105406
|
+
"div",
|
|
105407
|
+
{
|
|
105408
|
+
ref: chipsContainerRef,
|
|
105409
|
+
className: `flex items-center gap-[8px] flex-wrap flex-1 min-w-0 ${!filtersExpanded ? "max-h-[28px] overflow-hidden" : ""}`,
|
|
105410
|
+
children: activeFilters.map((filter, idx) => {
|
|
105411
|
+
const originalIndex = filters.indexOf(filter);
|
|
105412
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
105413
|
+
"div",
|
|
105414
|
+
{
|
|
105415
|
+
className: "inline-flex items-center gap-[4px] h-[28px] px-[10px] py-[4px] bg-blue-50 border border-blue-200 rounded-[6px] text-[12px] leading-[16px] text-blue-800 max-w-[260px]",
|
|
105416
|
+
children: [
|
|
105417
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate font-medium", children: getFilterChipLabel(filter) }),
|
|
105418
|
+
onRemoveFilter && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
105419
|
+
"button",
|
|
105420
|
+
{
|
|
105421
|
+
onClick: () => onRemoveFilter(originalIndex),
|
|
105422
|
+
className: "flex items-center justify-center shrink-0 text-blue-400 hover:text-blue-700 transition-colors",
|
|
105423
|
+
title: "Remove filter",
|
|
105424
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "w-[14px] h-[14px]", strokeWidth: 2 })
|
|
105425
|
+
}
|
|
105426
|
+
)
|
|
105427
|
+
]
|
|
105428
|
+
},
|
|
105429
|
+
`chip-${idx}`
|
|
105430
|
+
);
|
|
105431
|
+
})
|
|
105432
|
+
}
|
|
105433
|
+
),
|
|
105434
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[8px] shrink-0 leading-[28px]", children: [
|
|
105435
|
+
(isOverflowing || filtersExpanded) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
105436
|
+
"button",
|
|
105437
|
+
{
|
|
105438
|
+
onClick: () => setFiltersExpanded((prev) => !prev),
|
|
105439
|
+
className: "text-[12px] font-medium text-blue-600 hover:text-blue-800 transition-colors whitespace-nowrap",
|
|
105440
|
+
"data-test-id": "tracing-filter-toggle",
|
|
105441
|
+
children: filtersExpanded ? "View less" : "View all"
|
|
105442
|
+
}
|
|
105443
|
+
),
|
|
105444
|
+
onClearFilters && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
105445
|
+
"button",
|
|
105446
|
+
{
|
|
105447
|
+
onClick: onClearFilters,
|
|
105448
|
+
className: "text-[12px] font-medium text-gray-500 hover:text-gray-700 transition-colors whitespace-nowrap",
|
|
105449
|
+
"data-test-id": "tracing-filter-clear-all",
|
|
105450
|
+
children: "Clear all"
|
|
105451
|
+
}
|
|
105452
|
+
)
|
|
105453
|
+
] })
|
|
105454
|
+
]
|
|
105455
|
+
}
|
|
105456
|
+
)
|
|
105005
105457
|
] });
|
|
105006
105458
|
}
|
|
105007
105459
|
function ColumnCustomization(props) {
|
|
@@ -105488,6 +105940,8 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
105488
105940
|
] })
|
|
105489
105941
|
] });
|
|
105490
105942
|
}
|
|
105943
|
+
const TRACE_PII_DISPLAY_USER_MESSAGE_KEY = "piiDisplayUserMessage";
|
|
105944
|
+
const TRACE_PII_DISPLAY_APP_RESPONSE_KEY = "piiDisplayAppResponse";
|
|
105491
105945
|
class TraceTreeService {
|
|
105492
105946
|
/**
|
|
105493
105947
|
* Build a hierarchical tree from a flat list of observations
|
|
@@ -105660,43 +106114,205 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
105660
106114
|
});
|
|
105661
106115
|
}
|
|
105662
106116
|
/**
|
|
105663
|
-
* Extract user message from trace input
|
|
106117
|
+
* Extract user message from trace input for display.
|
|
106118
|
+
* Handles string, object with message/content/text/query, and messages array (e.g. voice/chat).
|
|
106119
|
+
*/
|
|
106120
|
+
/**
|
|
106121
|
+
* Parse trace metadata from API (string or object) into a plain object.
|
|
106122
|
+
*/
|
|
106123
|
+
static parseTraceMetadata(metadata) {
|
|
106124
|
+
if (metadata === null || metadata === void 0) {
|
|
106125
|
+
return {};
|
|
106126
|
+
}
|
|
106127
|
+
if (typeof metadata === "string") {
|
|
106128
|
+
try {
|
|
106129
|
+
return JSON.parse(metadata);
|
|
106130
|
+
} catch {
|
|
106131
|
+
return {};
|
|
106132
|
+
}
|
|
106133
|
+
}
|
|
106134
|
+
if (typeof metadata === "object" && !Array.isArray(metadata)) {
|
|
106135
|
+
return metadata;
|
|
106136
|
+
}
|
|
106137
|
+
return {};
|
|
106138
|
+
}
|
|
106139
|
+
/**
|
|
106140
|
+
* Read PII display strings from Langfuse/Kore trace metadata (if present).
|
|
105664
106141
|
*/
|
|
106142
|
+
static extractPiiDisplayFromTraceMetadata(metadata) {
|
|
106143
|
+
const obj = this.parseTraceMetadata(metadata);
|
|
106144
|
+
const userRaw = obj[TRACE_PII_DISPLAY_USER_MESSAGE_KEY];
|
|
106145
|
+
const appRaw = obj[TRACE_PII_DISPLAY_APP_RESPONSE_KEY];
|
|
106146
|
+
const result = {};
|
|
106147
|
+
if (typeof userRaw === "string" && userRaw.length > 0) {
|
|
106148
|
+
result.displayUserMessage = userRaw;
|
|
106149
|
+
}
|
|
106150
|
+
if (typeof appRaw === "string" && appRaw.length > 0) {
|
|
106151
|
+
result.displayAppResponse = appRaw;
|
|
106152
|
+
}
|
|
106153
|
+
return result;
|
|
106154
|
+
}
|
|
106155
|
+
/**
|
|
106156
|
+
* Some tracing APIs expose custom PII display keys on trace root as well as under metadata.
|
|
106157
|
+
*/
|
|
106158
|
+
static extractPiiDisplayFromApiTrace(trace) {
|
|
106159
|
+
const fromMeta = this.extractPiiDisplayFromTraceMetadata(trace.metadata);
|
|
106160
|
+
const userTop = trace[TRACE_PII_DISPLAY_USER_MESSAGE_KEY];
|
|
106161
|
+
const appTop = trace[TRACE_PII_DISPLAY_APP_RESPONSE_KEY];
|
|
106162
|
+
const fromTop = {};
|
|
106163
|
+
if (typeof userTop === "string" && userTop.length > 0) {
|
|
106164
|
+
fromTop.displayUserMessage = userTop;
|
|
106165
|
+
}
|
|
106166
|
+
if (typeof appTop === "string" && appTop.length > 0) {
|
|
106167
|
+
fromTop.displayAppResponse = appTop;
|
|
106168
|
+
}
|
|
106169
|
+
return {
|
|
106170
|
+
displayUserMessage: fromTop.displayUserMessage ?? fromMeta.displayUserMessage,
|
|
106171
|
+
displayAppResponse: fromTop.displayAppResponse ?? fromMeta.displayAppResponse
|
|
106172
|
+
};
|
|
106173
|
+
}
|
|
105665
106174
|
static extractUserMessage(input) {
|
|
105666
106175
|
if (!input) return "";
|
|
105667
106176
|
if (typeof input === "string") {
|
|
105668
106177
|
try {
|
|
105669
106178
|
const parsed = JSON.parse(input);
|
|
105670
|
-
|
|
106179
|
+
const fromParsed = (parsed == null ? void 0 : parsed.message) ?? (parsed == null ? void 0 : parsed.content) ?? (parsed == null ? void 0 : parsed.text) ?? (parsed == null ? void 0 : parsed.query);
|
|
106180
|
+
if (fromParsed !== void 0 && fromParsed !== null) return String(fromParsed);
|
|
106181
|
+
if (Array.isArray(parsed == null ? void 0 : parsed.messages)) {
|
|
106182
|
+
return this.extractLastUserMessageFromArray(parsed.messages);
|
|
106183
|
+
}
|
|
106184
|
+
return input;
|
|
105671
106185
|
} catch {
|
|
105672
106186
|
return input;
|
|
105673
106187
|
}
|
|
105674
106188
|
}
|
|
105675
106189
|
if (typeof input === "object") {
|
|
105676
106190
|
const obj = input;
|
|
105677
|
-
|
|
106191
|
+
const direct = (obj == null ? void 0 : obj["message"]) ?? (obj == null ? void 0 : obj["content"]) ?? (obj == null ? void 0 : obj["text"]) ?? (obj == null ? void 0 : obj["query"]);
|
|
106192
|
+
if (direct !== void 0 && direct !== null && direct !== "") {
|
|
106193
|
+
return typeof direct === "object" ? JSON.stringify(direct) : String(direct);
|
|
106194
|
+
}
|
|
106195
|
+
if (Array.isArray(obj == null ? void 0 : obj.messages)) {
|
|
106196
|
+
return this.extractLastUserMessageFromArray(obj.messages);
|
|
106197
|
+
}
|
|
106198
|
+
if (Array.isArray(input)) {
|
|
106199
|
+
return this.extractLastUserMessageFromArray(input);
|
|
106200
|
+
}
|
|
106201
|
+
return JSON.stringify(obj);
|
|
105678
106202
|
}
|
|
105679
106203
|
return String(input);
|
|
105680
106204
|
}
|
|
105681
106205
|
/**
|
|
105682
|
-
*
|
|
106206
|
+
* LangChain-serialized messages store role/content under `kwargs` and type in `id`.
|
|
106207
|
+
*/
|
|
106208
|
+
static getLangchainMessageContent(msg) {
|
|
106209
|
+
if (msg["content"] !== void 0 && msg["content"] !== null) {
|
|
106210
|
+
return msg["content"];
|
|
106211
|
+
}
|
|
106212
|
+
const kwargs = msg["kwargs"];
|
|
106213
|
+
if (kwargs && typeof kwargs === "object" && !Array.isArray(kwargs)) {
|
|
106214
|
+
const c2 = kwargs["content"];
|
|
106215
|
+
if (c2 !== void 0 && c2 !== null) {
|
|
106216
|
+
return c2;
|
|
106217
|
+
}
|
|
106218
|
+
}
|
|
106219
|
+
return void 0;
|
|
106220
|
+
}
|
|
106221
|
+
static inferLangchainMessageRole(msg) {
|
|
106222
|
+
if (typeof msg["role"] === "string") {
|
|
106223
|
+
return msg["role"];
|
|
106224
|
+
}
|
|
106225
|
+
const kwargs = msg["kwargs"];
|
|
106226
|
+
if (kwargs && typeof kwargs === "object" && !Array.isArray(kwargs)) {
|
|
106227
|
+
const r2 = kwargs["role"];
|
|
106228
|
+
if (typeof r2 === "string") {
|
|
106229
|
+
return r2;
|
|
106230
|
+
}
|
|
106231
|
+
}
|
|
106232
|
+
const id = msg["id"];
|
|
106233
|
+
if (Array.isArray(id)) {
|
|
106234
|
+
const tail = id[id.length - 1];
|
|
106235
|
+
if (tail === "HumanMessage") {
|
|
106236
|
+
return "user";
|
|
106237
|
+
}
|
|
106238
|
+
if (tail === "AIMessage" || tail === "AIMessageChunk") {
|
|
106239
|
+
return "assistant";
|
|
106240
|
+
}
|
|
106241
|
+
if (tail === "SystemMessage") {
|
|
106242
|
+
return "system";
|
|
106243
|
+
}
|
|
106244
|
+
if (tail === "ToolMessage") {
|
|
106245
|
+
return "tool";
|
|
106246
|
+
}
|
|
106247
|
+
}
|
|
106248
|
+
return void 0;
|
|
106249
|
+
}
|
|
106250
|
+
/**
|
|
106251
|
+
* Get last user message content from a messages array (chat/voice format).
|
|
106252
|
+
*/
|
|
106253
|
+
static extractLastUserMessageFromArray(messages) {
|
|
106254
|
+
if (!messages.length) return "";
|
|
106255
|
+
for (let i2 = messages.length - 1; i2 >= 0; i2--) {
|
|
106256
|
+
const msg = messages[i2];
|
|
106257
|
+
const role = this.inferLangchainMessageRole(msg);
|
|
106258
|
+
const content2 = this.getLangchainMessageContent(msg);
|
|
106259
|
+
if (role === "user" && content2 != null) {
|
|
106260
|
+
return typeof content2 === "string" ? content2 : JSON.stringify(content2);
|
|
106261
|
+
}
|
|
106262
|
+
}
|
|
106263
|
+
const last2 = messages[messages.length - 1];
|
|
106264
|
+
const content = this.getLangchainMessageContent(last2);
|
|
106265
|
+
if (content != null) {
|
|
106266
|
+
return typeof content === "string" ? content : JSON.stringify(content);
|
|
106267
|
+
}
|
|
106268
|
+
return JSON.stringify(messages[messages.length - 1]);
|
|
106269
|
+
}
|
|
106270
|
+
/**
|
|
106271
|
+
* Extract app response from trace output for display.
|
|
106272
|
+
* Handles string, object with message/content/text/response, and messages array.
|
|
105683
106273
|
*/
|
|
105684
106274
|
static extractAppResponse(output) {
|
|
105685
106275
|
if (!output) return "";
|
|
105686
106276
|
if (typeof output === "string") {
|
|
105687
106277
|
try {
|
|
105688
106278
|
const parsed = JSON.parse(output);
|
|
105689
|
-
|
|
106279
|
+
const fromParsed = (parsed == null ? void 0 : parsed.message) ?? (parsed == null ? void 0 : parsed.content) ?? (parsed == null ? void 0 : parsed.text) ?? (parsed == null ? void 0 : parsed.response);
|
|
106280
|
+
if (fromParsed !== void 0 && fromParsed !== null) return String(fromParsed);
|
|
106281
|
+
if (Array.isArray(parsed == null ? void 0 : parsed.messages)) {
|
|
106282
|
+
return this.extractLastMessageContentFromArray(parsed.messages);
|
|
106283
|
+
}
|
|
106284
|
+
return output;
|
|
105690
106285
|
} catch {
|
|
105691
106286
|
return output;
|
|
105692
106287
|
}
|
|
105693
106288
|
}
|
|
105694
106289
|
if (typeof output === "object") {
|
|
105695
106290
|
const obj = output;
|
|
105696
|
-
|
|
106291
|
+
const direct = (obj == null ? void 0 : obj["message"]) ?? (obj == null ? void 0 : obj["content"]) ?? (obj == null ? void 0 : obj["text"]) ?? (obj == null ? void 0 : obj["response"]);
|
|
106292
|
+
if (direct !== void 0 && direct !== null && direct !== "") {
|
|
106293
|
+
return typeof direct === "object" ? JSON.stringify(direct) : String(direct);
|
|
106294
|
+
}
|
|
106295
|
+
if (Array.isArray(obj == null ? void 0 : obj.messages)) {
|
|
106296
|
+
return this.extractLastMessageContentFromArray(obj.messages);
|
|
106297
|
+
}
|
|
106298
|
+
if (Array.isArray(output)) {
|
|
106299
|
+
return this.extractLastMessageContentFromArray(output);
|
|
106300
|
+
}
|
|
106301
|
+
return JSON.stringify(obj);
|
|
105697
106302
|
}
|
|
105698
106303
|
return String(output);
|
|
105699
106304
|
}
|
|
106305
|
+
/**
|
|
106306
|
+
* Get last message content from a messages array for output display.
|
|
106307
|
+
*/
|
|
106308
|
+
static extractLastMessageContentFromArray(messages) {
|
|
106309
|
+
if (!messages.length) return "";
|
|
106310
|
+
const last2 = messages[messages.length - 1];
|
|
106311
|
+
const fromKwargs = this.getLangchainMessageContent(last2);
|
|
106312
|
+
const content = fromKwargs ?? (last2 == null ? void 0 : last2.message) ?? (last2 == null ? void 0 : last2.text);
|
|
106313
|
+
if (content != null) return typeof content === "string" ? content : JSON.stringify(content);
|
|
106314
|
+
return JSON.stringify(last2);
|
|
106315
|
+
}
|
|
105700
106316
|
/**
|
|
105701
106317
|
* Calculate trace metrics from observations
|
|
105702
106318
|
*/
|
|
@@ -105706,7 +106322,9 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
105706
106322
|
let maxEndTime = 0;
|
|
105707
106323
|
let minStartTime = Infinity;
|
|
105708
106324
|
observations.forEach((obs) => {
|
|
105709
|
-
|
|
106325
|
+
var _a;
|
|
106326
|
+
const obsTokens = ((_a = obs.usageDetails) == null ? void 0 : _a.total) ?? obs.totalUsage ?? obs.totalTokens;
|
|
106327
|
+
totalTokens += typeof obsTokens === "number" ? obsTokens : parseInt(String(obsTokens || 0), 10) || 0;
|
|
105710
106328
|
const cost = parseFloat(obs.totalCost || "0");
|
|
105711
106329
|
if (!isNaN(cost)) totalCost += cost;
|
|
105712
106330
|
const startMs = new Date(obs.startTime).getTime();
|
|
@@ -105729,7 +106347,15 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
105729
106347
|
);
|
|
105730
106348
|
const generation = sorted.find((obs) => obs.type === "GENERATION");
|
|
105731
106349
|
if (!generation) {
|
|
105732
|
-
|
|
106350
|
+
const tree = this.buildObservationTree(observations);
|
|
106351
|
+
if (tree.length === 0) return { observation: null, ancestorIds: [] };
|
|
106352
|
+
const findFirstLeaf = (node) => {
|
|
106353
|
+
if (node.children.length === 0) return node;
|
|
106354
|
+
return findFirstLeaf(node.children[0]);
|
|
106355
|
+
};
|
|
106356
|
+
const leafNode = findFirstLeaf(tree[0]);
|
|
106357
|
+
const ancestorIds2 = this.getAncestorIds(observations, leafNode.observation.id);
|
|
106358
|
+
return { observation: leafNode.observation, ancestorIds: ancestorIds2 };
|
|
105733
106359
|
}
|
|
105734
106360
|
const ancestorIds = this.getAncestorIds(observations, generation.id);
|
|
105735
106361
|
return { observation: generation, ancestorIds };
|
|
@@ -105876,6 +106502,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
105876
106502
|
"toolNode",
|
|
105877
106503
|
"agent_toolNode",
|
|
105878
106504
|
"PreProcessor",
|
|
106505
|
+
"PostProcessor",
|
|
105879
106506
|
"MergerNode"
|
|
105880
106507
|
]
|
|
105881
106508
|
}
|
|
@@ -106135,6 +106762,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106135
106762
|
* Transform API trace response to TraceDetailData
|
|
106136
106763
|
*/
|
|
106137
106764
|
transformToTraceDetailData(trace) {
|
|
106765
|
+
const piiDisplay = TraceTreeService.extractPiiDisplayFromApiTrace(trace);
|
|
106138
106766
|
return {
|
|
106139
106767
|
id: trace.id,
|
|
106140
106768
|
name: trace.name || "",
|
|
@@ -106147,6 +106775,8 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106147
106775
|
input: trace.input,
|
|
106148
106776
|
output: trace.output,
|
|
106149
106777
|
metadata: trace.metadata,
|
|
106778
|
+
displayUserMessage: piiDisplay.displayUserMessage,
|
|
106779
|
+
displayAppResponse: piiDisplay.displayAppResponse,
|
|
106150
106780
|
tags: trace.tags || [],
|
|
106151
106781
|
bookmarked: trace.bookmarked || false,
|
|
106152
106782
|
public: trace.public || false,
|
|
@@ -106208,6 +106838,8 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106208
106838
|
timestamp: trace.timestamp,
|
|
106209
106839
|
input: trace.input,
|
|
106210
106840
|
output: trace.output,
|
|
106841
|
+
displayUserMessage: trace.displayUserMessage,
|
|
106842
|
+
displayAppResponse: trace.displayAppResponse,
|
|
106211
106843
|
latency: trace.latency,
|
|
106212
106844
|
totalTokens: trace.totalTokens,
|
|
106213
106845
|
totalCost: typeof trace.totalCost === "number" ? String(trace.totalCost) : trace.totalCost,
|
|
@@ -106361,6 +106993,19 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106361
106993
|
name
|
|
106362
106994
|
};
|
|
106363
106995
|
}
|
|
106996
|
+
function getObservationTokens(obs) {
|
|
106997
|
+
var _a;
|
|
106998
|
+
const total = ((_a = obs.usageDetails) == null ? void 0 : _a.total) ?? obs.totalUsage ?? obs.totalTokens;
|
|
106999
|
+
if (total === void 0 || total === null) return 0;
|
|
107000
|
+
return typeof total === "number" ? total : parseInt(String(total), 10) || 0;
|
|
107001
|
+
}
|
|
107002
|
+
function getAggregatedTotalTokens(node) {
|
|
107003
|
+
let sum2 = getObservationTokens(node.observation);
|
|
107004
|
+
node.children.forEach((child) => {
|
|
107005
|
+
sum2 += getAggregatedTotalTokens(child);
|
|
107006
|
+
});
|
|
107007
|
+
return sum2;
|
|
107008
|
+
}
|
|
106364
107009
|
const SuccessIcon = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
106365
107010
|
/* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "6", cy: "6", r: "5.5", fill: "#17B26A" }),
|
|
106366
107011
|
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M4 6L5.5 7.5L8 4.5", stroke: "white", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
@@ -106422,7 +107067,11 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106422
107067
|
return observation.name || observation.type || "";
|
|
106423
107068
|
};
|
|
106424
107069
|
const displayName = getDisplayName2();
|
|
106425
|
-
const displayTokens = ((_d = observation.usageDetails) == null ? void 0 : _d.total)
|
|
107070
|
+
const displayTokens = ((_d = observation.usageDetails) == null ? void 0 : _d.total) ?? observation.totalUsage ?? observation.totalTokens;
|
|
107071
|
+
const aggregatedTotalTokens = React.useMemo(() => {
|
|
107072
|
+
if (!isSupervisorOrAgent) return 0;
|
|
107073
|
+
return getAggregatedTotalTokens(node);
|
|
107074
|
+
}, [node, isSupervisorOrAgent]);
|
|
106426
107075
|
const handleRowClick = () => {
|
|
106427
107076
|
if (hasChildren) {
|
|
106428
107077
|
onToggle(observation.id);
|
|
@@ -106469,34 +107118,43 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106469
107118
|
className: "w-[24px] h-[24px] rounded-[8px]"
|
|
106470
107119
|
}
|
|
106471
107120
|
) }),
|
|
106472
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
106473
|
-
|
|
106474
|
-
isSupervisorOrAgent &&
|
|
106475
|
-
|
|
106476
|
-
|
|
107121
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-[2px] flex-1 min-w-0", children: [
|
|
107122
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold text-[12px] leading-[16px] text-[#101828] truncate", title: displayName, children: displayName }),
|
|
107123
|
+
isSupervisorOrAgent && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[6px] flex-wrap text-[10px] leading-[12px] text-[#667085] font-normal", children: [
|
|
107124
|
+
modelFromMetadata || observation.model ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate", children: modelFromMetadata || observation.model }) : null,
|
|
107125
|
+
aggregatedTotalTokens > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
107126
|
+
(modelFromMetadata || observation.model) && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "·" }),
|
|
107127
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "whitespace-nowrap", children: [
|
|
107128
|
+
TraceTreeService.formatTokens(aggregatedTotalTokens),
|
|
107129
|
+
" Tokens"
|
|
107130
|
+
] })
|
|
107131
|
+
] }),
|
|
107132
|
+
duration > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
107133
|
+
modelFromMetadata || observation.model || aggregatedTotalTokens > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "·" }) : null,
|
|
107134
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "whitespace-nowrap flex items-center gap-[4px]", children: [
|
|
107135
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ClockIcon, {}),
|
|
107136
|
+
TraceTreeService.formatDuration(duration)
|
|
107137
|
+
] })
|
|
107138
|
+
] })
|
|
107139
|
+
] })
|
|
107140
|
+
] }),
|
|
107141
|
+
!isSupervisorOrAgent && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[8px] flex-shrink-0", children: [
|
|
107142
|
+
isGeneration && displayTokens !== void 0 && Number(displayTokens) > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[10px] leading-[12px] text-[#667085] font-normal whitespace-nowrap", children: [
|
|
107143
|
+
TraceTreeService.formatTokens(Number(displayTokens)),
|
|
106477
107144
|
" Tokens"
|
|
106478
107145
|
] }),
|
|
106479
107146
|
duration > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[4px]", children: [
|
|
106480
107147
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ClockIcon, {}),
|
|
106481
107148
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] leading-[12px] text-[#667085] font-normal whitespace-nowrap", children: TraceTreeService.formatDuration(duration) })
|
|
106482
107149
|
] }),
|
|
106483
|
-
isError && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
106484
|
-
|
|
106485
|
-
{
|
|
106486
|
-
className: "flex-shrink-0 cursor-help",
|
|
106487
|
-
title: statusTooltip,
|
|
106488
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorIcon, {})
|
|
106489
|
-
}
|
|
106490
|
-
),
|
|
106491
|
-
isWarning && !isError && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
106492
|
-
"div",
|
|
106493
|
-
{
|
|
106494
|
-
className: "flex-shrink-0 cursor-help",
|
|
106495
|
-
title: statusTooltip,
|
|
106496
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(WarningIcon, {})
|
|
106497
|
-
}
|
|
106498
|
-
),
|
|
107150
|
+
isError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 cursor-help", title: statusTooltip, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorIcon, {}) }),
|
|
107151
|
+
isWarning && !isError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 cursor-help", title: statusTooltip, children: /* @__PURE__ */ jsxRuntimeExports.jsx(WarningIcon, {}) }),
|
|
106499
107152
|
isCompleted && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SuccessIcon, {}) })
|
|
107153
|
+
] }),
|
|
107154
|
+
isSupervisorOrAgent && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0 flex items-center", children: [
|
|
107155
|
+
isError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "cursor-help", title: statusTooltip, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorIcon, {}) }),
|
|
107156
|
+
isWarning && !isError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "cursor-help", title: statusTooltip, children: /* @__PURE__ */ jsxRuntimeExports.jsx(WarningIcon, {}) }),
|
|
107157
|
+
isCompleted && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SuccessIcon, {}) })
|
|
106500
107158
|
] })
|
|
106501
107159
|
]
|
|
106502
107160
|
}
|
|
@@ -106534,8 +107192,10 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106534
107192
|
onNodeSelect,
|
|
106535
107193
|
onExpandToggle,
|
|
106536
107194
|
showTraceId = true,
|
|
107195
|
+
onTraceIdClick,
|
|
106537
107196
|
isLoading = false,
|
|
106538
|
-
defaultExpandedNodeIds
|
|
107197
|
+
defaultExpandedNodeIds,
|
|
107198
|
+
runHeaderInputMode = "display"
|
|
106539
107199
|
}) {
|
|
106540
107200
|
const [isExpanded, setIsExpanded] = React.useState(defaultExpanded);
|
|
106541
107201
|
const [expandedNodeIds, setExpandedNodeIds] = React.useState(
|
|
@@ -106553,11 +107213,20 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106553
107213
|
return TraceTreeService.buildObservationTree(observations);
|
|
106554
107214
|
}, [observations]);
|
|
106555
107215
|
const userMessage = React.useMemo(() => {
|
|
107216
|
+
if (runHeaderInputMode !== "tokenized" && trace.displayUserMessage !== void 0 && trace.displayUserMessage.length > 0) {
|
|
107217
|
+
return trace.displayUserMessage;
|
|
107218
|
+
}
|
|
106556
107219
|
return TraceTreeService.extractUserMessage(trace.input);
|
|
106557
|
-
}, [trace.input]);
|
|
107220
|
+
}, [trace.input, trace.displayUserMessage, runHeaderInputMode]);
|
|
106558
107221
|
const appResponse = React.useMemo(() => {
|
|
107222
|
+
if (runHeaderInputMode !== "tokenized" && trace.displayAppResponse !== void 0 && trace.displayAppResponse.length > 0) {
|
|
107223
|
+
return trace.displayAppResponse;
|
|
107224
|
+
}
|
|
106559
107225
|
return TraceTreeService.extractAppResponse(trace.output);
|
|
106560
|
-
}, [trace.output]);
|
|
107226
|
+
}, [trace.output, trace.displayAppResponse, runHeaderInputMode]);
|
|
107227
|
+
const traceMetrics = React.useMemo(() => {
|
|
107228
|
+
return TraceTreeService.calculateTraceMetrics(trace, observations);
|
|
107229
|
+
}, [trace, observations]);
|
|
106561
107230
|
const handleTraceToggle = React.useCallback(() => {
|
|
106562
107231
|
setIsExpanded((prev) => !prev);
|
|
106563
107232
|
onExpandToggle == null ? void 0 : onExpandToggle();
|
|
@@ -106584,7 +107253,16 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106584
107253
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-[4px] w-full mb-[8px]", children: [
|
|
106585
107254
|
showTraceId && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-[8px] items-center px-0 py-[4px] w-full", children: [
|
|
106586
107255
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] leading-[12px] text-[#98A2B3]", children: "Trace ID" }),
|
|
106587
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
107256
|
+
onTraceIdClick ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
107257
|
+
"button",
|
|
107258
|
+
{
|
|
107259
|
+
onClick: () => onTraceIdClick(trace.id),
|
|
107260
|
+
className: "font-medium text-[10px] leading-[12px] text-[#155EEF] hover:underline cursor-pointer bg-transparent border-none p-0",
|
|
107261
|
+
title: "View Trace Details",
|
|
107262
|
+
"data-test-id": `trace-tree-id-link-${trace.id}`,
|
|
107263
|
+
children: trace.id
|
|
107264
|
+
}
|
|
107265
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-[10px] leading-[12px] text-[#667085]", children: trace.id }),
|
|
106588
107266
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
106589
107267
|
"button",
|
|
106590
107268
|
{
|
|
@@ -106659,10 +107337,18 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106659
107337
|
rootNode.observation.id
|
|
106660
107338
|
)) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-[16px] text-[12px] text-[#667085] text-center", children: "No observations available" }) }),
|
|
106661
107339
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white flex flex-col gap-[8px] p-[12px] border-t border-[#EAECF0]", children: [
|
|
106662
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
106663
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
106664
|
-
|
|
106665
|
-
|
|
107340
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-[8px] items-center w-full", children: [
|
|
107341
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-[8px] items-center flex-1 min-w-0", children: [
|
|
107342
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AppResponseIcon, {}),
|
|
107343
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold text-[11px] leading-[14px] text-[#98A2B3] uppercase tracking-[0.02em]", children: "APP RESPONSE" })
|
|
107344
|
+
] }),
|
|
107345
|
+
(traceMetrics.latency > 0 || traceMetrics.totalTokens > 0) && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[10px] leading-[12px] text-[#667085] font-normal whitespace-nowrap flex-shrink-0", children: [
|
|
107346
|
+
TraceTreeService.formatDuration(traceMetrics.latency),
|
|
107347
|
+
" · ",
|
|
107348
|
+
TraceTreeService.formatTokens(traceMetrics.totalTokens),
|
|
107349
|
+
" Tokens"
|
|
107350
|
+
] })
|
|
107351
|
+
] }),
|
|
106666
107352
|
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-medium text-[12px] leading-[16px] text-[#101828]", children: appResponse ? appResponse.length > 150 && !isResponseExpanded ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
106667
107353
|
appResponse.substring(0, 150),
|
|
106668
107354
|
"...",
|
|
@@ -106695,114 +107381,6 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
106695
107381
|
] })
|
|
106696
107382
|
] });
|
|
106697
107383
|
}
|
|
106698
|
-
const CopyButton$1 = ({
|
|
106699
|
-
text,
|
|
106700
|
-
className = "",
|
|
106701
|
-
iconClassName = "",
|
|
106702
|
-
iconStyle,
|
|
106703
|
-
title = "Copy to clipboard",
|
|
106704
|
-
onCopySuccess,
|
|
106705
|
-
onCopyError,
|
|
106706
|
-
tooltipText = "Copied!",
|
|
106707
|
-
tooltipPosition = "bottom",
|
|
106708
|
-
size = "md"
|
|
106709
|
-
}) => {
|
|
106710
|
-
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
106711
|
-
const getSizeClasses = () => {
|
|
106712
|
-
switch (size) {
|
|
106713
|
-
case "sm":
|
|
106714
|
-
return {
|
|
106715
|
-
button: "p-1",
|
|
106716
|
-
icon: "w-[12px] h-[12px]",
|
|
106717
|
-
tooltip: "text-xs py-1 px-2"
|
|
106718
|
-
};
|
|
106719
|
-
case "lg":
|
|
106720
|
-
return {
|
|
106721
|
-
button: "p-2",
|
|
106722
|
-
icon: "w-[20px] h-[20px]",
|
|
106723
|
-
tooltip: "text-sm py-2 px-3"
|
|
106724
|
-
};
|
|
106725
|
-
default:
|
|
106726
|
-
return {
|
|
106727
|
-
button: "p-1.5",
|
|
106728
|
-
icon: "w-[16px] h-[16px]",
|
|
106729
|
-
tooltip: "text-xs py-1 px-2"
|
|
106730
|
-
};
|
|
106731
|
-
}
|
|
106732
|
-
};
|
|
106733
|
-
const getTooltipPositionClasses = () => {
|
|
106734
|
-
const baseClasses = "absolute bg-gray-800 text-white rounded whitespace-nowrap z-50";
|
|
106735
|
-
switch (tooltipPosition) {
|
|
106736
|
-
case "bottom":
|
|
106737
|
-
return `${baseClasses} top-full mt-1 left-1/2 -translate-x-1/2`;
|
|
106738
|
-
case "left":
|
|
106739
|
-
return `${baseClasses} right-full mr-1 top-1/2 -translate-y-1/2`;
|
|
106740
|
-
case "right":
|
|
106741
|
-
return `${baseClasses} left-full ml-1 top-1/2 -translate-y-1/2`;
|
|
106742
|
-
default:
|
|
106743
|
-
return `${baseClasses} bottom-full mb-1 left-1/2 -translate-x-1/2`;
|
|
106744
|
-
}
|
|
106745
|
-
};
|
|
106746
|
-
const sizeClasses2 = getSizeClasses();
|
|
106747
|
-
const showCopyTooltip = React.useCallback(() => {
|
|
106748
|
-
setShowTooltip(true);
|
|
106749
|
-
setTimeout(() => setShowTooltip(false), 1e3);
|
|
106750
|
-
}, []);
|
|
106751
|
-
const copyToClipboard2 = React.useCallback(async () => {
|
|
106752
|
-
try {
|
|
106753
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
106754
|
-
await navigator.clipboard.writeText(text);
|
|
106755
|
-
showCopyTooltip();
|
|
106756
|
-
onCopySuccess == null ? void 0 : onCopySuccess();
|
|
106757
|
-
return;
|
|
106758
|
-
}
|
|
106759
|
-
const textArea = document.createElement("textarea");
|
|
106760
|
-
textArea.value = text;
|
|
106761
|
-
textArea.style.position = "fixed";
|
|
106762
|
-
textArea.style.left = "-999999px";
|
|
106763
|
-
textArea.style.top = "-999999px";
|
|
106764
|
-
document.body.appendChild(textArea);
|
|
106765
|
-
textArea.focus();
|
|
106766
|
-
textArea.select();
|
|
106767
|
-
try {
|
|
106768
|
-
document.execCommand("copy");
|
|
106769
|
-
showCopyTooltip();
|
|
106770
|
-
onCopySuccess == null ? void 0 : onCopySuccess();
|
|
106771
|
-
} catch (err) {
|
|
106772
|
-
const error = err instanceof Error ? err : new Error("Copy failed");
|
|
106773
|
-
console.warn("Copy to clipboard failed:", error);
|
|
106774
|
-
onCopyError == null ? void 0 : onCopyError(error);
|
|
106775
|
-
} finally {
|
|
106776
|
-
document.body.removeChild(textArea);
|
|
106777
|
-
}
|
|
106778
|
-
} catch (err) {
|
|
106779
|
-
const error = err instanceof Error ? err : new Error("Copy failed");
|
|
106780
|
-
console.warn("Copy to clipboard failed:", error);
|
|
106781
|
-
onCopyError == null ? void 0 : onCopyError(error);
|
|
106782
|
-
}
|
|
106783
|
-
}, [text, showCopyTooltip, onCopySuccess, onCopyError]);
|
|
106784
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative inline-flex", children: [
|
|
106785
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
106786
|
-
"button",
|
|
106787
|
-
{
|
|
106788
|
-
onClick: copyToClipboard2,
|
|
106789
|
-
className: `${sizeClasses2.button} hover:bg-gray-100 rounded transition-colors ${className}`,
|
|
106790
|
-
title,
|
|
106791
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { className: `${sizeClasses2.icon} text-gray-400 ${iconClassName}`, style: iconStyle })
|
|
106792
|
-
}
|
|
106793
|
-
),
|
|
106794
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
106795
|
-
"div",
|
|
106796
|
-
{
|
|
106797
|
-
className: `${getTooltipPositionClasses()} ${sizeClasses2.tooltip} transition-opacity duration-150 ${showTooltip ? "opacity-100 animate-fade-in" : "opacity-0 pointer-events-none"}`,
|
|
106798
|
-
style: {
|
|
106799
|
-
visibility: showTooltip ? "visible" : "hidden"
|
|
106800
|
-
},
|
|
106801
|
-
children: tooltipText
|
|
106802
|
-
}
|
|
106803
|
-
)
|
|
106804
|
-
] });
|
|
106805
|
-
};
|
|
106806
107384
|
function __awaiter(thisArg, _arguments, P2, generator) {
|
|
106807
107385
|
function adopt(value) {
|
|
106808
107386
|
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
@@ -107967,21 +108545,35 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
107967
108545
|
)
|
|
107968
108546
|
] })
|
|
107969
108547
|
] }),
|
|
107970
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
107971
|
-
|
|
108548
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
108549
|
+
"div",
|
|
107972
108550
|
{
|
|
107973
|
-
|
|
107974
|
-
|
|
107975
|
-
|
|
107976
|
-
|
|
107977
|
-
|
|
107978
|
-
|
|
107979
|
-
|
|
107980
|
-
|
|
107981
|
-
|
|
107982
|
-
|
|
108551
|
+
className: "flex-1 overflow-auto bg-gray-800 p-4",
|
|
108552
|
+
style: {
|
|
108553
|
+
"--json-property": "#ffffff",
|
|
108554
|
+
"--json-index": "#e2e8f0",
|
|
108555
|
+
"--json-number": "#e2e8f0",
|
|
108556
|
+
"--json-string": "#e2e8f0",
|
|
108557
|
+
"--json-boolean": "#e2e8f0",
|
|
108558
|
+
"--json-null": "#e2e8f0"
|
|
108559
|
+
},
|
|
108560
|
+
children: viewMode === "interactive" && useEnhancedJsonView ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
108561
|
+
JsonView,
|
|
108562
|
+
{
|
|
108563
|
+
src: parsedData,
|
|
108564
|
+
dark: true,
|
|
108565
|
+
collapseObjectsAfterLength: 20,
|
|
108566
|
+
collapseStringsAfterLength: 500,
|
|
108567
|
+
collapseStringMode: "word",
|
|
108568
|
+
displaySize: "collapsed",
|
|
108569
|
+
matchesURL: true,
|
|
108570
|
+
customizeCopy: (node) => stringifyJsonNode(node),
|
|
108571
|
+
className: "w-full text-xs",
|
|
108572
|
+
style: { color: "#f1f5f9" }
|
|
108573
|
+
}
|
|
108574
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs whitespace-pre text-white font-mono", children: stringifyJsonNode(parsedData) })
|
|
107983
108575
|
}
|
|
107984
|
-
)
|
|
108576
|
+
)
|
|
107985
108577
|
] }) });
|
|
107986
108578
|
};
|
|
107987
108579
|
const JsonViewer = ({
|
|
@@ -108349,6 +108941,23 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108349
108941
|
function isObservation(node) {
|
|
108350
108942
|
return node !== null && "traceId" in node && "type" in node;
|
|
108351
108943
|
}
|
|
108944
|
+
function metadataForDisplay(metadata) {
|
|
108945
|
+
if (metadata === null || metadata === void 0) return {};
|
|
108946
|
+
let obj;
|
|
108947
|
+
if (typeof metadata === "string") {
|
|
108948
|
+
try {
|
|
108949
|
+
obj = JSON.parse(metadata);
|
|
108950
|
+
} catch {
|
|
108951
|
+
return {};
|
|
108952
|
+
}
|
|
108953
|
+
} else if (typeof metadata === "object") {
|
|
108954
|
+
obj = metadata;
|
|
108955
|
+
} else {
|
|
108956
|
+
return {};
|
|
108957
|
+
}
|
|
108958
|
+
const { tools: _tools, ...rest } = obj;
|
|
108959
|
+
return rest;
|
|
108960
|
+
}
|
|
108352
108961
|
const defaultMetrics = {
|
|
108353
108962
|
totalCost: "0",
|
|
108354
108963
|
totalTokens: 0,
|
|
@@ -108397,7 +109006,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108397
109006
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-[1px] bg-[#EAECF0]" })
|
|
108398
109007
|
] });
|
|
108399
109008
|
}
|
|
108400
|
-
function PreviewContent({ input, output, metadata, statusMessage, isLoading = false
|
|
109009
|
+
function PreviewContent({ input, output, metadata, statusMessage, isLoading = false }) {
|
|
108401
109010
|
const [showAllMetadata, setShowAllMetadata] = React.useState(false);
|
|
108402
109011
|
const messages = React.useMemo(() => {
|
|
108403
109012
|
if (!input || typeof input !== "object") return null;
|
|
@@ -108429,15 +109038,6 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108429
109038
|
}
|
|
108430
109039
|
return String(output);
|
|
108431
109040
|
}, [output]);
|
|
108432
|
-
const modelName = React.useMemo(() => {
|
|
108433
|
-
if (!input || typeof input !== "object") return null;
|
|
108434
|
-
return input["model"] ?? null;
|
|
108435
|
-
}, [input]);
|
|
108436
|
-
const formatParamValue = (value) => {
|
|
108437
|
-
if (value === null || value === void 0) return "";
|
|
108438
|
-
if (typeof value === "object") return JSON.stringify(value);
|
|
108439
|
-
return String(value);
|
|
108440
|
-
};
|
|
108441
109041
|
if (isLoading) {
|
|
108442
109042
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-[16px] p-[16px] overflow-y-auto h-full", children: [
|
|
108443
109043
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
|
|
@@ -108451,29 +109051,6 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108451
109051
|
] });
|
|
108452
109052
|
}
|
|
108453
109053
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-[20px] p-[16px] overflow-y-auto h-full", children: [
|
|
108454
|
-
(modelName || modelParameters && Object.keys(modelParameters).length > 0) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-[6px]", children: [
|
|
108455
|
-
modelName && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "px-[8px] py-[4px] bg-[#F2F4F7] rounded-[4px] text-[11px] font-medium text-[#344054]", children: [
|
|
108456
|
-
"Model: ",
|
|
108457
|
-
modelName
|
|
108458
|
-
] }),
|
|
108459
|
-
modelParameters && typeof modelParameters === "object" && Object.entries(modelParameters).filter(([_2, value]) => value !== null && value !== void 0).map(([key, value]) => {
|
|
108460
|
-
const valueString = formatParamValue(value);
|
|
108461
|
-
const displayKey = key.replace(/_/g, " ");
|
|
108462
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
108463
|
-
"span",
|
|
108464
|
-
{
|
|
108465
|
-
className: "px-[8px] py-[4px] bg-[#F2F4F7] border border-[#EAECF0] rounded-[4px] text-[11px] font-medium text-[#344054] max-w-[200px] truncate",
|
|
108466
|
-
title: `${key}: ${valueString}`,
|
|
108467
|
-
children: [
|
|
108468
|
-
displayKey,
|
|
108469
|
-
": ",
|
|
108470
|
-
valueString
|
|
108471
|
-
]
|
|
108472
|
-
},
|
|
108473
|
-
key
|
|
108474
|
-
);
|
|
108475
|
-
})
|
|
108476
|
-
] }),
|
|
108477
109054
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
108478
109055
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SectionHeader, { title: "Input" }),
|
|
108479
109056
|
messages ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-[8px]", children: messages.map((msg, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -108560,14 +109137,21 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108560
109137
|
showHeader: true,
|
|
108561
109138
|
useEnhancedJsonView: true,
|
|
108562
109139
|
collapseStringsAfterLength: 500,
|
|
108563
|
-
collapseObjectsAfterLength: 20,
|
|
109140
|
+
collapseObjectsAfterLength: selectedTab === "metadata" ? 100 : 20,
|
|
109141
|
+
defaultExpanded: selectedTab === "metadata",
|
|
108564
109142
|
maxHeight: "100%",
|
|
108565
109143
|
className: "h-full border-0 rounded-none"
|
|
108566
|
-
}
|
|
109144
|
+
},
|
|
109145
|
+
selectedTab
|
|
108567
109146
|
) })
|
|
108568
109147
|
] });
|
|
108569
109148
|
}
|
|
108570
|
-
function NodeDetailPanel({
|
|
109149
|
+
function NodeDetailPanel({
|
|
109150
|
+
node,
|
|
109151
|
+
nodeType: _nodeType,
|
|
109152
|
+
apiConfig,
|
|
109153
|
+
generationSummaryInputOverride = null
|
|
109154
|
+
}) {
|
|
108571
109155
|
const [selectedTab, setSelectedTab] = React.useState("preview");
|
|
108572
109156
|
const [showTokenTooltip, setShowTokenTooltip] = React.useState(false);
|
|
108573
109157
|
const tooltipTimeoutRef = React.useRef(null);
|
|
@@ -108654,6 +109238,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108654
109238
|
}
|
|
108655
109239
|
return TraceTreeService.extractUserMessage(displayNode.input);
|
|
108656
109240
|
}, [displayNode]);
|
|
109241
|
+
const summaryInputLine = generationSummaryInputOverride !== null && generationSummaryInputOverride.length > 0 ? generationSummaryInputOverride : inputText;
|
|
108657
109242
|
const isGeneration = React.useMemo(() => {
|
|
108658
109243
|
return node !== null && isObservation(node) && node.type === "GENERATION";
|
|
108659
109244
|
}, [node]);
|
|
@@ -108737,7 +109322,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108737
109322
|
case "response":
|
|
108738
109323
|
return displayNode.output || {};
|
|
108739
109324
|
case "metadata":
|
|
108740
|
-
return isObservation(displayNode) ? displayNode.metadata || {} : {};
|
|
109325
|
+
return isObservation(displayNode) ? metadataForDisplay(displayNode.metadata || {}) : {};
|
|
108741
109326
|
case "logs":
|
|
108742
109327
|
return {
|
|
108743
109328
|
id: isObservation(displayNode) ? displayNode.id : displayNode.id,
|
|
@@ -108757,11 +109342,17 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108757
109342
|
return {
|
|
108758
109343
|
input: formattedInput,
|
|
108759
109344
|
output: displayNode.output || {},
|
|
108760
|
-
metadata: isObservation(displayNode) ? displayNode.metadata || {} : {},
|
|
109345
|
+
metadata: isObservation(displayNode) ? metadataForDisplay(displayNode.metadata || {}) : {},
|
|
108761
109346
|
statusMessage: isObservation(displayNode) ? displayNode.statusMessage : void 0,
|
|
108762
109347
|
modelParameters: isObservation(displayNode) ? displayNode.modelParameters : void 0
|
|
108763
109348
|
};
|
|
108764
109349
|
}, [displayNode, formattedInput]);
|
|
109350
|
+
const summaryModelInfo = React.useMemo(() => {
|
|
109351
|
+
if (!isGeneration || !displayNode) return { modelName: null, modelParameters: {} };
|
|
109352
|
+
const modelName = typeof formattedInput === "object" && formattedInput !== null && "model" in formattedInput ? formattedInput.model ?? null : null;
|
|
109353
|
+
const modelParameters = isObservation(displayNode) && displayNode.modelParameters && typeof displayNode.modelParameters === "object" ? displayNode.modelParameters : {};
|
|
109354
|
+
return { modelName, modelParameters };
|
|
109355
|
+
}, [isGeneration, displayNode, formattedInput]);
|
|
108765
109356
|
const tokenTooltipContent = metrics.totalTokens > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
108766
109357
|
"div",
|
|
108767
109358
|
{
|
|
@@ -108854,10 +109445,10 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108854
109445
|
] })
|
|
108855
109446
|
),
|
|
108856
109447
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ContentDivider, {}),
|
|
108857
|
-
isGeneration &&
|
|
109448
|
+
isGeneration && summaryInputLine.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
108858
109449
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-[8px]", children: [
|
|
108859
109450
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[12px] font-medium leading-[16px] text-[#98A2B3]", children: "Input" }),
|
|
108860
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[12px] font-medium leading-[16px] text-[#101828] truncate", children:
|
|
109451
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[12px] font-medium leading-[16px] text-[#101828] truncate", children: summaryInputLine })
|
|
108861
109452
|
] }),
|
|
108862
109453
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ContentDivider, {})
|
|
108863
109454
|
] }),
|
|
@@ -108873,6 +109464,37 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108873
109464
|
] })
|
|
108874
109465
|
] }),
|
|
108875
109466
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ContentDivider, {})
|
|
109467
|
+
] }),
|
|
109468
|
+
isGeneration && (summaryModelInfo.modelName || Object.keys(summaryModelInfo.modelParameters).length > 0) && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
109469
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-[8px]", children: [
|
|
109470
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[12px] font-medium leading-[16px] text-[#98A2B3]", children: "Model parameters" }),
|
|
109471
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-[6px]", children: [
|
|
109472
|
+
summaryModelInfo.modelName && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "px-[8px] py-[4px] bg-[#F2F4F7] rounded-[4px] text-[11px] font-medium text-[#344054]", children: [
|
|
109473
|
+
"Model: ",
|
|
109474
|
+
summaryModelInfo.modelName
|
|
109475
|
+
] }),
|
|
109476
|
+
Object.entries(summaryModelInfo.modelParameters).filter(
|
|
109477
|
+
([_2, value]) => value !== null && value !== void 0
|
|
109478
|
+
).map(([key, value]) => {
|
|
109479
|
+
const valueStr = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
109480
|
+
const displayKey = key.replace(/_/g, " ");
|
|
109481
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
109482
|
+
"span",
|
|
109483
|
+
{
|
|
109484
|
+
className: "px-[8px] py-[4px] bg-[#F2F4F7] border border-[#EAECF0] rounded-[4px] text-[11px] font-medium text-[#344054] max-w-[200px] truncate",
|
|
109485
|
+
title: `${key}: ${valueStr}`,
|
|
109486
|
+
children: [
|
|
109487
|
+
displayKey,
|
|
109488
|
+
": ",
|
|
109489
|
+
valueStr
|
|
109490
|
+
]
|
|
109491
|
+
},
|
|
109492
|
+
key
|
|
109493
|
+
);
|
|
109494
|
+
})
|
|
109495
|
+
] })
|
|
109496
|
+
] }),
|
|
109497
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ContentDivider, {})
|
|
108876
109498
|
] })
|
|
108877
109499
|
] })
|
|
108878
109500
|
] }),
|
|
@@ -108900,7 +109522,8 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
108900
109522
|
selectedObservationId,
|
|
108901
109523
|
batchSize = DEFAULT_BATCH_SIZE,
|
|
108902
109524
|
initialTraceCount,
|
|
108903
|
-
initialSessionData
|
|
109525
|
+
initialSessionData,
|
|
109526
|
+
runHeaderInputMode = "display"
|
|
108904
109527
|
}) {
|
|
108905
109528
|
const [currentMode, setCurrentMode] = React.useState(initialMode);
|
|
108906
109529
|
const [currentSessionId, setCurrentSessionId] = React.useState(initialSessionId);
|
|
@@ -109141,12 +109764,52 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109141
109764
|
}, [mode, sessionData, traceData, sessionId, traceId, initialSessionData]);
|
|
109142
109765
|
const traces = React.useMemo(() => {
|
|
109143
109766
|
if (mode === "session" && sessionData) {
|
|
109144
|
-
|
|
109767
|
+
const sorted = [...sessionData.traces].sort((a2, b) => {
|
|
109768
|
+
const tA = a2.timestamp ? new Date(a2.timestamp).getTime() : 0;
|
|
109769
|
+
const tB = b.timestamp ? new Date(b.timestamp).getTime() : 0;
|
|
109770
|
+
return tA - tB;
|
|
109771
|
+
});
|
|
109772
|
+
return sorted.map((t) => service.transformToTraceData(t));
|
|
109145
109773
|
} else if (mode === "trace" && traceData) {
|
|
109146
109774
|
return [service.transformToTraceData(traceData)];
|
|
109147
109775
|
}
|
|
109148
109776
|
return [];
|
|
109149
109777
|
}, [mode, sessionData, traceData, service]);
|
|
109778
|
+
const generationSummaryInputOverride = React.useMemo(() => {
|
|
109779
|
+
var _a;
|
|
109780
|
+
if (runHeaderInputMode === "tokenized") {
|
|
109781
|
+
return null;
|
|
109782
|
+
}
|
|
109783
|
+
if (!selectedNode || !("traceId" in selectedNode) || !("type" in selectedNode)) {
|
|
109784
|
+
return null;
|
|
109785
|
+
}
|
|
109786
|
+
const obs = selectedNode;
|
|
109787
|
+
if (obs.type !== "GENERATION") {
|
|
109788
|
+
return null;
|
|
109789
|
+
}
|
|
109790
|
+
const traceRow = traces.find((t) => t.id === obs.traceId);
|
|
109791
|
+
if (!traceRow) {
|
|
109792
|
+
return null;
|
|
109793
|
+
}
|
|
109794
|
+
const displayUser = traceRow.displayUserMessage && traceRow.displayUserMessage.length > 0 ? traceRow.displayUserMessage : TraceTreeService.extractUserMessage(traceRow.input);
|
|
109795
|
+
if (!displayUser || displayUser.length === 0) {
|
|
109796
|
+
return null;
|
|
109797
|
+
}
|
|
109798
|
+
const fromState = (_a = traceObservations[obs.traceId]) == null ? void 0 : _a.observations;
|
|
109799
|
+
const observations = fromState && fromState.length > 0 ? fromState : mode === "trace" && (traceData == null ? void 0 : traceData.id) === obs.traceId && traceData.observations.length > 0 ? traceData.observations : [];
|
|
109800
|
+
const { observation: firstGen } = TraceTreeService.findFirstGeneration(observations);
|
|
109801
|
+
if (!firstGen || firstGen.id !== obs.id) {
|
|
109802
|
+
return null;
|
|
109803
|
+
}
|
|
109804
|
+
return displayUser;
|
|
109805
|
+
}, [
|
|
109806
|
+
runHeaderInputMode,
|
|
109807
|
+
selectedNode,
|
|
109808
|
+
traces,
|
|
109809
|
+
traceObservations,
|
|
109810
|
+
mode,
|
|
109811
|
+
traceData
|
|
109812
|
+
]);
|
|
109150
109813
|
const handleNodeSelect = React.useCallback((node) => {
|
|
109151
109814
|
setSelectedNode(node);
|
|
109152
109815
|
}, []);
|
|
@@ -109195,6 +109858,23 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109195
109858
|
firstTraceId: null
|
|
109196
109859
|
});
|
|
109197
109860
|
}, []);
|
|
109861
|
+
const handleNavigateToTrace = React.useCallback((targetTraceId) => {
|
|
109862
|
+
setSelectedNode(null);
|
|
109863
|
+
setSessionData(null);
|
|
109864
|
+
setTraceData(null);
|
|
109865
|
+
setTraceObservations({});
|
|
109866
|
+
setLoadingState("idle");
|
|
109867
|
+
setError(null);
|
|
109868
|
+
setHasAutoSelected(false);
|
|
109869
|
+
setCurrentMode("trace");
|
|
109870
|
+
setCurrentTraceId(targetTraceId);
|
|
109871
|
+
setProgressiveState({
|
|
109872
|
+
traceCount: 0,
|
|
109873
|
+
pendingTraceIds: [],
|
|
109874
|
+
firstTraceLoaded: false,
|
|
109875
|
+
firstTraceId: null
|
|
109876
|
+
});
|
|
109877
|
+
}, []);
|
|
109198
109878
|
if (loadingState === "loading") {
|
|
109199
109879
|
const canShowHeader = mode === "session" && initialSessionData;
|
|
109200
109880
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col bg-white ${className}`, children: [
|
|
@@ -109363,8 +110043,10 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109363
110043
|
onNodeSelect: handleNodeSelect,
|
|
109364
110044
|
onExpandToggle: () => handleTraceExpand(trace.id, trace.timestamp),
|
|
109365
110045
|
showTraceId: mode === "session",
|
|
110046
|
+
onTraceIdClick: mode === "session" ? handleNavigateToTrace : void 0,
|
|
109366
110047
|
isLoading: isLoadingObservations,
|
|
109367
|
-
defaultExpandedNodeIds: autoExpandIds
|
|
110048
|
+
defaultExpandedNodeIds: autoExpandIds,
|
|
110049
|
+
runHeaderInputMode
|
|
109368
110050
|
},
|
|
109369
110051
|
trace.id
|
|
109370
110052
|
);
|
|
@@ -109384,7 +110066,15 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109384
110066
|
);
|
|
109385
110067
|
}) })
|
|
109386
110068
|
] }) }),
|
|
109387
|
-
!selectedNode && !hasAutoSelected ? /* @__PURE__ */ jsxRuntimeExports.jsx(NodeDetailSkeleton, { showFullSummary: true }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
110069
|
+
!selectedNode && !hasAutoSelected ? /* @__PURE__ */ jsxRuntimeExports.jsx(NodeDetailSkeleton, { showFullSummary: true }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
110070
|
+
NodeDetailPanel,
|
|
110071
|
+
{
|
|
110072
|
+
node: selectedNode,
|
|
110073
|
+
nodeType,
|
|
110074
|
+
apiConfig,
|
|
110075
|
+
generationSummaryInputOverride
|
|
110076
|
+
}
|
|
110077
|
+
)
|
|
109388
110078
|
] })
|
|
109389
110079
|
] });
|
|
109390
110080
|
}
|
|
@@ -109799,22 +110489,25 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109799
110489
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-600", title: envId || "-", children: displayName });
|
|
109800
110490
|
}
|
|
109801
110491
|
function SessionsListContent(props) {
|
|
109802
|
-
const { apiConfig, onSessionClick, className = "", defaultFilters = [], defaultTimeRange = "24 hours" } = props;
|
|
109803
|
-
const { environments } = useEnvironment();
|
|
109804
|
-
const [selectedSessionId, setSelectedSessionId] = React.useState(null);
|
|
110492
|
+
const { apiConfig, onSessionClick, className = "", defaultFilters = [], defaultTimeRange = "24 hours", initialSessionId } = props;
|
|
110493
|
+
const { environments, resolveEnvironmentName } = useEnvironment();
|
|
110494
|
+
const [selectedSessionId, setSelectedSessionId] = React.useState(() => initialSessionId ?? null);
|
|
109805
110495
|
const [selectedSessionData, setSelectedSessionData] = React.useState(null);
|
|
109806
|
-
const [isModalOpen, setIsModalOpen] = React.useState(
|
|
110496
|
+
const [isModalOpen, setIsModalOpen] = React.useState(() => !!initialSessionId);
|
|
109807
110497
|
const [sessions, setSessions] = React.useState([]);
|
|
109808
110498
|
const [totalCount, setTotalCount] = React.useState(0);
|
|
109809
110499
|
const [loading, setLoading] = React.useState(true);
|
|
109810
110500
|
const [hasInitiallyLoaded, setHasInitiallyLoaded] = React.useState(false);
|
|
110501
|
+
const [appVersionOptions, setAppVersionOptions] = React.useState([]);
|
|
110502
|
+
const [searchTerm, setSearchTerm] = React.useState("");
|
|
109811
110503
|
const initialFilters = React.useMemo(() => {
|
|
109812
110504
|
const hasEnvFilter = defaultFilters.some((f) => f.column === "envId");
|
|
109813
|
-
|
|
109814
|
-
|
|
110505
|
+
const base2 = hasEnvFilter ? defaultFilters : [createDraftEnvironmentFilter$1(), ...defaultFilters];
|
|
110506
|
+
if (initialSessionId) {
|
|
110507
|
+
return [...base2, { column: "id", type: "string", operator: "=", value: initialSessionId }];
|
|
109815
110508
|
}
|
|
109816
|
-
return
|
|
109817
|
-
}, [defaultFilters]);
|
|
110509
|
+
return base2;
|
|
110510
|
+
}, [defaultFilters, initialSessionId]);
|
|
109818
110511
|
const [filters, setFilters] = React.useState(initialFilters);
|
|
109819
110512
|
const [showFilterPanel, setShowFilterPanel] = React.useState(false);
|
|
109820
110513
|
const [showColumnCustomization, setShowColumnCustomization] = React.useState(false);
|
|
@@ -109823,6 +110516,32 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109823
110516
|
const [pagination, setPagination] = React.useState({ page: 0, limit: 50 });
|
|
109824
110517
|
const [orderBy, setOrderBy] = React.useState({ column: "createdAt", order: "DESC" });
|
|
109825
110518
|
const apiService = React.useMemo(() => new TracingApiService(apiConfig), [apiConfig]);
|
|
110519
|
+
React.useEffect(() => {
|
|
110520
|
+
if (initialSessionId) {
|
|
110521
|
+
setSelectedSessionId(initialSessionId);
|
|
110522
|
+
setIsModalOpen(true);
|
|
110523
|
+
}
|
|
110524
|
+
}, [initialSessionId]);
|
|
110525
|
+
React.useEffect(() => {
|
|
110526
|
+
const fetchAppVersions = async () => {
|
|
110527
|
+
try {
|
|
110528
|
+
const filterOptionsData = await apiService.fetchFilterOptions({
|
|
110529
|
+
projectId: apiConfig.projectId
|
|
110530
|
+
});
|
|
110531
|
+
if ((filterOptionsData == null ? void 0 : filterOptionsData.appvIds) && Array.isArray(filterOptionsData.appvIds)) {
|
|
110532
|
+
setAppVersionOptions(
|
|
110533
|
+
filterOptionsData.appvIds.map((item) => ({
|
|
110534
|
+
value: item.value,
|
|
110535
|
+
label: item.value
|
|
110536
|
+
}))
|
|
110537
|
+
);
|
|
110538
|
+
}
|
|
110539
|
+
} catch (error) {
|
|
110540
|
+
console.warn("Failed to fetch app version filter options:", error);
|
|
110541
|
+
}
|
|
110542
|
+
};
|
|
110543
|
+
fetchAppVersions();
|
|
110544
|
+
}, [apiService, apiConfig.projectId]);
|
|
109826
110545
|
const convertPresetToDateRange = (preset) => {
|
|
109827
110546
|
const now2 = /* @__PURE__ */ new Date();
|
|
109828
110547
|
let pastDate;
|
|
@@ -109884,7 +110603,6 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109884
110603
|
});
|
|
109885
110604
|
}
|
|
109886
110605
|
const allFilters = [...timeFilters, ...filters];
|
|
109887
|
-
if (apiConfig.projectId) ;
|
|
109888
110606
|
return allFilters;
|
|
109889
110607
|
}, [timeRange, filters]);
|
|
109890
110608
|
const fetchSessions = React.useCallback(async () => {
|
|
@@ -109944,6 +110662,28 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109944
110662
|
React.useEffect(() => {
|
|
109945
110663
|
fetchSessions();
|
|
109946
110664
|
}, [fetchSessions]);
|
|
110665
|
+
const filteredSessions = React.useMemo(() => {
|
|
110666
|
+
const term = searchTerm.trim().toLowerCase();
|
|
110667
|
+
if (!term) return sessions;
|
|
110668
|
+
return sessions.filter((session) => {
|
|
110669
|
+
var _a;
|
|
110670
|
+
const envName = ((_a = resolveEnvironmentName(session.envId)) == null ? void 0 : _a.toLowerCase()) || "";
|
|
110671
|
+
const searchableFields = [
|
|
110672
|
+
session.id,
|
|
110673
|
+
envName,
|
|
110674
|
+
session.envId,
|
|
110675
|
+
session.appvId,
|
|
110676
|
+
session.source,
|
|
110677
|
+
session.environment,
|
|
110678
|
+
session.sessionReference,
|
|
110679
|
+
session.userReference,
|
|
110680
|
+
...session.userIds || []
|
|
110681
|
+
];
|
|
110682
|
+
return searchableFields.some(
|
|
110683
|
+
(field) => field && String(field).toLowerCase().includes(term)
|
|
110684
|
+
);
|
|
110685
|
+
});
|
|
110686
|
+
}, [sessions, searchTerm, resolveEnvironmentName]);
|
|
109947
110687
|
const defaultColumns = React.useMemo(
|
|
109948
110688
|
() => [
|
|
109949
110689
|
{
|
|
@@ -109952,8 +110692,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
109952
110692
|
width: 320,
|
|
109953
110693
|
pinned: "left",
|
|
109954
110694
|
hide: false,
|
|
109955
|
-
|
|
109956
|
-
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-medium text-gray-900", title: params.value, children: TracingUtils.truncate(params.value, 30) })
|
|
110695
|
+
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableId, { value: params.value, truncateLength: 30 })
|
|
109957
110696
|
},
|
|
109958
110697
|
{
|
|
109959
110698
|
field: "envId",
|
|
@@ -110080,6 +110819,20 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110080
110819
|
disabled: true,
|
|
110081
110820
|
valueFormatter: (params) => TracingUtils.formatTokens(params.value),
|
|
110082
110821
|
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-700", children: TracingUtils.formatTokens(params.value) })
|
|
110822
|
+
},
|
|
110823
|
+
{
|
|
110824
|
+
field: "sessionReference",
|
|
110825
|
+
headerName: "Session Reference",
|
|
110826
|
+
width: 180,
|
|
110827
|
+
hide: true,
|
|
110828
|
+
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-700", title: params.value || "-", children: params.value || "-" })
|
|
110829
|
+
},
|
|
110830
|
+
{
|
|
110831
|
+
field: "identity",
|
|
110832
|
+
headerName: "User Reference",
|
|
110833
|
+
width: 180,
|
|
110834
|
+
hide: true,
|
|
110835
|
+
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-700", title: params.value || "-", children: params.value || "-" })
|
|
110083
110836
|
}
|
|
110084
110837
|
// {
|
|
110085
110838
|
// field: 'traceTags',
|
|
@@ -110199,8 +110952,9 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110199
110952
|
// User-friendly label
|
|
110200
110953
|
apiColumnName: "App Version ID",
|
|
110201
110954
|
// API expects "App Version ID" (koretracing uiTableName)
|
|
110202
|
-
type: "
|
|
110203
|
-
operators: ["
|
|
110955
|
+
type: "stringOptions",
|
|
110956
|
+
operators: ["any of", "none of"],
|
|
110957
|
+
options: appVersionOptions
|
|
110204
110958
|
},
|
|
110205
110959
|
{
|
|
110206
110960
|
field: "source",
|
|
@@ -110252,10 +111006,27 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110252
111006
|
// API expects "Output Tokens" (koretracing uiTableName)
|
|
110253
111007
|
type: "number",
|
|
110254
111008
|
operators: ["=", ">", ">=", "<", "<="]
|
|
111009
|
+
},
|
|
111010
|
+
{
|
|
111011
|
+
field: "sessionReference",
|
|
111012
|
+
label: "Session Reference",
|
|
111013
|
+
apiColumnName: "Session Reference",
|
|
111014
|
+
type: "string",
|
|
111015
|
+
operators: ["=", "!=", "contains"]
|
|
111016
|
+
},
|
|
111017
|
+
{
|
|
111018
|
+
field: "identity",
|
|
111019
|
+
label: "User Reference",
|
|
111020
|
+
apiColumnName: "User Reference",
|
|
111021
|
+
type: "string",
|
|
111022
|
+
operators: ["=", "!=", "contains"]
|
|
110255
111023
|
}
|
|
110256
111024
|
],
|
|
110257
|
-
[environments]
|
|
111025
|
+
[environments, appVersionOptions]
|
|
110258
111026
|
);
|
|
111027
|
+
const handleSearch = React.useCallback((term) => {
|
|
111028
|
+
setSearchTerm(term);
|
|
111029
|
+
}, []);
|
|
110259
111030
|
const handleTimeRangeChange = (value, presetLabel) => {
|
|
110260
111031
|
console.log("🗓️ SessionsList: Time range change requested:", value, presetLabel);
|
|
110261
111032
|
setTimeRange(value);
|
|
@@ -110297,6 +111068,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110297
111068
|
};
|
|
110298
111069
|
const handleClearFilters = () => {
|
|
110299
111070
|
setFilters([]);
|
|
111071
|
+
setSearchTerm("");
|
|
110300
111072
|
setTimeRange("24 hours");
|
|
110301
111073
|
};
|
|
110302
111074
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col w-full ${className}`, children: [
|
|
@@ -110305,11 +111077,19 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110305
111077
|
{
|
|
110306
111078
|
title: "Sessions",
|
|
110307
111079
|
description: "Review session logs and trace details to analyze conversation logs and app behavior.",
|
|
110308
|
-
|
|
111080
|
+
searchPlaceholder: "Search sessions...",
|
|
111081
|
+
showSearch: true,
|
|
111082
|
+
searchConfig: {
|
|
111083
|
+
metadataSearchFields: ["Session ID", "Environment", "App Version", "User ID", "Source"],
|
|
111084
|
+
updateQuery: handleSearch,
|
|
111085
|
+
currentQuery: searchTerm,
|
|
111086
|
+
tableAllowsFullTextSearch: false
|
|
111087
|
+
},
|
|
110309
111088
|
timeRange,
|
|
110310
111089
|
timeRangePresetLabel,
|
|
110311
111090
|
onTimeRangeChange: handleTimeRangeChange,
|
|
110312
111091
|
filters,
|
|
111092
|
+
filterColumns,
|
|
110313
111093
|
onFiltersClick: () => setShowFilterPanel(!showFilterPanel),
|
|
110314
111094
|
onModifyColumnsClick: () => setShowColumnCustomization(true),
|
|
110315
111095
|
onExportClick: handleExport,
|
|
@@ -110360,10 +111140,10 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110360
111140
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto p-[24px] pt-[8px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
110361
111141
|
TracingTable,
|
|
110362
111142
|
{
|
|
110363
|
-
data:
|
|
111143
|
+
data: filteredSessions,
|
|
110364
111144
|
columns,
|
|
110365
111145
|
loading,
|
|
110366
|
-
totalCount,
|
|
111146
|
+
totalCount: searchTerm.trim() ? filteredSessions.length : totalCount,
|
|
110367
111147
|
pagination,
|
|
110368
111148
|
onPaginationChange: setPagination,
|
|
110369
111149
|
onRowClick: handleRowClick,
|
|
@@ -110410,24 +111190,26 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110410
111190
|
onTraceClick,
|
|
110411
111191
|
className = "",
|
|
110412
111192
|
defaultFilters = [],
|
|
110413
|
-
sessionId
|
|
111193
|
+
sessionId,
|
|
111194
|
+
initialTraceId
|
|
110414
111195
|
} = props;
|
|
110415
111196
|
const { environments } = useEnvironment();
|
|
110416
|
-
const [selectedTraceId, setSelectedTraceId] = React.useState(null);
|
|
110417
|
-
const [isModalOpen, setIsModalOpen] = React.useState(
|
|
111197
|
+
const [selectedTraceId, setSelectedTraceId] = React.useState(() => initialTraceId ?? null);
|
|
111198
|
+
const [isModalOpen, setIsModalOpen] = React.useState(() => !!initialTraceId);
|
|
110418
111199
|
const [traces, setTraces] = React.useState([]);
|
|
110419
111200
|
const [totalCount, setTotalCount] = React.useState(0);
|
|
110420
111201
|
const [loading, setLoading] = React.useState(true);
|
|
110421
111202
|
const [hasInitiallyLoaded, setHasInitiallyLoaded] = React.useState(false);
|
|
110422
111203
|
const [searchTerm, setSearchTerm] = React.useState("");
|
|
110423
|
-
const [searchType, setSearchType] = React.useState(["id"]);
|
|
111204
|
+
const [searchType, setSearchType] = React.useState(["id", "content"]);
|
|
110424
111205
|
const initialFilters = React.useMemo(() => {
|
|
110425
111206
|
const hasEnvFilter = defaultFilters.some((f) => f.column === "envId");
|
|
110426
|
-
|
|
110427
|
-
|
|
111207
|
+
const base2 = hasEnvFilter ? defaultFilters : [createDraftEnvironmentFilter(), ...defaultFilters];
|
|
111208
|
+
if (initialTraceId) {
|
|
111209
|
+
return [...base2, { column: "id", type: "string", operator: "=", value: initialTraceId }];
|
|
110428
111210
|
}
|
|
110429
|
-
return
|
|
110430
|
-
}, [defaultFilters]);
|
|
111211
|
+
return base2;
|
|
111212
|
+
}, [defaultFilters, initialTraceId]);
|
|
110431
111213
|
const [filters, setFilters] = React.useState(initialFilters);
|
|
110432
111214
|
const [showFilterPanel, setShowFilterPanel] = React.useState(false);
|
|
110433
111215
|
const [showColumnCustomization, setShowColumnCustomization] = React.useState(false);
|
|
@@ -110436,6 +111218,12 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110436
111218
|
const [pagination, setPagination] = React.useState({ page: 0, limit: 50 });
|
|
110437
111219
|
const [orderBy, setOrderBy] = React.useState({ column: "timestamp", order: "DESC" });
|
|
110438
111220
|
const [detailedTraceData, setDetailedTraceData] = React.useState(/* @__PURE__ */ new Map());
|
|
111221
|
+
React.useEffect(() => {
|
|
111222
|
+
if (initialTraceId) {
|
|
111223
|
+
setSelectedTraceId(initialTraceId);
|
|
111224
|
+
setIsModalOpen(true);
|
|
111225
|
+
}
|
|
111226
|
+
}, [initialTraceId]);
|
|
110439
111227
|
const apiService = React.useMemo(() => new TracingApiService(apiConfig), [apiConfig]);
|
|
110440
111228
|
const convertPresetToDateRange = (preset) => {
|
|
110441
111229
|
const now2 = /* @__PURE__ */ new Date();
|
|
@@ -110521,18 +111309,24 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110521
111309
|
orderBy
|
|
110522
111310
|
});
|
|
110523
111311
|
const apiFilters = TracingUtils.convertFiltersToApiFormat(effectiveFilters, filterColumns);
|
|
110524
|
-
const tracesResponse = await
|
|
110525
|
-
|
|
110526
|
-
|
|
110527
|
-
|
|
110528
|
-
|
|
110529
|
-
|
|
110530
|
-
|
|
110531
|
-
|
|
110532
|
-
|
|
110533
|
-
|
|
111312
|
+
const [tracesResponse, countResponse] = await Promise.all([
|
|
111313
|
+
apiService.fetchTraces({
|
|
111314
|
+
projectId: apiConfig.projectId,
|
|
111315
|
+
filter: apiFilters,
|
|
111316
|
+
orderBy,
|
|
111317
|
+
page: pagination.page,
|
|
111318
|
+
limit: pagination.limit,
|
|
111319
|
+
searchQuery: searchTerm || null,
|
|
111320
|
+
searchType
|
|
111321
|
+
}),
|
|
111322
|
+
apiService.fetchTracesCount(apiConfig.projectId, apiFilters, {
|
|
111323
|
+
searchQuery: searchTerm || null,
|
|
111324
|
+
searchType,
|
|
111325
|
+
orderBy
|
|
111326
|
+
})
|
|
111327
|
+
]);
|
|
110534
111328
|
const basicTraces = tracesResponse.traces || [];
|
|
110535
|
-
console.log("✅ Basic traces loaded:", { count: basicTraces.length });
|
|
111329
|
+
console.log("✅ Basic traces loaded:", { count: basicTraces.length, total: countResponse.totalCount });
|
|
110536
111330
|
if (basicTraces.length > 0) {
|
|
110537
111331
|
const traceIds = basicTraces.map((t) => t.id);
|
|
110538
111332
|
try {
|
|
@@ -110567,7 +111361,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110567
111361
|
} else {
|
|
110568
111362
|
setTraces([]);
|
|
110569
111363
|
}
|
|
110570
|
-
setTotalCount(
|
|
111364
|
+
setTotalCount(countResponse.totalCount);
|
|
110571
111365
|
} catch (error) {
|
|
110572
111366
|
console.error("❌ Error fetching traces:", error);
|
|
110573
111367
|
setTraces([]);
|
|
@@ -110596,11 +111390,13 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110596
111390
|
projectId: apiConfig.projectId,
|
|
110597
111391
|
timestamp: trace.timestamp
|
|
110598
111392
|
});
|
|
111393
|
+
const inputDisplay = TraceTreeService.extractUserMessage(detail["input"]);
|
|
111394
|
+
const outputDisplay = TraceTreeService.extractAppResponse(detail["output"]);
|
|
110599
111395
|
setDetailedTraceData((prev) => {
|
|
110600
111396
|
const newMap = new Map(prev);
|
|
110601
111397
|
newMap.set(traceId, {
|
|
110602
|
-
input:
|
|
110603
|
-
output:
|
|
111398
|
+
input: inputDisplay,
|
|
111399
|
+
output: outputDisplay,
|
|
110604
111400
|
totalCost: detail["totalCost"],
|
|
110605
111401
|
envId: detail["envId"],
|
|
110606
111402
|
source: detail["source"]
|
|
@@ -110637,8 +111433,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110637
111433
|
width: 320,
|
|
110638
111434
|
pinned: "left",
|
|
110639
111435
|
hide: false,
|
|
110640
|
-
|
|
110641
|
-
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-medium text-gray-900", title: params.value, children: TracingUtils.truncate(params.value, 30) })
|
|
111436
|
+
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableId, { value: params.value, truncateLength: 30 })
|
|
110642
111437
|
}
|
|
110643
111438
|
];
|
|
110644
111439
|
{
|
|
@@ -110649,11 +111444,13 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110649
111444
|
hide: false,
|
|
110650
111445
|
cellRenderer: (params) => {
|
|
110651
111446
|
const detailData = detailedTraceData.get(params.data.id);
|
|
110652
|
-
const
|
|
110653
|
-
if (
|
|
111447
|
+
const rawInput = detailData == null ? void 0 : detailData.input;
|
|
111448
|
+
if (rawInput === void 0) {
|
|
110654
111449
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400 italic", children: "Loading..." });
|
|
110655
111450
|
}
|
|
110656
|
-
|
|
111451
|
+
const inputText = typeof rawInput === "string" ? rawInput : TraceTreeService.extractUserMessage(rawInput);
|
|
111452
|
+
const displayText = TracingUtils.truncate(inputText || "-", 50);
|
|
111453
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-700", title: inputText || void 0, children: displayText });
|
|
110657
111454
|
}
|
|
110658
111455
|
});
|
|
110659
111456
|
}
|
|
@@ -110682,11 +111479,13 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110682
111479
|
hide: false,
|
|
110683
111480
|
cellRenderer: (params) => {
|
|
110684
111481
|
const detailData = detailedTraceData.get(params.data.id);
|
|
110685
|
-
const
|
|
110686
|
-
if (
|
|
111482
|
+
const rawOutput = detailData == null ? void 0 : detailData.output;
|
|
111483
|
+
if (rawOutput === void 0) {
|
|
110687
111484
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400 italic", children: "Loading..." });
|
|
110688
111485
|
}
|
|
110689
|
-
|
|
111486
|
+
const outputText = typeof rawOutput === "string" ? rawOutput : TraceTreeService.extractAppResponse(rawOutput);
|
|
111487
|
+
const displayText = TracingUtils.truncate(outputText || "-", 50);
|
|
111488
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-700", title: outputText || void 0, children: displayText });
|
|
110690
111489
|
}
|
|
110691
111490
|
});
|
|
110692
111491
|
}
|
|
@@ -110749,11 +111548,9 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110749
111548
|
// },
|
|
110750
111549
|
{
|
|
110751
111550
|
field: "timestamp",
|
|
110752
|
-
headerName: "
|
|
111551
|
+
headerName: "Created At",
|
|
110753
111552
|
width: 180,
|
|
110754
|
-
hide:
|
|
110755
|
-
// DISABLED - This is the main sort column for traces
|
|
110756
|
-
disabled: true,
|
|
111553
|
+
hide: false,
|
|
110757
111554
|
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-500", children: params.value ? new Date(params.value).toLocaleString() : "-" })
|
|
110758
111555
|
},
|
|
110759
111556
|
{
|
|
@@ -110828,6 +111625,20 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
110828
111625
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-600", children: source || "-" });
|
|
110829
111626
|
}
|
|
110830
111627
|
},
|
|
111628
|
+
{
|
|
111629
|
+
field: "sessionReference",
|
|
111630
|
+
headerName: "Session Reference",
|
|
111631
|
+
width: 180,
|
|
111632
|
+
hide: true,
|
|
111633
|
+
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-700", title: params.value || "-", children: params.value || "-" })
|
|
111634
|
+
},
|
|
111635
|
+
{
|
|
111636
|
+
field: "identity",
|
|
111637
|
+
headerName: "User Reference",
|
|
111638
|
+
width: 180,
|
|
111639
|
+
hide: true,
|
|
111640
|
+
cellRenderer: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-700", title: params.value || "-", children: params.value || "-" })
|
|
111641
|
+
},
|
|
110831
111642
|
{
|
|
110832
111643
|
field: "promptTokens",
|
|
110833
111644
|
headerName: "Input Tokens",
|
|
@@ -111004,10 +111815,9 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
111004
111815
|
},
|
|
111005
111816
|
{
|
|
111006
111817
|
field: "timestamp",
|
|
111007
|
-
label: "
|
|
111008
|
-
// Same as API
|
|
111818
|
+
label: "Created At",
|
|
111009
111819
|
apiColumnName: "Timestamp",
|
|
111010
|
-
//
|
|
111820
|
+
// Backend payload: keep "Timestamp" for API
|
|
111011
111821
|
type: "datetime",
|
|
111012
111822
|
operators: [">=", "<=", "="]
|
|
111013
111823
|
},
|
|
@@ -111098,6 +111908,20 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
111098
111908
|
label: "Output Tokens",
|
|
111099
111909
|
type: "number",
|
|
111100
111910
|
operators: ["=", ">", ">=", "<", "<="]
|
|
111911
|
+
},
|
|
111912
|
+
{
|
|
111913
|
+
field: "sessionReference",
|
|
111914
|
+
label: "Session Reference",
|
|
111915
|
+
apiColumnName: "Session Reference",
|
|
111916
|
+
type: "string",
|
|
111917
|
+
operators: ["=", "!=", "contains"]
|
|
111918
|
+
},
|
|
111919
|
+
{
|
|
111920
|
+
field: "identity",
|
|
111921
|
+
label: "User Reference",
|
|
111922
|
+
apiColumnName: "User Reference",
|
|
111923
|
+
type: "string",
|
|
111924
|
+
operators: ["=", "!=", "contains"]
|
|
111101
111925
|
}
|
|
111102
111926
|
);
|
|
111103
111927
|
return baseColumns;
|
|
@@ -111164,6 +111988,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
111164
111988
|
timeRangePresetLabel,
|
|
111165
111989
|
onTimeRangeChange: handleTimeRangeChange,
|
|
111166
111990
|
filters,
|
|
111991
|
+
filterColumns,
|
|
111167
111992
|
onFiltersClick: () => setShowFilterPanel(!showFilterPanel),
|
|
111168
111993
|
onModifyColumnsClick: () => setShowColumnCustomization(true),
|
|
111169
111994
|
onExportClick: handleExport,
|
|
@@ -112215,12 +113040,12 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
112215
113040
|
* Process execution events and build a hierarchical tree structure
|
|
112216
113041
|
* Session > Run > Node Tree
|
|
112217
113042
|
*/
|
|
112218
|
-
static buildSessionTree(events, sessionId) {
|
|
113043
|
+
static buildSessionTree(events, sessionId, options) {
|
|
112219
113044
|
var _a;
|
|
112220
113045
|
const runGroups = this.groupEventsByRun(events);
|
|
112221
113046
|
const runs = [];
|
|
112222
113047
|
for (const [runId, runEvents] of runGroups.entries()) {
|
|
112223
|
-
const runTree = this.buildRunTree(runId, runEvents);
|
|
113048
|
+
const runTree = this.buildRunTree(runId, runEvents, options);
|
|
112224
113049
|
runs.push(runTree);
|
|
112225
113050
|
}
|
|
112226
113051
|
runs.sort((a2, b) => new Date(a2.startTime).getTime() - new Date(b.startTime).getTime());
|
|
@@ -112246,11 +113071,11 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
112246
113071
|
/**
|
|
112247
113072
|
* Build tree for a single run
|
|
112248
113073
|
*/
|
|
112249
|
-
static buildRunTree(runId, events) {
|
|
113074
|
+
static buildRunTree(runId, events, options) {
|
|
112250
113075
|
var _a;
|
|
112251
113076
|
const nodeEventMap = /* @__PURE__ */ new Map();
|
|
112252
113077
|
events.forEach((event) => {
|
|
112253
|
-
const nodeKey =
|
|
113078
|
+
const nodeKey = event.data.id;
|
|
112254
113079
|
if (!nodeEventMap.has(nodeKey)) {
|
|
112255
113080
|
nodeEventMap.set(nodeKey, {});
|
|
112256
113081
|
}
|
|
@@ -112277,7 +113102,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
112277
113102
|
const status = this.calculateRunStatus(runEvents);
|
|
112278
113103
|
const duration = endTime && startTime ? endTime - startTime : void 0;
|
|
112279
113104
|
const totalTokens = this.calculateRunTokens(runEvents);
|
|
112280
|
-
const userInput = this.extractUserInput(runEvents);
|
|
113105
|
+
const userInput = this.extractUserInput(runEvents, options);
|
|
112281
113106
|
const finalOutput = this.extractFinalOutput(runEvents);
|
|
112282
113107
|
return {
|
|
112283
113108
|
runId,
|
|
@@ -112296,11 +113121,12 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
112296
113121
|
* Create TreeNode from paired started/completed events
|
|
112297
113122
|
*/
|
|
112298
113123
|
static createTreeNodeFromEvents(startedEvent, completedEvent, runId) {
|
|
113124
|
+
var _a;
|
|
112299
113125
|
const startTime = startedEvent.data.timestamp;
|
|
112300
113126
|
const endTime = completedEvent == null ? void 0 : completedEvent.data.timestamp;
|
|
112301
113127
|
const duration = endTime && startTime ? new Date(endTime).getTime() - new Date(startTime).getTime() : void 0;
|
|
112302
113128
|
const primaryEvent = completedEvent || startedEvent;
|
|
112303
|
-
const hasInputOutput = primaryEvent.data.type === "llm" || primaryEvent.data.type === "tool" || primaryEvent.data.type === "GuardrailsInputScan" || primaryEvent.data.type === "GuardrailsOutputScan" || primaryEvent.data.type === "Agent" || primaryEvent.data.type === "External Orchestrator" || primaryEvent.data.type === "ProxyWorker" || primaryEvent.data.type === "event";
|
|
113129
|
+
const hasInputOutput = primaryEvent.data.type === "llm" || primaryEvent.data.type === "tool" || primaryEvent.data.type === "GuardrailsInputScan" || primaryEvent.data.type === "GuardrailsOutputScan" || primaryEvent.data.type === "Agent" || primaryEvent.data.type === "External Orchestrator" || primaryEvent.data.type === "ProxyWorker" || primaryEvent.data.type === "PostProcessor" || primaryEvent.data.type === "event";
|
|
112304
113130
|
const input = hasInputOutput ? startedEvent.data.input : void 0;
|
|
112305
113131
|
let output = void 0;
|
|
112306
113132
|
let error = void 0;
|
|
@@ -112314,7 +113140,8 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
112314
113140
|
const { toolInvocations, isResponse } = this.extractToolInvocations(output);
|
|
112315
113141
|
console.log("toolInvocations", toolInvocations);
|
|
112316
113142
|
console.log("isResponse", isResponse);
|
|
112317
|
-
const
|
|
113143
|
+
const extractedProvider = primaryEvent.data.type === "llm" ? this.extractProvider(primaryEvent.data.name || primaryEvent.data.toolName) : void 0;
|
|
113144
|
+
const provider = ((_a = primaryEvent.data.metadata) == null ? void 0 : _a.provider) || extractedProvider;
|
|
112318
113145
|
return {
|
|
112319
113146
|
id: primaryEvent.data.id,
|
|
112320
113147
|
parentId: primaryEvent.data.parentId,
|
|
@@ -112473,12 +113300,22 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
112473
113300
|
/**
|
|
112474
113301
|
* Extract initial user input from the first LLM node's input
|
|
112475
113302
|
*/
|
|
112476
|
-
static extractUserInput(events) {
|
|
113303
|
+
static extractUserInput(events, options) {
|
|
113304
|
+
const preferDisplay = ((options == null ? void 0 : options.runHeaderInputMode) ?? "display") === "display";
|
|
112477
113305
|
const llmEvents = events.filter(
|
|
112478
113306
|
(e) => e.type === "node_started" && e.data.type === "llm"
|
|
112479
113307
|
).sort((a2, b) => new Date(a2.data.timestamp).getTime() - new Date(b.data.timestamp).getTime());
|
|
112480
113308
|
if (llmEvents.length > 0) {
|
|
112481
113309
|
const firstLlmEvent = llmEvents[0];
|
|
113310
|
+
if (preferDisplay && firstLlmEvent.data.displayInput !== void 0 && firstLlmEvent.data.displayInput !== null) {
|
|
113311
|
+
const d = firstLlmEvent.data.displayInput;
|
|
113312
|
+
if (typeof d === "string") {
|
|
113313
|
+
return d;
|
|
113314
|
+
}
|
|
113315
|
+
if (typeof d === "object") {
|
|
113316
|
+
return JSON.stringify(d);
|
|
113317
|
+
}
|
|
113318
|
+
}
|
|
112482
113319
|
if (firstLlmEvent.data.input) {
|
|
112483
113320
|
if (typeof firstLlmEvent.data.input === "string") {
|
|
112484
113321
|
return firstLlmEvent.data.input;
|
|
@@ -112546,6 +113383,22 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
112546
113383
|
*/
|
|
112547
113384
|
static extractFinalOutput(events) {
|
|
112548
113385
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
113386
|
+
const postProcessorEvents = events.filter(
|
|
113387
|
+
(e) => {
|
|
113388
|
+
var _a2;
|
|
113389
|
+
return e.type === "node_completed" && e.data.type === "tool" && ((_a2 = e.data.metadata) == null ? void 0 : _a2.type) === "PostProcessor" && e.data.output;
|
|
113390
|
+
}
|
|
113391
|
+
);
|
|
113392
|
+
if (postProcessorEvents.length > 0) {
|
|
113393
|
+
const lastPP = postProcessorEvents[postProcessorEvents.length - 1];
|
|
113394
|
+
const ppOutput = lastPP.data.output;
|
|
113395
|
+
if (typeof ppOutput === "object" && ppOutput.output) {
|
|
113396
|
+
return typeof ppOutput.output === "string" ? ppOutput.output : JSON.stringify(ppOutput.output);
|
|
113397
|
+
}
|
|
113398
|
+
if (typeof ppOutput === "string") {
|
|
113399
|
+
return ppOutput;
|
|
113400
|
+
}
|
|
113401
|
+
}
|
|
112549
113402
|
const errorEvents = events.filter(
|
|
112550
113403
|
(e) => e.type === "node_completed" && e.data.error && (e.data.status === "errored" || e.data.status === "failed")
|
|
112551
113404
|
);
|
|
@@ -112672,8 +113525,8 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
112672
113525
|
/**
|
|
112673
113526
|
* Update tree with new events (optimized for real-time updates)
|
|
112674
113527
|
*/
|
|
112675
|
-
static updateTree(existingTree, _newEvents, allEvents) {
|
|
112676
|
-
return this.buildSessionTree(allEvents, existingTree.sessionId);
|
|
113528
|
+
static updateTree(existingTree, _newEvents, allEvents, options) {
|
|
113529
|
+
return this.buildSessionTree(allEvents, existingTree.sessionId, options);
|
|
112677
113530
|
}
|
|
112678
113531
|
/**
|
|
112679
113532
|
* Merge new events into existing events efficiently
|
|
@@ -113025,7 +113878,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113025
113878
|
nodeId,
|
|
113026
113879
|
totalObservations: observations.length
|
|
113027
113880
|
});
|
|
113028
|
-
const
|
|
113881
|
+
const matchingObservations = observations.filter((obs) => {
|
|
113029
113882
|
let metadata = obs.metadata;
|
|
113030
113883
|
if (typeof metadata === "string") {
|
|
113031
113884
|
try {
|
|
@@ -113046,6 +113899,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113046
113899
|
});
|
|
113047
113900
|
return nodeId === observationNodeId;
|
|
113048
113901
|
});
|
|
113902
|
+
const matchedObservation = matchingObservations.find((obs) => obs.type === "GENERATION") || matchingObservations[0] || null;
|
|
113049
113903
|
if (!matchedObservation) {
|
|
113050
113904
|
const parts = nodeId.split("_");
|
|
113051
113905
|
if (parts.length === 2) {
|
|
@@ -113187,6 +114041,36 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113187
114041
|
return this.config;
|
|
113188
114042
|
}
|
|
113189
114043
|
}
|
|
114044
|
+
function sanitizeForTestId(value) {
|
|
114045
|
+
return value.trim().toLowerCase().replace(/[\s_]+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "") || "node";
|
|
114046
|
+
}
|
|
114047
|
+
function getDebuggerCallTypeTestId(node) {
|
|
114048
|
+
const name = (node.name ?? "unknown").toString();
|
|
114049
|
+
let slug = sanitizeForTestId(name);
|
|
114050
|
+
switch (node.type) {
|
|
114051
|
+
case "event":
|
|
114052
|
+
slug = slug.replace(/-event$/, "") || "event";
|
|
114053
|
+
return `debugger-event-${slug}`;
|
|
114054
|
+
case "Agent":
|
|
114055
|
+
return `debugger-${slug}-call`;
|
|
114056
|
+
case "tool":
|
|
114057
|
+
return `debugger-${slug}-call`;
|
|
114058
|
+
case "llm":
|
|
114059
|
+
return `debugger-llm-${slug}`;
|
|
114060
|
+
case "GuardrailsInputScan":
|
|
114061
|
+
return `debugger-guardrails-input-${slug}`;
|
|
114062
|
+
case "GuardrailsOutputScan":
|
|
114063
|
+
return `debugger-guardrails-output-${slug}`;
|
|
114064
|
+
case "External Orchestrator":
|
|
114065
|
+
return `debugger-orchestrator-${slug}`;
|
|
114066
|
+
case "ProxyWorker":
|
|
114067
|
+
return `debugger-proxy-${slug}`;
|
|
114068
|
+
case "PostProcessor":
|
|
114069
|
+
return `debugger-postprocessor-${slug}`;
|
|
114070
|
+
default:
|
|
114071
|
+
return `debugger-${String(node.type).toLowerCase().replace(/\s+/g, "-")}-${slug}`;
|
|
114072
|
+
}
|
|
114073
|
+
}
|
|
113190
114074
|
function DebugCard({
|
|
113191
114075
|
node,
|
|
113192
114076
|
onToggle,
|
|
@@ -113198,9 +114082,12 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113198
114082
|
projectId,
|
|
113199
114083
|
nodeIndex = 0
|
|
113200
114084
|
}) {
|
|
114085
|
+
var _a;
|
|
114086
|
+
const callTypeTestId = React.useMemo(() => getDebuggerCallTypeTestId(node), [node.type, node.name]);
|
|
114087
|
+
const cardTestId = React.useMemo(() => `${callTypeTestId}_${node.id}`, [callTypeTestId, node.id]);
|
|
113201
114088
|
const isGuardrailsNode = React.useMemo(() => {
|
|
113202
|
-
var
|
|
113203
|
-
return node.type === "GuardrailsInputScan" || node.type === "GuardrailsOutputScan" || ((
|
|
114089
|
+
var _a2;
|
|
114090
|
+
return node.type === "GuardrailsInputScan" || node.type === "GuardrailsOutputScan" || ((_a2 = node.name) == null ? void 0 : _a2.toLowerCase().includes("guardrail"));
|
|
113204
114091
|
}, [node.type, node.name]);
|
|
113205
114092
|
const availableTabs = React.useMemo(() => {
|
|
113206
114093
|
switch (node.type) {
|
|
@@ -113377,7 +114264,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113377
114264
|
}
|
|
113378
114265
|
};
|
|
113379
114266
|
const getNodeIcon = () => {
|
|
113380
|
-
var
|
|
114267
|
+
var _a2, _b;
|
|
113381
114268
|
if (isGuardrailsNode) {
|
|
113382
114269
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 relative w-[24px] h-[24px] bg-gray-200 rounded-[8px] flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "17", height: "21", viewBox: "0 0 17 21", fill: "none", className: "w-[16px] h-[16px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113383
114270
|
"path",
|
|
@@ -113412,7 +114299,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113412
114299
|
size: "small",
|
|
113413
114300
|
name: node.name,
|
|
113414
114301
|
className: "w-[24px] h-[24px]",
|
|
113415
|
-
toolType: node.type === "tool" ? (
|
|
114302
|
+
toolType: node.type === "tool" ? (_a2 = node.metadata) == null ? void 0 : _a2.type : void 0,
|
|
113416
114303
|
provider: node.type === "llm" ? (_b = node.metadata) == null ? void 0 : _b.provider : void 0,
|
|
113417
114304
|
modelName: node.type === "llm" ? node.name : void 0
|
|
113418
114305
|
}
|
|
@@ -113436,7 +114323,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113436
114323
|
return availableTabs;
|
|
113437
114324
|
};
|
|
113438
114325
|
const renderActionContent = () => {
|
|
113439
|
-
var
|
|
114326
|
+
var _a2, _b;
|
|
113440
114327
|
let toolInvocations = node.toolInvocations || [];
|
|
113441
114328
|
if (node.type === "llm" && Array.isArray(node.output)) {
|
|
113442
114329
|
toolInvocations = node.output.filter(
|
|
@@ -113458,7 +114345,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113458
114345
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600 truncate", children: child.name || "Unknown" })
|
|
113459
114346
|
] }, child.id || index))
|
|
113460
114347
|
] }),
|
|
113461
|
-
toolInvocations.length > 0 && ((_b = (
|
|
114348
|
+
toolInvocations.length > 0 && ((_b = (_a2 = toolInvocations[0]) == null ? void 0 : _a2.args) == null ? void 0 : _b.reason) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
113462
114349
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs font-medium text-gray-400 mb-[4px]", children: "Reason" }),
|
|
113463
114350
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-600", children: toolInvocations[0].args.reason })
|
|
113464
114351
|
] })
|
|
@@ -113485,14 +114372,14 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113485
114372
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 italic", children: "No actions taken" });
|
|
113486
114373
|
};
|
|
113487
114374
|
const extractOutputMessage = (output) => {
|
|
113488
|
-
var
|
|
114375
|
+
var _a2, _b, _c, _d;
|
|
113489
114376
|
if (!output || typeof output !== "object") return void 0;
|
|
113490
114377
|
if (Array.isArray(output)) {
|
|
113491
114378
|
const routeToUserTool = output.find(
|
|
113492
114379
|
(item) => item && typeof item === "object" && (item.name === "route_to_user" || item.toolName === "route_to_user")
|
|
113493
114380
|
);
|
|
113494
114381
|
if (routeToUserTool) {
|
|
113495
|
-
return ((
|
|
114382
|
+
return ((_a2 = routeToUserTool.args) == null ? void 0 : _a2.message) || routeToUserTool.message || ((_b = routeToUserTool.output) == null ? void 0 : _b.message);
|
|
113496
114383
|
}
|
|
113497
114384
|
} else if (output.name === "route_to_user" || output.toolName === "route_to_user") {
|
|
113498
114385
|
return ((_c = output.args) == null ? void 0 : _c.message) || output.message || ((_d = output.output) == null ? void 0 : _d.message);
|
|
@@ -113589,7 +114476,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113589
114476
|
] });
|
|
113590
114477
|
};
|
|
113591
114478
|
const renderTabContent = () => {
|
|
113592
|
-
var
|
|
114479
|
+
var _a2;
|
|
113593
114480
|
switch (activeTab) {
|
|
113594
114481
|
case "summary":
|
|
113595
114482
|
if (isGuardrailsNode) {
|
|
@@ -113780,7 +114667,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113780
114667
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113781
114668
|
DataViewer,
|
|
113782
114669
|
{
|
|
113783
|
-
data: ((
|
|
114670
|
+
data: ((_a2 = node.metadata) == null ? void 0 : _a2["logs"]) || {},
|
|
113784
114671
|
title: "Execution Logs",
|
|
113785
114672
|
maxHeight: "250px",
|
|
113786
114673
|
defaultExpanded: true,
|
|
@@ -113793,15 +114680,15 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113793
114680
|
};
|
|
113794
114681
|
return (
|
|
113795
114682
|
// bg-white w-full border-t border-gray-200
|
|
113796
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white w-full", "data-test-id":
|
|
114683
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white w-full", "data-test-id": cardTestId, "data-call-type-test-id": callTypeTestId, children: [
|
|
113797
114684
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113798
114685
|
"div",
|
|
113799
114686
|
{
|
|
113800
114687
|
className: `flex items-center pl-[8px] pr-[8px] relative transition-colors cursor-pointer w-full
|
|
113801
114688
|
${isSelected ? "" : ""}`,
|
|
113802
114689
|
onClick: handleNodeClick,
|
|
113803
|
-
"data-test-id":
|
|
113804
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[10px] w-full", "data-test-id":
|
|
114690
|
+
"data-test-id": `${callTypeTestId}_header`,
|
|
114691
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[10px] w-full", "data-test-id": `${callTypeTestId}_header_content`, children: [
|
|
113805
114692
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113806
114693
|
"div",
|
|
113807
114694
|
{
|
|
@@ -113815,7 +114702,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113815
114702
|
}
|
|
113816
114703
|
},
|
|
113817
114704
|
title: hasChildren ? isExpanded ? "Collapse" : "Expand" : "Show details",
|
|
113818
|
-
"data-test-id":
|
|
114705
|
+
"data-test-id": `${callTypeTestId}_toggle`,
|
|
113819
114706
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113820
114707
|
ChevronRight,
|
|
113821
114708
|
{
|
|
@@ -113824,28 +114711,28 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113824
114711
|
)
|
|
113825
114712
|
}
|
|
113826
114713
|
),
|
|
113827
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[8px] w-full py-[8px] border-b border-gray-200", "data-test-id":
|
|
113828
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 rounded-[8px] bg-[#B2DDFF]", "data-test-id":
|
|
114714
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[8px] w-full py-[8px] border-b border-gray-200", "data-test-id": `${callTypeTestId}_node_info`, children: [
|
|
114715
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 rounded-[8px] bg-[#B2DDFF]", "data-test-id": `${callTypeTestId}_node_icon`, children: getNodeIcon() }),
|
|
113829
114716
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113830
114717
|
"span",
|
|
113831
114718
|
{
|
|
113832
114719
|
className: "font-semibold text-gray-900 text-xs truncate w-full",
|
|
113833
114720
|
title: node.type === "llm" ? node.name : void 0,
|
|
113834
|
-
"data-test-id":
|
|
113835
|
-
children: isGuardrailsNode ? node.type === "GuardrailsInputScan" ? "Input Guardrails Scanner" : "Output Guardrails Scanner" : node.type === "llm" ? "AI Model Call" : node.type === "tool" ? formatToolName(node.name) : node.name
|
|
114721
|
+
"data-test-id": `${callTypeTestId}_node_name`,
|
|
114722
|
+
children: isGuardrailsNode ? node.type === "GuardrailsInputScan" ? "Input Guardrails Scanner" : "Output Guardrails Scanner" : node.type === "llm" ? ((_a = node == null ? void 0 : node.metadata) == null ? void 0 : _a.isRoutedModel) ? `AI Model Call (${node.name})` : "AI Model Call" : node.type === "PostProcessor" ? "Response Processor" : node.type === "tool" ? formatToolName(node.name) : node.name
|
|
113836
114723
|
}
|
|
113837
114724
|
),
|
|
113838
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[12px] text-[10px] text-gray-500", "data-test-id":
|
|
114725
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[12px] text-[10px] text-gray-500", "data-test-id": `${callTypeTestId}_node_metadata`, children: [
|
|
113839
114726
|
node.type === "Agent" && (() => {
|
|
113840
|
-
var
|
|
113841
|
-
const llmChild = (
|
|
114727
|
+
var _a2;
|
|
114728
|
+
const llmChild = (_a2 = node.children) == null ? void 0 : _a2.find((child) => child.type === "llm");
|
|
113842
114729
|
if (llmChild == null ? void 0 : llmChild.name) {
|
|
113843
114730
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113844
114731
|
"span",
|
|
113845
114732
|
{
|
|
113846
114733
|
className: "text-[10px] text-gray-500 truncate max-w-[100px]",
|
|
113847
114734
|
title: llmChild.name,
|
|
113848
|
-
"data-test-id":
|
|
114735
|
+
"data-test-id": `${callTypeTestId}_node_model_name`,
|
|
113849
114736
|
children: llmChild.name
|
|
113850
114737
|
}
|
|
113851
114738
|
);
|
|
@@ -113853,7 +114740,7 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113853
114740
|
return null;
|
|
113854
114741
|
})(),
|
|
113855
114742
|
(node.type === "Agent" || node.type === "llm" || isGuardrailsNode) && (() => {
|
|
113856
|
-
var
|
|
114743
|
+
var _a2, _b, _c;
|
|
113857
114744
|
let llmUsage = node.llmUsage;
|
|
113858
114745
|
if (node.type === "Agent" && node.children) {
|
|
113859
114746
|
const llmChildren = node.children.filter((child) => child.type === "llm");
|
|
@@ -113875,10 +114762,10 @@ For more info see: https://www.ag-grid.com/javascript-grid/modules/`;
|
|
|
113875
114762
|
"span",
|
|
113876
114763
|
{
|
|
113877
114764
|
className: "text-[10px] text-gray-500 whitespace-nowrap cursor-help",
|
|
113878
|
-
title: `Input: ${((
|
|
114765
|
+
title: `Input: ${((_a2 = llmUsage.input_tokens) == null ? void 0 : _a2.toLocaleString()) || 0} tokens
|
|
113879
114766
|
Output: ${((_b = llmUsage.output_tokens) == null ? void 0 : _b.toLocaleString()) || 0} tokens
|
|
113880
114767
|
Total: ${((_c = llmUsage.total_tokens) == null ? void 0 : _c.toLocaleString()) || 0} tokens`,
|
|
113881
|
-
"data-test-id":
|
|
114768
|
+
"data-test-id": `${callTypeTestId}_node_tokens`,
|
|
113882
114769
|
children: [
|
|
113883
114770
|
llmUsage.total_tokens.toLocaleString(),
|
|
113884
114771
|
" Tokens"
|
|
@@ -113888,34 +114775,34 @@ Total: ${((_c = llmUsage.total_tokens) == null ? void 0 : _c.toLocaleString()) |
|
|
|
113888
114775
|
}
|
|
113889
114776
|
return null;
|
|
113890
114777
|
})(),
|
|
113891
|
-
node.duration && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[4px]", "data-test-id":
|
|
114778
|
+
node.duration && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-[4px]", "data-test-id": `${callTypeTestId}_node_duration`, children: [
|
|
113892
114779
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "w-[12px] h-[12px]" }),
|
|
113893
114780
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] text-gray-500 whitespace-nowrap", children: formatDuration(node.duration) })
|
|
113894
114781
|
] })
|
|
113895
114782
|
] }),
|
|
113896
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0", "data-test-id":
|
|
114783
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0", "data-test-id": `${callTypeTestId}_node_status`, children: getStatusIcon() })
|
|
113897
114784
|
] })
|
|
113898
114785
|
] })
|
|
113899
114786
|
}
|
|
113900
114787
|
),
|
|
113901
|
-
isSelected && availableTabs.length > 0 && showDetailView && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full pl-[32px] relative", "data-test-id":
|
|
113902
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute top-[-40px] left-[16px] w-[1px] border-l border-dashed border-gray-200 h-[calc(100%+40px)] z-[1]", "data-test-id":
|
|
113903
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-[4px] py-[8px] w-full", "data-test-id":
|
|
113904
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-gray-50 rounded-[4px] p-[4px] inline-flex gap-[4px] mb-[8px] border border-gray-200", "data-test-id":
|
|
114788
|
+
isSelected && availableTabs.length > 0 && showDetailView && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full pl-[32px] relative", "data-test-id": `${callTypeTestId}_detail_panel`, children: [
|
|
114789
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute top-[-40px] left-[16px] w-[1px] border-l border-dashed border-gray-200 h-[calc(100%+40px)] z-[1]", "data-test-id": `${callTypeTestId}_detail_panel_connector` }),
|
|
114790
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-[4px] py-[8px] w-full", "data-test-id": `${callTypeTestId}_detail_panel_content`, children: [
|
|
114791
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-gray-50 rounded-[4px] p-[4px] inline-flex gap-[4px] mb-[8px] border border-gray-200", "data-test-id": `${callTypeTestId}_detail_panel_tabs`, children: getTabsForNodeType().map((tab) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113905
114792
|
"button",
|
|
113906
114793
|
{
|
|
113907
114794
|
onClick: () => handleTabClick(tab),
|
|
113908
114795
|
className: `px-[8px] py-[4px] text-xs font-medium rounded-[4px] text-gray-500 hover:text-gray-700 hover:shadow-tab hover:bg-white transition-colors ${activeTab === tab ? "bg-white text-gray-900 shadow-tab" : "text-gray-500 hover:text-gray-700 hover:bg-white"}`,
|
|
113909
|
-
"data-test-id":
|
|
114796
|
+
"data-test-id": `${callTypeTestId}_detail_panel_tab_${tab}`,
|
|
113910
114797
|
children: tab.charAt(0).toUpperCase() + tab.slice(1)
|
|
113911
114798
|
},
|
|
113912
114799
|
tab
|
|
113913
114800
|
)) }),
|
|
113914
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-[4px]", "data-test-id":
|
|
114801
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-[4px]", "data-test-id": `${callTypeTestId}_detail_panel_tab_content`, children: renderTabContent() })
|
|
113915
114802
|
] })
|
|
113916
114803
|
] }),
|
|
113917
|
-
isExpanded && hasChildren && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full pl-[32px] relative", "data-test-id":
|
|
113918
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute top-[-40px] left-[16px] w-[1px] border-l border-dashed border-gray-200 h-[calc(100%+40px)] z-[1]", "data-test-id":
|
|
114804
|
+
isExpanded && hasChildren && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full pl-[32px] relative", "data-test-id": `${callTypeTestId}_children`, children: [
|
|
114805
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute top-[-40px] left-[16px] w-[1px] border-l border-dashed border-gray-200 h-[calc(100%+40px)] z-[1]", "data-test-id": `${callTypeTestId}_children_connector` }),
|
|
113919
114806
|
node.children.map((child, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
113920
114807
|
DebugCard,
|
|
113921
114808
|
{
|
|
@@ -113951,6 +114838,7 @@ Total: ${((_c = llmUsage.total_tokens) == null ? void 0 : _c.toLocaleString()) |
|
|
|
113951
114838
|
expansionMode = "none",
|
|
113952
114839
|
showExpansionControls = false,
|
|
113953
114840
|
defaultDetailView = true,
|
|
114841
|
+
runHeaderInputMode = "display",
|
|
113954
114842
|
apiConfig
|
|
113955
114843
|
} = config2;
|
|
113956
114844
|
console.log("🔧 DebugPanel - Config received:", {
|
|
@@ -114011,10 +114899,12 @@ Total: ${((_c = llmUsage.total_tokens) == null ? void 0 : _c.toLocaleString()) |
|
|
|
114011
114899
|
}
|
|
114012
114900
|
}), []);
|
|
114013
114901
|
const sessionTree = React.useMemo(() => {
|
|
114014
|
-
const tree = TreeBuilder.buildSessionTree(executionEvents, sessionId
|
|
114902
|
+
const tree = TreeBuilder.buildSessionTree(executionEvents, sessionId, {
|
|
114903
|
+
runHeaderInputMode
|
|
114904
|
+
});
|
|
114015
114905
|
prevSessionTreeRef.current = tree;
|
|
114016
114906
|
return tree;
|
|
114017
|
-
}, [executionEvents, sessionId]);
|
|
114907
|
+
}, [executionEvents, sessionId, runHeaderInputMode]);
|
|
114018
114908
|
const getAllNodeIds = (tree) => {
|
|
114019
114909
|
const nodeIds = [];
|
|
114020
114910
|
const collectIds = (node) => {
|
|
@@ -114422,16 +115312,25 @@ Total: ${((_c = llmUsage.total_tokens) == null ? void 0 : _c.toLocaleString()) |
|
|
|
114422
115312
|
const findFinalOutput = (nodes) => {
|
|
114423
115313
|
let lastOutput = void 0;
|
|
114424
115314
|
let routeToUserOutput = void 0;
|
|
115315
|
+
let postProcessorOutput = void 0;
|
|
114425
115316
|
const traverse = (nodeList) => {
|
|
114426
|
-
var _a, _b, _c, _d, _e;
|
|
115317
|
+
var _a, _b, _c, _d, _e, _f;
|
|
114427
115318
|
for (const node of nodeList) {
|
|
115319
|
+
if (node.type === "tool" && ((_a = node.metadata) == null ? void 0 : _a.type) === "PostProcessor" && node.output) {
|
|
115320
|
+
const ppOut = node.output;
|
|
115321
|
+
if (typeof ppOut === "object" && ppOut.output) {
|
|
115322
|
+
postProcessorOutput = typeof ppOut.output === "string" ? ppOut.output : JSON.stringify(ppOut.output);
|
|
115323
|
+
} else if (typeof ppOut === "string") {
|
|
115324
|
+
postProcessorOutput = ppOut;
|
|
115325
|
+
}
|
|
115326
|
+
}
|
|
114428
115327
|
if (node.type === "tool" && (node.name === "route_to_user" || node.name === "route_to_user")) {
|
|
114429
115328
|
if (node.output) {
|
|
114430
115329
|
if (typeof node.output === "string") {
|
|
114431
115330
|
routeToUserOutput = node.output;
|
|
114432
|
-
} else if ((
|
|
115331
|
+
} else if ((_b = node.output) == null ? void 0 : _b.message) {
|
|
114433
115332
|
routeToUserOutput = node.output.message;
|
|
114434
|
-
} else if ((
|
|
115333
|
+
} else if ((_c = node.output) == null ? void 0 : _c.result) {
|
|
114435
115334
|
routeToUserOutput = node.output.result;
|
|
114436
115335
|
}
|
|
114437
115336
|
}
|
|
@@ -114441,7 +115340,7 @@ Total: ${((_c = llmUsage.total_tokens) == null ? void 0 : _c.toLocaleString()) |
|
|
|
114441
115340
|
(item) => (item == null ? void 0 : item.name) === "route_to_user" || (item == null ? void 0 : item.toolName) === "route_to_user"
|
|
114442
115341
|
);
|
|
114443
115342
|
if (routeItem) {
|
|
114444
|
-
if ((
|
|
115343
|
+
if ((_d = routeItem.args) == null ? void 0 : _d.message) {
|
|
114445
115344
|
routeToUserOutput = routeItem.args.message;
|
|
114446
115345
|
} else if (routeItem.message) {
|
|
114447
115346
|
routeToUserOutput = routeItem.message;
|
|
@@ -114452,9 +115351,9 @@ Total: ${((_c = llmUsage.total_tokens) == null ? void 0 : _c.toLocaleString()) |
|
|
|
114452
115351
|
if (typeof node.output === "string") {
|
|
114453
115352
|
lastOutput = node.output;
|
|
114454
115353
|
} else if (!Array.isArray(node.output)) {
|
|
114455
|
-
if ((
|
|
115354
|
+
if ((_e = node.output) == null ? void 0 : _e.message) {
|
|
114456
115355
|
lastOutput = node.output.message;
|
|
114457
|
-
} else if ((
|
|
115356
|
+
} else if ((_f = node.output) == null ? void 0 : _f.result) {
|
|
114458
115357
|
lastOutput = node.output.result;
|
|
114459
115358
|
} else if (typeof node.output === "object") {
|
|
114460
115359
|
if (!node.output.name && !node.output.toolName) {
|
|
@@ -114469,7 +115368,7 @@ Total: ${((_c = llmUsage.total_tokens) == null ? void 0 : _c.toLocaleString()) |
|
|
|
114469
115368
|
}
|
|
114470
115369
|
};
|
|
114471
115370
|
traverse(nodes);
|
|
114472
|
-
return routeToUserOutput || lastOutput;
|
|
115371
|
+
return postProcessorOutput || routeToUserOutput || lastOutput;
|
|
114473
115372
|
};
|
|
114474
115373
|
const outputFromNodes = run2.rootNodes ? findFinalOutput(run2.rootNodes) : void 0;
|
|
114475
115374
|
const finalOutput = outputFromNodes || run2.finalOutput;
|
|
@@ -141290,6 +142189,57 @@ ${code2}
|
|
|
141290
142189
|
};
|
|
141291
142190
|
});
|
|
141292
142191
|
}
|
|
142192
|
+
function getVariableContextAtPosition(editor, pos) {
|
|
142193
|
+
const { doc: doc2 } = editor.state;
|
|
142194
|
+
if (pos < 2 || pos > doc2.content.size) {
|
|
142195
|
+
return null;
|
|
142196
|
+
}
|
|
142197
|
+
const $pos = doc2.resolve(pos);
|
|
142198
|
+
const parent = $pos.parent;
|
|
142199
|
+
if (!parent.isTextblock) {
|
|
142200
|
+
return null;
|
|
142201
|
+
}
|
|
142202
|
+
const contentStart = $pos.start();
|
|
142203
|
+
let text = "";
|
|
142204
|
+
const posMap = [];
|
|
142205
|
+
parent.forEach((node, offset2) => {
|
|
142206
|
+
const nodeDocStart = contentStart + offset2;
|
|
142207
|
+
if (nodeDocStart >= pos) return;
|
|
142208
|
+
if (node.isText && node.text) {
|
|
142209
|
+
const charsToTake = Math.min(node.text.length, pos - nodeDocStart);
|
|
142210
|
+
for (let i2 = 0; i2 < charsToTake; i2++) {
|
|
142211
|
+
posMap.push(nodeDocStart + i2);
|
|
142212
|
+
text += node.text[i2];
|
|
142213
|
+
}
|
|
142214
|
+
}
|
|
142215
|
+
});
|
|
142216
|
+
const lastOpen = text.lastIndexOf("{{");
|
|
142217
|
+
if (lastOpen === -1) {
|
|
142218
|
+
return null;
|
|
142219
|
+
}
|
|
142220
|
+
const queryText = text.substring(lastOpen + 2);
|
|
142221
|
+
if (queryText.includes("}}")) {
|
|
142222
|
+
return null;
|
|
142223
|
+
}
|
|
142224
|
+
const triggerFrom = posMap[lastOpen];
|
|
142225
|
+
if (triggerFrom === void 0) {
|
|
142226
|
+
return null;
|
|
142227
|
+
}
|
|
142228
|
+
const trimmedQuery = /^\}*$/.test(queryText) ? "" : queryText;
|
|
142229
|
+
return { triggerFrom, query: trimmedQuery };
|
|
142230
|
+
}
|
|
142231
|
+
const TYPE_PREFIXES = ["env", "memory", "system", "content"];
|
|
142232
|
+
function inferVariableType(path) {
|
|
142233
|
+
const firstDot = path.indexOf(".");
|
|
142234
|
+
if (firstDot === -1) return "custom";
|
|
142235
|
+
const prefix2 = path.substring(0, firstDot).toLowerCase();
|
|
142236
|
+
return TYPE_PREFIXES.includes(prefix2) ? prefix2 : "custom";
|
|
142237
|
+
}
|
|
142238
|
+
function removeTypePrefix(path) {
|
|
142239
|
+
const type = inferVariableType(path);
|
|
142240
|
+
if (type === "custom") return path;
|
|
142241
|
+
return path.substring(type.length + 1);
|
|
142242
|
+
}
|
|
141293
142243
|
const buildVariableSyntax = (variableType, path) => {
|
|
141294
142244
|
if (variableType === "system" || variableType === "custom") {
|
|
141295
142245
|
return `{{${path}}}`;
|
|
@@ -142008,6 +142958,27 @@ ${code2}
|
|
|
142008
142958
|
)
|
|
142009
142959
|
}
|
|
142010
142960
|
);
|
|
142961
|
+
const AIStarIcon = ({ size = 14, className }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
142962
|
+
"svg",
|
|
142963
|
+
{
|
|
142964
|
+
width: size,
|
|
142965
|
+
height: size,
|
|
142966
|
+
viewBox: "0 0 14 14",
|
|
142967
|
+
fill: "none",
|
|
142968
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
142969
|
+
className,
|
|
142970
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
142971
|
+
"path",
|
|
142972
|
+
{
|
|
142973
|
+
d: "M2.10833 12.3167V9.4M2.10833 3.56667V0.65M0.65 2.10833H3.56667M0.65 10.8583H3.56667M7.06667 1.23333L6.05506 3.8635C5.89056 4.29122 5.8083 4.50508 5.68039 4.68497C5.56703 4.8444 5.42773 4.98369 5.2683 5.09706C5.08841 5.22497 4.87455 5.30722 4.44684 5.47173L1.81667 6.48333L4.44684 7.49494C4.87455 7.65944 5.08841 7.7417 5.2683 7.86961C5.42773 7.98297 5.56703 8.12227 5.68039 8.2817C5.8083 8.46159 5.89056 8.67545 6.05506 9.10316L7.06667 11.7333L8.07827 9.10316C8.24278 8.67545 8.32503 8.46159 8.45294 8.2817C8.56631 8.12227 8.7056 7.98297 8.86503 7.86961C9.04492 7.7417 9.25878 7.65944 9.6865 7.49494L12.3167 6.48333L9.6865 5.47173C9.25878 5.30722 9.04492 5.22497 8.86503 5.09706C8.7056 4.98369 8.56631 4.8444 8.45294 4.68497C8.32503 4.50508 8.24278 4.29122 8.07827 3.8635L7.06667 1.23333Z",
|
|
142974
|
+
stroke: "currentColor",
|
|
142975
|
+
strokeWidth: "1.3",
|
|
142976
|
+
strokeLinecap: "round",
|
|
142977
|
+
strokeLinejoin: "round"
|
|
142978
|
+
}
|
|
142979
|
+
)
|
|
142980
|
+
}
|
|
142981
|
+
);
|
|
142011
142982
|
const CATEGORY_ICON_MAP = {
|
|
142012
142983
|
agents: AgentsIcon,
|
|
142013
142984
|
tools: ToolsIcon,
|
|
@@ -142884,7 +143855,7 @@ ${code2}
|
|
|
142884
143855
|
setCurrentPath(parsedQuery.path);
|
|
142885
143856
|
}
|
|
142886
143857
|
}, [parsedQuery.category, parsedQuery.path, activeCategory]);
|
|
142887
|
-
React.
|
|
143858
|
+
React.useLayoutEffect(() => {
|
|
142888
143859
|
if (!menuRef.current) return;
|
|
142889
143860
|
const menuRect = menuRef.current.getBoundingClientRect();
|
|
142890
143861
|
const viewportWidth = window.innerWidth;
|
|
@@ -142905,7 +143876,7 @@ ${code2}
|
|
|
142905
143876
|
newTop = padding;
|
|
142906
143877
|
}
|
|
142907
143878
|
setAdjustedPosition({ top: newTop, left: newLeft });
|
|
142908
|
-
}, [position]);
|
|
143879
|
+
}, [position, activeCategory, currentPath.length, query]);
|
|
142909
143880
|
const categories = [
|
|
142910
143881
|
{ id: "env", label: "Environment Variables", icon: VariableIcon, variables: envVariables },
|
|
142911
143882
|
{ id: "memory", label: "Memory", icon: MemoryIcon, variables: memoryVariables },
|
|
@@ -142980,13 +143951,21 @@ ${code2}
|
|
|
142980
143951
|
}
|
|
142981
143952
|
}, [editorControlled]);
|
|
142982
143953
|
React.useEffect(() => {
|
|
143954
|
+
const isEventInsideMenu = (event) => {
|
|
143955
|
+
if (!menuRef.current) return false;
|
|
143956
|
+
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
143957
|
+
if (path.length > 0) {
|
|
143958
|
+
return path.includes(menuRef.current);
|
|
143959
|
+
}
|
|
143960
|
+
return menuRef.current.contains(event.target);
|
|
143961
|
+
};
|
|
142983
143962
|
const handleClickOutside = (e) => {
|
|
142984
|
-
if (
|
|
143963
|
+
if (!isEventInsideMenu(e)) {
|
|
142985
143964
|
onClose();
|
|
142986
143965
|
}
|
|
142987
143966
|
};
|
|
142988
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
142989
|
-
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
143967
|
+
document.addEventListener("mousedown", handleClickOutside, true);
|
|
143968
|
+
return () => document.removeEventListener("mousedown", handleClickOutside, true);
|
|
142990
143969
|
}, [onClose]);
|
|
142991
143970
|
React.useEffect(() => {
|
|
142992
143971
|
const handleKeyDown2 = (e) => {
|
|
@@ -143073,6 +144052,10 @@ ${code2}
|
|
|
143073
144052
|
"button",
|
|
143074
144053
|
{
|
|
143075
144054
|
type: "button",
|
|
144055
|
+
onMouseDown: (e) => {
|
|
144056
|
+
e.preventDefault();
|
|
144057
|
+
e.stopPropagation();
|
|
144058
|
+
},
|
|
143076
144059
|
onClick: handleBack,
|
|
143077
144060
|
className: "flex items-center justify-center w-[24px] h-[24px] p-0 border-0 bg-[#F9FAFB] rounded-[4px] cursor-pointer text-[#667085] hover:bg-[#F2F4F7]",
|
|
143078
144061
|
"aria-label": "Go back",
|
|
@@ -143098,7 +144081,7 @@ ${code2}
|
|
|
143098
144081
|
)
|
|
143099
144082
|
] }) }),
|
|
143100
144083
|
!activeCategory && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pt-[8px] pb-[4px] px-[12px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[12px] leading-[16px] font-normal text-[#667085]", children: "Type to search or choose from:" }) }),
|
|
143101
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto", children: items.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-[16px] text-center text-[#667085] text-[14px]", children: "No items found" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: items.map((item, index) => {
|
|
144084
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 min-h-0 overflow-y-auto", children: items.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "py-[16px] text-center text-[#667085] text-[14px]", children: "No items found" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: items.map((item, index) => {
|
|
143102
144085
|
var _a;
|
|
143103
144086
|
const isCategory = "variables" in item;
|
|
143104
144087
|
const Icon = isCategory ? item.icon : getIconForType(item.type);
|
|
@@ -143107,7 +144090,11 @@ ${code2}
|
|
|
143107
144090
|
"button",
|
|
143108
144091
|
{
|
|
143109
144092
|
type: "button",
|
|
143110
|
-
|
|
144093
|
+
onMouseDown: (e) => {
|
|
144094
|
+
e.preventDefault();
|
|
144095
|
+
e.stopPropagation();
|
|
144096
|
+
handleItemClick(item);
|
|
144097
|
+
},
|
|
143111
144098
|
className: `flex items-center gap-[8px] w-full px-[12px] py-[8px] border-0 rounded-[4px] text-left cursor-pointer transition-colors duration-100 ${index === selectedIndex ? "bg-[#F9FAFB]" : "bg-transparent hover:bg-[#F9FAFB]"}`,
|
|
143112
144099
|
onMouseEnter: () => setSelectedIndex(index),
|
|
143113
144100
|
"data-test-id": `md-editor-variable-item-${isCategory ? item.id : item.id}`,
|
|
@@ -143683,7 +144670,9 @@ ${code2}
|
|
|
143683
144670
|
theme = "light",
|
|
143684
144671
|
disabled = false,
|
|
143685
144672
|
containerRef,
|
|
143686
|
-
followSelection = false
|
|
144673
|
+
followSelection = false,
|
|
144674
|
+
showDesignWithAI = false,
|
|
144675
|
+
onDesignWithAI
|
|
143687
144676
|
}) => {
|
|
143688
144677
|
const [position, setPosition] = React.useState(null);
|
|
143689
144678
|
const [isAtSelection, setIsAtSelection] = React.useState(false);
|
|
@@ -144041,7 +145030,30 @@ ${code2}
|
|
|
144041
145030
|
)
|
|
144042
145031
|
] }),
|
|
144043
145032
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ToolbarDivider$2, {}),
|
|
144044
|
-
|
|
145033
|
+
showDesignWithAI && onDesignWithAI && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
145034
|
+
"button",
|
|
145035
|
+
{
|
|
145036
|
+
type: "button",
|
|
145037
|
+
onClick: (e) => {
|
|
145038
|
+
e.preventDefault();
|
|
145039
|
+
e.stopPropagation();
|
|
145040
|
+
onDesignWithAI();
|
|
145041
|
+
},
|
|
145042
|
+
disabled,
|
|
145043
|
+
className: `
|
|
145044
|
+
flex items-center justify-center gap-1 px-3 py-1 rounded-[4px]
|
|
145045
|
+
text-[12px] leading-[16px] font-medium transition-colors duration-150 whitespace-nowrap
|
|
145046
|
+
border border-[#6A11CB] text-[#004EEB] hover:bg-[#EFF4FF]
|
|
145047
|
+
${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
145048
|
+
`,
|
|
145049
|
+
"data-id": "toolbar-design-with-ai",
|
|
145050
|
+
children: [
|
|
145051
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AIStarIcon, { size: 14, className: "text-[#155EEF]" }),
|
|
145052
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Design with AI" })
|
|
145053
|
+
]
|
|
145054
|
+
}
|
|
145055
|
+
),
|
|
145056
|
+
showAIButton && onAIAction && !showDesignWithAI && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: aiDropdownRef, className: "relative shrink-0", children: [
|
|
144045
145057
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
144046
145058
|
"button",
|
|
144047
145059
|
{
|
|
@@ -144156,7 +145168,8 @@ ${code2}
|
|
|
144156
145168
|
"make-shorter": "Make Shorter",
|
|
144157
145169
|
"make-longer": "Make Longer",
|
|
144158
145170
|
"convert-to-yaml": "Convert to YAML",
|
|
144159
|
-
"custom": "Custom Modify"
|
|
145171
|
+
"custom": "Custom Modify",
|
|
145172
|
+
"generate": "Generate"
|
|
144160
145173
|
};
|
|
144161
145174
|
function calculateTextSimilarity(text1, text2) {
|
|
144162
145175
|
if (text1 === text2) return 1;
|
|
@@ -144190,7 +145203,7 @@ ${code2}
|
|
|
144190
145203
|
sessionState,
|
|
144191
145204
|
sessionActions
|
|
144192
145205
|
}) => {
|
|
144193
|
-
var _a, _b;
|
|
145206
|
+
var _a, _b, _c;
|
|
144194
145207
|
const useSessionMode = !!sessionState && !!sessionActions;
|
|
144195
145208
|
const [messages, setMessages] = React.useState([]);
|
|
144196
145209
|
const [inputValue, setInputValue] = React.useState("");
|
|
@@ -144206,6 +145219,36 @@ ${code2}
|
|
|
144206
145219
|
const modificationReason = useSessionMode ? sessionState.modificationReason : selectionModifiedReason;
|
|
144207
145220
|
const currentGeneratedContent = useSessionMode ? (_b = sessionState.session) == null ? void 0 : _b.lastGeneratedContent : generatedContent;
|
|
144208
145221
|
const displayMessages = useSessionMode ? convertSessionHistoryToMessages(sessionState) : messages;
|
|
145222
|
+
const [appliedFeedback, setAppliedFeedback] = React.useState(null);
|
|
145223
|
+
const [copiedFeedback, setCopiedFeedback] = React.useState(false);
|
|
145224
|
+
const [pendingApplyMode, setPendingApplyMode] = React.useState(null);
|
|
145225
|
+
const [autocopiedOnFail, setAutocopiedOnFail] = React.useState(false);
|
|
145226
|
+
const appliedTimerRef = React.useRef(null);
|
|
145227
|
+
const copiedTimerRef = React.useRef(null);
|
|
145228
|
+
const lastAssistantMsgId = React.useMemo(() => {
|
|
145229
|
+
const assistantMsgs = displayMessages.filter(
|
|
145230
|
+
(m) => m.type === "assistant" && !m.isGenerating && !m.isError
|
|
145231
|
+
);
|
|
145232
|
+
return assistantMsgs.length > 0 ? assistantMsgs[assistantMsgs.length - 1].id : null;
|
|
145233
|
+
}, [displayMessages]);
|
|
145234
|
+
const showInsertButton = isSelectionMode;
|
|
145235
|
+
const cursorInsertActive = useSessionMode && sessionState.cursorInsertPosition !== null;
|
|
145236
|
+
const replaceTooltip = isSelectionMode ? "Replace selection" : "Replace all";
|
|
145237
|
+
const insertTooltip = cursorInsertActive ? "Insert at cursor" : "Insert below selection";
|
|
145238
|
+
React.useEffect(() => {
|
|
145239
|
+
return () => {
|
|
145240
|
+
if (appliedTimerRef.current) clearTimeout(appliedTimerRef.current);
|
|
145241
|
+
if (copiedTimerRef.current) clearTimeout(copiedTimerRef.current);
|
|
145242
|
+
};
|
|
145243
|
+
}, []);
|
|
145244
|
+
React.useEffect(() => {
|
|
145245
|
+
if (isCurrentlyGenerating) {
|
|
145246
|
+
setAppliedFeedback(null);
|
|
145247
|
+
setCopiedFeedback(false);
|
|
145248
|
+
setPendingApplyMode(null);
|
|
145249
|
+
setAutocopiedOnFail(false);
|
|
145250
|
+
}
|
|
145251
|
+
}, [isCurrentlyGenerating]);
|
|
144209
145252
|
React.useEffect(() => {
|
|
144210
145253
|
var _a2;
|
|
144211
145254
|
(_a2 = messagesEndRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "smooth" });
|
|
@@ -144309,8 +145352,9 @@ ${code2}
|
|
|
144309
145352
|
setGeneratedContent(response.refinedText);
|
|
144310
145353
|
onContentGenerated == null ? void 0 : onContentGenerated(true);
|
|
144311
145354
|
} catch (error) {
|
|
145355
|
+
const errorMsg = error instanceof Error ? error.message : "Failed to generate. Please try again.";
|
|
144312
145356
|
setMessages((prev) => prev.map(
|
|
144313
|
-
(msg) => msg.id === aiMsgId ? { ...msg, content:
|
|
145357
|
+
(msg) => msg.id === aiMsgId ? { ...msg, content: errorMsg, isGenerating: false, isError: true } : msg
|
|
144314
145358
|
));
|
|
144315
145359
|
} finally {
|
|
144316
145360
|
setIsGenerating(false);
|
|
@@ -144352,8 +145396,9 @@ ${code2}
|
|
|
144352
145396
|
setGeneratedContent(response.refinedText);
|
|
144353
145397
|
onContentGenerated == null ? void 0 : onContentGenerated(true);
|
|
144354
145398
|
} catch (error) {
|
|
145399
|
+
const errorMsg = error instanceof Error ? error.message : "Failed to generate. Please try again.";
|
|
144355
145400
|
setMessages((prev) => prev.map(
|
|
144356
|
-
(msg) => msg.id === aiMsgId ? { ...msg, content:
|
|
145401
|
+
(msg) => msg.id === aiMsgId ? { ...msg, content: errorMsg, isGenerating: false, isError: true } : msg
|
|
144357
145402
|
));
|
|
144358
145403
|
} finally {
|
|
144359
145404
|
setIsGenerating(false);
|
|
@@ -144388,6 +145433,52 @@ ${code2}
|
|
|
144388
145433
|
};
|
|
144389
145434
|
}
|
|
144390
145435
|
}, [useSessionMode, sessionActions, generatedContent, onReplace, isSelectionMode]);
|
|
145436
|
+
const handleCopy = React.useCallback(async () => {
|
|
145437
|
+
var _a2;
|
|
145438
|
+
const content = useSessionMode ? (_a2 = sessionState == null ? void 0 : sessionState.session) == null ? void 0 : _a2.lastGeneratedContent : generatedContent;
|
|
145439
|
+
if (content) {
|
|
145440
|
+
await navigator.clipboard.writeText(content);
|
|
145441
|
+
setCopiedFeedback(true);
|
|
145442
|
+
if (copiedTimerRef.current) clearTimeout(copiedTimerRef.current);
|
|
145443
|
+
copiedTimerRef.current = setTimeout(() => setCopiedFeedback(false), 2e3);
|
|
145444
|
+
}
|
|
145445
|
+
}, [useSessionMode, sessionState, generatedContent]);
|
|
145446
|
+
const handleInsertWithFeedback = React.useCallback(() => {
|
|
145447
|
+
setPendingApplyMode("insert");
|
|
145448
|
+
setAutocopiedOnFail(false);
|
|
145449
|
+
handleInsert();
|
|
145450
|
+
}, [handleInsert]);
|
|
145451
|
+
const handleReplaceWithFeedback = React.useCallback(() => {
|
|
145452
|
+
setPendingApplyMode("replace");
|
|
145453
|
+
setAutocopiedOnFail(false);
|
|
145454
|
+
handleReplace();
|
|
145455
|
+
}, [handleReplace]);
|
|
145456
|
+
React.useEffect(() => {
|
|
145457
|
+
var _a2;
|
|
145458
|
+
if (!pendingApplyMode) return;
|
|
145459
|
+
if (useSessionMode) {
|
|
145460
|
+
if (sessionState.status === "applied") {
|
|
145461
|
+
setAppliedFeedback(pendingApplyMode);
|
|
145462
|
+
setPendingApplyMode(null);
|
|
145463
|
+
if (appliedTimerRef.current) clearTimeout(appliedTimerRef.current);
|
|
145464
|
+
appliedTimerRef.current = setTimeout(() => setAppliedFeedback(null), 2500);
|
|
145465
|
+
} else if (sessionState.isOriginalModified) {
|
|
145466
|
+
const content = (_a2 = sessionState.session) == null ? void 0 : _a2.lastGeneratedContent;
|
|
145467
|
+
if (content) {
|
|
145468
|
+
navigator.clipboard.writeText(content).catch(() => {
|
|
145469
|
+
});
|
|
145470
|
+
setAutocopiedOnFail(true);
|
|
145471
|
+
}
|
|
145472
|
+
setAppliedFeedback(null);
|
|
145473
|
+
setPendingApplyMode(null);
|
|
145474
|
+
}
|
|
145475
|
+
} else {
|
|
145476
|
+
setAppliedFeedback(pendingApplyMode);
|
|
145477
|
+
setPendingApplyMode(null);
|
|
145478
|
+
if (appliedTimerRef.current) clearTimeout(appliedTimerRef.current);
|
|
145479
|
+
appliedTimerRef.current = setTimeout(() => setAppliedFeedback(null), 2500);
|
|
145480
|
+
}
|
|
145481
|
+
}, [pendingApplyMode, useSessionMode, sessionState == null ? void 0 : sessionState.status, sessionState == null ? void 0 : sessionState.isOriginalModified, (_c = sessionState == null ? void 0 : sessionState.session) == null ? void 0 : _c.lastGeneratedContent]);
|
|
144391
145482
|
const handleStop = React.useCallback(() => {
|
|
144392
145483
|
if (useSessionMode) {
|
|
144393
145484
|
return;
|
|
@@ -144487,34 +145578,71 @@ ${code2}
|
|
|
144487
145578
|
// Result - gray background bubble
|
|
144488
145579
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full", children: [
|
|
144489
145580
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-[#F2F4F7] rounded-xl p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-[#101828] leading-relaxed whitespace-pre-wrap", children: message.content }) }),
|
|
144490
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
144491
|
-
/*
|
|
144492
|
-
|
|
144493
|
-
{
|
|
144494
|
-
|
|
144495
|
-
|
|
144496
|
-
|
|
144497
|
-
|
|
144498
|
-
|
|
144499
|
-
|
|
144500
|
-
|
|
144501
|
-
|
|
144502
|
-
|
|
144503
|
-
"
|
|
144504
|
-
|
|
144505
|
-
|
|
144506
|
-
|
|
144507
|
-
|
|
144508
|
-
|
|
144509
|
-
|
|
144510
|
-
|
|
144511
|
-
|
|
144512
|
-
|
|
144513
|
-
|
|
144514
|
-
|
|
144515
|
-
|
|
144516
|
-
|
|
144517
|
-
|
|
145581
|
+
message.id === lastAssistantMsgId && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: appliedFeedback ? (
|
|
145582
|
+
/* Success feedback */
|
|
145583
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5 mt-2 text-[#12B76A] animate-[fadeIn_0.2s_ease-out]", children: [
|
|
145584
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { size: 14, strokeWidth: 2.5 }),
|
|
145585
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-medium", children: appliedFeedback === "replace" ? "Replaced" : "Inserted" }),
|
|
145586
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-[#667085] ml-1", children: [
|
|
145587
|
+
navigator.platform.includes("Mac") ? "⌘Z" : "Ctrl+Z",
|
|
145588
|
+
" to undo"
|
|
145589
|
+
] })
|
|
145590
|
+
] })
|
|
145591
|
+
) : isModified ? (
|
|
145592
|
+
/* Recovery UI -- original text was modified, apply would fail */
|
|
145593
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 animate-[fadeIn_0.2s_ease-out]", children: [
|
|
145594
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
145595
|
+
"button",
|
|
145596
|
+
{
|
|
145597
|
+
type: "button",
|
|
145598
|
+
onClick: handleCopy,
|
|
145599
|
+
className: "px-2.5 py-0.5 text-sm font-medium rounded-full border transition-colors text-[#344054] bg-white border-[#EAECF0] hover:bg-gray-50 cursor-pointer flex items-center gap-1.5",
|
|
145600
|
+
children: copiedFeedback || autocopiedOnFail ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
145601
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { size: 12, className: "text-[#12B76A]" }),
|
|
145602
|
+
" Copied"
|
|
145603
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
145604
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { size: 12 }),
|
|
145605
|
+
" Copy content"
|
|
145606
|
+
] })
|
|
145607
|
+
}
|
|
145608
|
+
) }),
|
|
145609
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-[#667085] mt-1.5", children: autocopiedOnFail ? "Content saved to clipboard. Paste manually or re-select text to try again." : `${modificationReason || "Original text changed"}. Copy content and paste manually, or re-select text.` })
|
|
145610
|
+
] })
|
|
145611
|
+
) : (
|
|
145612
|
+
/* Normal action buttons */
|
|
145613
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 mt-2", children: [
|
|
145614
|
+
(onReplace || useSessionMode) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
145615
|
+
"button",
|
|
145616
|
+
{
|
|
145617
|
+
type: "button",
|
|
145618
|
+
onClick: handleReplaceWithFeedback,
|
|
145619
|
+
title: replaceTooltip,
|
|
145620
|
+
className: "px-2.5 py-0.5 text-sm font-medium rounded-full border transition-colors text-white bg-[#155EEF] border-[#155EEF] hover:bg-[#1849D6] cursor-pointer",
|
|
145621
|
+
children: "Replace"
|
|
145622
|
+
}
|
|
145623
|
+
),
|
|
145624
|
+
showInsertButton && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
145625
|
+
"button",
|
|
145626
|
+
{
|
|
145627
|
+
type: "button",
|
|
145628
|
+
onClick: handleInsertWithFeedback,
|
|
145629
|
+
title: insertTooltip,
|
|
145630
|
+
className: "px-2.5 py-0.5 text-sm font-medium rounded-full border transition-colors text-[#344054] bg-white border-[#EAECF0] hover:bg-gray-50 cursor-pointer",
|
|
145631
|
+
children: "Insert"
|
|
145632
|
+
}
|
|
145633
|
+
),
|
|
145634
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
145635
|
+
"button",
|
|
145636
|
+
{
|
|
145637
|
+
type: "button",
|
|
145638
|
+
onClick: handleCopy,
|
|
145639
|
+
title: copiedFeedback ? "Copied!" : "Copy to clipboard",
|
|
145640
|
+
className: "p-1 text-[#667085] hover:text-[#344054] hover:bg-gray-100 rounded transition-colors cursor-pointer",
|
|
145641
|
+
children: copiedFeedback ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { size: 14, className: "text-[#12B76A]" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { size: 14 })
|
|
145642
|
+
}
|
|
145643
|
+
)
|
|
145644
|
+
] })
|
|
145645
|
+
) })
|
|
144518
145646
|
] })
|
|
144519
145647
|
) })
|
|
144520
145648
|
) }, message.id)),
|
|
@@ -144597,6 +145725,32 @@ ${code2}
|
|
|
144597
145725
|
}
|
|
144598
145726
|
return messages;
|
|
144599
145727
|
}
|
|
145728
|
+
const EmptyStatePlaceholder = ({
|
|
145729
|
+
placeholder = "Write your agent definition here or type '/' to insert variables, agents, tools, memory & more",
|
|
145730
|
+
example,
|
|
145731
|
+
isFocused = false
|
|
145732
|
+
}) => {
|
|
145733
|
+
if (isFocused) return null;
|
|
145734
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
145735
|
+
"div",
|
|
145736
|
+
{
|
|
145737
|
+
className: "absolute inset-0 pointer-events-none px-[32px] py-[24px] overflow-hidden",
|
|
145738
|
+
"data-id": "md-editor-empty-state",
|
|
145739
|
+
children: [
|
|
145740
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-[14px] leading-[20px] text-[#98A2B3] mb-[8px]", children: placeholder }),
|
|
145741
|
+
example && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-[14px] leading-[20px] text-[#98A2B3]", children: example })
|
|
145742
|
+
]
|
|
145743
|
+
}
|
|
145744
|
+
);
|
|
145745
|
+
};
|
|
145746
|
+
const AgentDefinitionExample = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
145747
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mb-[14px]", children: "e.g., You are a meeting scheduler agent who coordinate sales meetings by checking team availability, matching prospect needs with appropriate sales specialists, and sending prep materials." }),
|
|
145748
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("ul", { className: "list-disc ml-[21px]", children: [
|
|
145749
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { className: "mb-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "leading-[20px]", children: "Match prospect needs with sales expertise" }) }),
|
|
145750
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { className: "mb-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "leading-[20px]", children: "Find optimal meeting times across calendars" }) }),
|
|
145751
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "leading-[20px]", children: "Distribute meeting agenda and materials" }) })
|
|
145752
|
+
] })
|
|
145753
|
+
] });
|
|
144600
145754
|
function hashString(str) {
|
|
144601
145755
|
let hash2 = 5381;
|
|
144602
145756
|
for (let i2 = 0; i2 < str.length; i2++) {
|
|
@@ -144806,7 +145960,8 @@ ${code2}
|
|
|
144806
145960
|
modificationReason: "",
|
|
144807
145961
|
pendingSelection: null,
|
|
144808
145962
|
showSwitchBanner: false,
|
|
144809
|
-
error: null
|
|
145963
|
+
error: null,
|
|
145964
|
+
cursorInsertPosition: null
|
|
144810
145965
|
};
|
|
144811
145966
|
function refinementReducer(state, action) {
|
|
144812
145967
|
switch (action.type) {
|
|
@@ -144917,7 +146072,7 @@ ${code2}
|
|
|
144917
146072
|
}
|
|
144918
146073
|
case "APPLY_CONTENT": {
|
|
144919
146074
|
if (!state.session) return state;
|
|
144920
|
-
const { appliedContent } = action.payload;
|
|
146075
|
+
const { appliedContent, newFingerprint } = action.payload;
|
|
144921
146076
|
return {
|
|
144922
146077
|
...state,
|
|
144923
146078
|
status: "applied",
|
|
@@ -144925,8 +146080,11 @@ ${code2}
|
|
|
144925
146080
|
...state.session,
|
|
144926
146081
|
appliedContent,
|
|
144927
146082
|
applyCount: state.session.applyCount + 1,
|
|
144928
|
-
workingContent: appliedContent
|
|
146083
|
+
workingContent: appliedContent,
|
|
144929
146084
|
// For subsequent refinements
|
|
146085
|
+
// Update fingerprint to track the newly applied content's position
|
|
146086
|
+
// This enables subsequent iterations to work on the replaced content
|
|
146087
|
+
fingerprint: newFingerprint || state.session.fingerprint
|
|
144930
146088
|
},
|
|
144931
146089
|
isOriginalModified: false,
|
|
144932
146090
|
modificationReason: ""
|
|
@@ -144934,9 +146092,9 @@ ${code2}
|
|
|
144934
146092
|
}
|
|
144935
146093
|
case "SELECTION_CHANGED": {
|
|
144936
146094
|
if (!state.session) return state;
|
|
144937
|
-
const { fingerprint } = action.payload;
|
|
144938
|
-
const
|
|
144939
|
-
const newMode =
|
|
146095
|
+
const { fingerprint, explicitMode } = action.payload;
|
|
146096
|
+
const inferredMode = fingerprint.contextBefore === "" && fingerprint.contextAfter === "" ? "full-document" : "selection";
|
|
146097
|
+
const newMode = explicitMode ?? inferredMode;
|
|
144940
146098
|
return {
|
|
144941
146099
|
...state,
|
|
144942
146100
|
session: {
|
|
@@ -144944,8 +146102,10 @@ ${code2}
|
|
|
144944
146102
|
mode: newMode,
|
|
144945
146103
|
fingerprint,
|
|
144946
146104
|
workingContent: fingerprint.selectedMarkdown,
|
|
144947
|
-
// Reset
|
|
144948
|
-
appliedContent: null
|
|
146105
|
+
// Reset apply state since selection changed -- previous apply context is irrelevant
|
|
146106
|
+
appliedContent: null,
|
|
146107
|
+
applyCount: 0,
|
|
146108
|
+
lastGeneratedContent: null
|
|
144949
146109
|
},
|
|
144950
146110
|
// Clear modification state since we have a fresh selection
|
|
144951
146111
|
isOriginalModified: false,
|
|
@@ -144953,7 +146113,8 @@ ${code2}
|
|
|
144953
146113
|
// Only show switch banner if there was content and this is user-initiated selection change
|
|
144954
146114
|
// For now, keep it simple - don't show banner, just update context
|
|
144955
146115
|
pendingSelection: null,
|
|
144956
|
-
showSwitchBanner: false
|
|
146116
|
+
showSwitchBanner: false,
|
|
146117
|
+
cursorInsertPosition: null
|
|
144957
146118
|
};
|
|
144958
146119
|
}
|
|
144959
146120
|
case "CONFIRM_SWITCH": {
|
|
@@ -145022,6 +146183,11 @@ ${code2}
|
|
|
145022
146183
|
}
|
|
145023
146184
|
};
|
|
145024
146185
|
}
|
|
146186
|
+
case "SET_CURSOR_INSERT_POSITION":
|
|
146187
|
+
return {
|
|
146188
|
+
...state,
|
|
146189
|
+
cursorInsertPosition: action.payload.position
|
|
146190
|
+
};
|
|
145025
146191
|
default:
|
|
145026
146192
|
return state;
|
|
145027
146193
|
}
|
|
@@ -145031,7 +146197,8 @@ ${code2}
|
|
|
145031
146197
|
onRefine,
|
|
145032
146198
|
editorContent,
|
|
145033
146199
|
promptType,
|
|
145034
|
-
agentContext
|
|
146200
|
+
agentContext,
|
|
146201
|
+
onContentApplied
|
|
145035
146202
|
}) {
|
|
145036
146203
|
const [state, dispatch] = React.useReducer(refinementReducer, initialState);
|
|
145037
146204
|
const hasGeneratedContentRef = React.useRef(false);
|
|
@@ -145050,14 +146217,18 @@ ${code2}
|
|
|
145050
146217
|
});
|
|
145051
146218
|
if (editor) {
|
|
145052
146219
|
let fingerprint;
|
|
145053
|
-
|
|
146220
|
+
const isSelection = !!range2 && range2.from !== range2.to;
|
|
146221
|
+
if (isSelection) {
|
|
145054
146222
|
fingerprint = createSelectionFingerprint(editor, range2.from, range2.to);
|
|
145055
146223
|
} else {
|
|
145056
146224
|
fingerprint = createFullDocumentFingerprint(editor);
|
|
145057
146225
|
}
|
|
145058
146226
|
dispatch({
|
|
145059
146227
|
type: "SELECTION_CHANGED",
|
|
145060
|
-
payload: {
|
|
146228
|
+
payload: {
|
|
146229
|
+
fingerprint,
|
|
146230
|
+
explicitMode: isSelection ? "selection" : "full-document"
|
|
146231
|
+
}
|
|
145061
146232
|
});
|
|
145062
146233
|
}
|
|
145063
146234
|
}, [editor]);
|
|
@@ -145067,13 +146238,24 @@ ${code2}
|
|
|
145067
146238
|
}, []);
|
|
145068
146239
|
const startGeneration = React.useCallback(async (action, instruction) => {
|
|
145069
146240
|
if (!onRefine || !state.session) return;
|
|
145070
|
-
|
|
146241
|
+
let contextText;
|
|
146242
|
+
if (state.session.mode === "full-document" && state.session.applyCount > 0) {
|
|
146243
|
+
contextText = editorContent || state.session.appliedContent || state.session.workingContent;
|
|
146244
|
+
} else if (state.session.applyCount > 0) {
|
|
146245
|
+
contextText = state.session.appliedContent || state.session.workingContent;
|
|
146246
|
+
} else {
|
|
146247
|
+
contextText = state.session.lastGeneratedContent || state.session.workingContent;
|
|
146248
|
+
}
|
|
146249
|
+
if (!contextText) {
|
|
146250
|
+
contextText = editorContent;
|
|
146251
|
+
}
|
|
145071
146252
|
const actionLabels = {
|
|
145072
146253
|
"improve": "Improve",
|
|
145073
146254
|
"make-shorter": "Make Shorter",
|
|
145074
146255
|
"make-longer": "Make Longer",
|
|
145075
146256
|
"convert-to-yaml": "Convert to YAML",
|
|
145076
|
-
"custom": instruction || "Custom"
|
|
146257
|
+
"custom": instruction || "Custom",
|
|
146258
|
+
"generate": "Generate new content"
|
|
145077
146259
|
};
|
|
145078
146260
|
const displayMessage = instruction || actionLabels[action] || action;
|
|
145079
146261
|
const isFirstMessage = state.session.conversationHistory.length === 0;
|
|
@@ -145133,7 +146315,7 @@ ${code2}
|
|
|
145133
146315
|
"custom": instruction || "Custom"
|
|
145134
146316
|
};
|
|
145135
146317
|
const displayMessage = instruction || actionLabels[action] || action;
|
|
145136
|
-
const contentForAI = ((_a = state.session.fingerprint) == null ? void 0 : _a.selectedMarkdown) || state.session.workingContent;
|
|
146318
|
+
const contentForAI = ((_a = state.session.fingerprint) == null ? void 0 : _a.selectedMarkdown) || state.session.workingContent || editorContent;
|
|
145137
146319
|
const quotedText = contentForAI.length > 100 ? `${contentForAI.substring(0, 100)}...` : contentForAI;
|
|
145138
146320
|
dispatch({
|
|
145139
146321
|
type: "START_GENERATION",
|
|
@@ -145177,11 +146359,13 @@ ${code2}
|
|
|
145177
146359
|
if (!editor || !state.session || !state.session.lastGeneratedContent) return;
|
|
145178
146360
|
const refinedText = state.session.lastGeneratedContent;
|
|
145179
146361
|
let result;
|
|
146362
|
+
let newFingerprint;
|
|
145180
146363
|
if (state.session.mode === "full-document") {
|
|
145181
146364
|
try {
|
|
145182
146365
|
const parsed = markdownToEditorJson(refinedText);
|
|
145183
146366
|
editor.commands.setContent(parsed);
|
|
145184
146367
|
result = { success: true };
|
|
146368
|
+
newFingerprint = createFullDocumentFingerprint(editor);
|
|
145185
146369
|
} catch (error) {
|
|
145186
146370
|
result = {
|
|
145187
146371
|
success: false,
|
|
@@ -145201,10 +146385,17 @@ ${code2}
|
|
|
145201
146385
|
} else {
|
|
145202
146386
|
try {
|
|
145203
146387
|
const parsedContent = markdownToEditorJson(refinedText);
|
|
146388
|
+
const insertionStart = matchedRange.from;
|
|
145204
146389
|
if (mode === "replace") {
|
|
145205
146390
|
editor.chain().focus().setTextSelection(matchedRange).deleteSelection().insertContent(parsedContent).run();
|
|
146391
|
+
const newEndPos = editor.state.selection.to;
|
|
146392
|
+
newFingerprint = createSelectionFingerprint(editor, insertionStart, newEndPos);
|
|
145206
146393
|
} else {
|
|
145207
|
-
|
|
146394
|
+
const useCursorPos = state.cursorInsertPosition !== null && state.cursorInsertPosition !== matchedRange.to;
|
|
146395
|
+
const insertPos = useCursorPos ? state.cursorInsertPosition : matchedRange.to;
|
|
146396
|
+
editor.chain().focus().setTextSelection({ from: insertPos, to: insertPos }).insertContent("\n\n").insertContent(parsedContent).run();
|
|
146397
|
+
const newEndPos = editor.state.selection.to;
|
|
146398
|
+
newFingerprint = createSelectionFingerprint(editor, insertPos + 2, newEndPos);
|
|
145208
146399
|
}
|
|
145209
146400
|
result = { success: true };
|
|
145210
146401
|
} catch (error) {
|
|
@@ -145219,8 +146410,12 @@ ${code2}
|
|
|
145219
146410
|
if (result.success) {
|
|
145220
146411
|
dispatch({
|
|
145221
146412
|
type: "APPLY_CONTENT",
|
|
145222
|
-
payload: { mode, appliedContent: refinedText }
|
|
146413
|
+
payload: { mode, appliedContent: refinedText, newFingerprint }
|
|
145223
146414
|
});
|
|
146415
|
+
if (onContentApplied && editor) {
|
|
146416
|
+
const fullMarkdown = state.session.mode === "full-document" ? refinedText : editorJsonToMarkdown(editor.getJSON());
|
|
146417
|
+
onContentApplied(fullMarkdown);
|
|
146418
|
+
}
|
|
145224
146419
|
} else {
|
|
145225
146420
|
dispatch({
|
|
145226
146421
|
type: "SET_MODIFIED",
|
|
@@ -145230,7 +146425,7 @@ ${code2}
|
|
|
145230
146425
|
}
|
|
145231
146426
|
});
|
|
145232
146427
|
}
|
|
145233
|
-
}, [editor, state.session]);
|
|
146428
|
+
}, [editor, state.session, state.cursorInsertPosition, onContentApplied]);
|
|
145234
146429
|
const handleSelectionChange = React.useCallback((from, to, _text) => {
|
|
145235
146430
|
if (!editor || !state.session) return;
|
|
145236
146431
|
if (from === to) return;
|
|
@@ -145242,7 +146437,7 @@ ${code2}
|
|
|
145242
146437
|
}
|
|
145243
146438
|
dispatch({
|
|
145244
146439
|
type: "SELECTION_CHANGED",
|
|
145245
|
-
payload: { fingerprint: newFingerprint }
|
|
146440
|
+
payload: { fingerprint: newFingerprint, explicitMode: "selection" }
|
|
145246
146441
|
});
|
|
145247
146442
|
}, [editor, state.session]);
|
|
145248
146443
|
const confirmSwitch = React.useCallback(() => {
|
|
@@ -145281,19 +146476,31 @@ ${code2}
|
|
|
145281
146476
|
React.useEffect(() => {
|
|
145282
146477
|
if (!editor || state.status === "idle") return;
|
|
145283
146478
|
const handleSelectionUpdate = () => {
|
|
146479
|
+
var _a, _b;
|
|
145284
146480
|
const { from, to } = editor.state.selection;
|
|
145285
146481
|
const hasSelection2 = from !== to;
|
|
145286
|
-
if (
|
|
145287
|
-
|
|
146482
|
+
if (hasSelection2) {
|
|
146483
|
+
if (hasGeneratedContentRef.current) {
|
|
146484
|
+
const selectedText = editor.state.doc.textBetween(from, to, " ", "\n");
|
|
146485
|
+
handleSelectionChange(from, to, selectedText);
|
|
146486
|
+
}
|
|
146487
|
+
if (state.cursorInsertPosition !== null) {
|
|
146488
|
+
dispatch({ type: "SET_CURSOR_INSERT_POSITION", payload: { position: null } });
|
|
146489
|
+
}
|
|
146490
|
+
} else if (((_a = state.session) == null ? void 0 : _a.mode) === "selection" && ((_b = state.session) == null ? void 0 : _b.fingerprint) && hasGeneratedContentRef.current) {
|
|
146491
|
+
const fp = state.session.fingerprint;
|
|
146492
|
+
const isOutside = from < fp.originalRange.from || from > fp.originalRange.to;
|
|
146493
|
+
const newPos = isOutside ? from : null;
|
|
146494
|
+
if (newPos !== state.cursorInsertPosition) {
|
|
146495
|
+
dispatch({ type: "SET_CURSOR_INSERT_POSITION", payload: { position: newPos } });
|
|
146496
|
+
}
|
|
145288
146497
|
}
|
|
145289
|
-
const selectedText = editor.state.doc.textBetween(from, to, " ", "\n");
|
|
145290
|
-
handleSelectionChange(from, to, selectedText);
|
|
145291
146498
|
};
|
|
145292
146499
|
editor.on("selectionUpdate", handleSelectionUpdate);
|
|
145293
146500
|
return () => {
|
|
145294
146501
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
145295
146502
|
};
|
|
145296
|
-
}, [editor, state.status, handleSelectionChange]);
|
|
146503
|
+
}, [editor, state.status, state.session, state.cursorInsertPosition, handleSelectionChange]);
|
|
145297
146504
|
const actions = {
|
|
145298
146505
|
openPanel,
|
|
145299
146506
|
closePanel,
|
|
@@ -145360,7 +146567,12 @@ ${code2}
|
|
|
145360
146567
|
onFocus,
|
|
145361
146568
|
onBlur,
|
|
145362
146569
|
onLoadSuggestions,
|
|
145363
|
-
suggestionsLoading: propSuggestionsLoading = false
|
|
146570
|
+
suggestionsLoading: propSuggestionsLoading = false,
|
|
146571
|
+
// Empty state props
|
|
146572
|
+
emptyStatePlaceholder,
|
|
146573
|
+
emptyStateExample,
|
|
146574
|
+
showDesignWithAI = false,
|
|
146575
|
+
onDesignWithAI
|
|
145364
146576
|
} = props;
|
|
145365
146577
|
const mergedSlashConfig = { ...DEFAULT_SLASH_COMMAND_CONFIG, ...slashCommandConfig };
|
|
145366
146578
|
const mergedAIConfig = { ...DEFAULT_AI_CONFIG, ...aiConfig };
|
|
@@ -145368,13 +146580,16 @@ ${code2}
|
|
|
145368
146580
|
const lastEmittedMarkdownRef = React.useRef("");
|
|
145369
146581
|
const isInternalUpdateRef = React.useRef(false);
|
|
145370
146582
|
const editorContainerRef = React.useRef(null);
|
|
146583
|
+
const skipRawSyncRef = React.useRef(false);
|
|
146584
|
+
const skipEditorSyncRef = React.useRef(false);
|
|
145371
146585
|
const [asyncSuggestions, setAsyncSuggestions] = React.useState(null);
|
|
145372
146586
|
const [suggestionsLoading, setSuggestionsLoading] = React.useState(false);
|
|
145373
146587
|
const [variableMenuOpen, setVariableMenuOpen] = React.useState(false);
|
|
145374
146588
|
const [variableMenuPosition, setVariableMenuPosition] = React.useState({ top: 0, left: 0 });
|
|
145375
146589
|
const [variableMenuQuery, setVariableMenuQuery] = React.useState("");
|
|
145376
|
-
const [editingVariableChip, setEditingVariableChip] = React.useState(null);
|
|
145377
146590
|
const variableTriggerPosRef = React.useRef(null);
|
|
146591
|
+
const hasVariableSuggestionsRef = React.useRef(false);
|
|
146592
|
+
const variableMenuOpenRef = React.useRef(false);
|
|
145378
146593
|
const [editorMode, setEditorMode] = React.useState("editor");
|
|
145379
146594
|
const [rawMarkdown, setRawMarkdown] = React.useState("");
|
|
145380
146595
|
const isRawMode = editorMode === "preview";
|
|
@@ -145418,12 +146633,7 @@ ${code2}
|
|
|
145418
146633
|
contentVariables: mergedContentVariables,
|
|
145419
146634
|
loading: finalSuggestionsLoading
|
|
145420
146635
|
};
|
|
145421
|
-
|
|
145422
|
-
agentsCount: mergedAgents.length,
|
|
145423
|
-
toolsCount: mergedTools.length,
|
|
145424
|
-
knowledgeCount: mergedKnowledge.length,
|
|
145425
|
-
hasAsyncSuggestions: !!asyncSuggestions
|
|
145426
|
-
});
|
|
146636
|
+
hasVariableSuggestionsRef.current = mergedEnvVariables.length > 0 || mergedMemoryVariables.length > 0 || mergedSystemVariables.length > 0 || mergedContentVariables.length > 0;
|
|
145427
146637
|
const defaultCategories = React.useMemo(() => {
|
|
145428
146638
|
const categories = [];
|
|
145429
146639
|
if (mergedAgents.length > 0) {
|
|
@@ -145488,21 +146698,6 @@ ${code2}
|
|
|
145488
146698
|
(variable, triggerPos) => {
|
|
145489
146699
|
if (!editorRef.current) return;
|
|
145490
146700
|
const editor2 = editorRef.current;
|
|
145491
|
-
if (editingVariableChip) {
|
|
145492
|
-
const { position, nodeSize: nodeSize2 } = editingVariableChip;
|
|
145493
|
-
editor2.chain().focus().deleteRange({ from: position, to: position + nodeSize2 }).insertContentAt(position, {
|
|
145494
|
-
type: "variableChip",
|
|
145495
|
-
attrs: {
|
|
145496
|
-
variableType: variable.type,
|
|
145497
|
-
path: variable.path,
|
|
145498
|
-
displayName: variable.name
|
|
145499
|
-
}
|
|
145500
|
-
}).run();
|
|
145501
|
-
setEditingVariableChip(null);
|
|
145502
|
-
setVariableMenuOpen(false);
|
|
145503
|
-
setVariableMenuQuery("");
|
|
145504
|
-
return;
|
|
145505
|
-
}
|
|
145506
146701
|
const deleteFrom = triggerPos ?? variableTriggerPosRef.current;
|
|
145507
146702
|
if (deleteFrom !== null) {
|
|
145508
146703
|
const { from } = editor2.state.selection;
|
|
@@ -145515,6 +146710,10 @@ ${code2}
|
|
|
145515
146710
|
displayName: variable.name
|
|
145516
146711
|
}
|
|
145517
146712
|
}).insertContent(" ").run();
|
|
146713
|
+
const posAfter = editor2.state.selection.from;
|
|
146714
|
+
if (posAfter + 2 <= editor2.state.doc.content.size && editor2.state.doc.textBetween(posAfter, posAfter + 2) === "}}") {
|
|
146715
|
+
editor2.chain().focus().deleteRange({ from: posAfter, to: posAfter + 2 }).run();
|
|
146716
|
+
}
|
|
145518
146717
|
} else {
|
|
145519
146718
|
editor2.chain().focus().insertContent({
|
|
145520
146719
|
type: "variableChip",
|
|
@@ -145529,7 +146728,19 @@ ${code2}
|
|
|
145529
146728
|
setVariableMenuQuery("");
|
|
145530
146729
|
variableTriggerPosRef.current = null;
|
|
145531
146730
|
},
|
|
145532
|
-
[
|
|
146731
|
+
[]
|
|
146732
|
+
);
|
|
146733
|
+
const handleVariableQueryChange = React.useCallback(
|
|
146734
|
+
(newQuery) => {
|
|
146735
|
+
setVariableMenuQuery(newQuery);
|
|
146736
|
+
if (!editorRef.current || variableTriggerPosRef.current === null) return;
|
|
146737
|
+
const editor2 = editorRef.current;
|
|
146738
|
+
const triggerPos = variableTriggerPosRef.current;
|
|
146739
|
+
const insertFrom = triggerPos + 2;
|
|
146740
|
+
const { from } = editor2.state.selection;
|
|
146741
|
+
editor2.chain().focus().deleteRange({ from: insertFrom, to: from }).insertContentAt(insertFrom, newQuery).run();
|
|
146742
|
+
},
|
|
146743
|
+
[]
|
|
145533
146744
|
);
|
|
145534
146745
|
const insertMention = React.useCallback(
|
|
145535
146746
|
(mention) => {
|
|
@@ -145564,14 +146775,23 @@ ${code2}
|
|
|
145564
146775
|
const json = editorRef.current.getJSON();
|
|
145565
146776
|
const markdown = editorJsonToMarkdown(json);
|
|
145566
146777
|
setRawMarkdown(markdown);
|
|
146778
|
+
lastEmittedMarkdownRef.current = markdown;
|
|
146779
|
+
skipRawSyncRef.current = true;
|
|
145567
146780
|
}
|
|
145568
146781
|
if (currentMode === "preview" && newMode === "editor") {
|
|
145569
146782
|
const parsedContent = markdownToEditorJson(rawMarkdown);
|
|
146783
|
+
isInternalUpdateRef.current = true;
|
|
145570
146784
|
editorRef.current.commands.setContent(parsedContent);
|
|
145571
146785
|
lastEmittedMarkdownRef.current = rawMarkdown;
|
|
146786
|
+
skipEditorSyncRef.current = true;
|
|
146787
|
+
onMarkdownChange == null ? void 0 : onMarkdownChange(rawMarkdown);
|
|
146788
|
+
if (onChange) {
|
|
146789
|
+
const doc2 = editorJsonToDocument(parsedContent);
|
|
146790
|
+
onChange(doc2, rawMarkdown);
|
|
146791
|
+
}
|
|
145572
146792
|
}
|
|
145573
146793
|
setEditorMode(newMode);
|
|
145574
|
-
}, [editorMode, rawMarkdown]);
|
|
146794
|
+
}, [editorMode, rawMarkdown, onChange, onMarkdownChange]);
|
|
145575
146795
|
const toggleRawMode = React.useCallback(() => {
|
|
145576
146796
|
handleModeChange(isRawMode ? "editor" : "preview");
|
|
145577
146797
|
}, [handleModeChange, isRawMode]);
|
|
@@ -145586,13 +146806,17 @@ ${code2}
|
|
|
145586
146806
|
dropcursor: false
|
|
145587
146807
|
}),
|
|
145588
146808
|
Placeholder.configure({
|
|
145589
|
-
placeholder: ({ node }) => {
|
|
146809
|
+
placeholder: ({ node, editor: placeholderEditor }) => {
|
|
146810
|
+
if (emptyStatePlaceholder && placeholderEditor.isEmpty) {
|
|
146811
|
+
return "";
|
|
146812
|
+
}
|
|
145590
146813
|
if (node.type.name === "heading") {
|
|
145591
146814
|
const level = node.attrs["level"];
|
|
145592
146815
|
return `Heading ${level}`;
|
|
145593
146816
|
}
|
|
145594
146817
|
if (node.type.name === "paragraph") {
|
|
145595
|
-
|
|
146818
|
+
const focusPlaceholder = "Type here or '/' to insert variables, agents, tools, memory & more";
|
|
146819
|
+
return placeholderEditor.isEmpty ? placeholder : focusPlaceholder;
|
|
145596
146820
|
}
|
|
145597
146821
|
return "";
|
|
145598
146822
|
},
|
|
@@ -145662,7 +146886,7 @@ ${code2}
|
|
|
145662
146886
|
);
|
|
145663
146887
|
}
|
|
145664
146888
|
return exts;
|
|
145665
|
-
}, [mergedFeatures, placeholder, defaultCategories, handleSlashCommandSelect, mergedSlashConfig.highlightMentions]);
|
|
146889
|
+
}, [mergedFeatures, placeholder, emptyStatePlaceholder, defaultCategories, handleSlashCommandSelect, mergedSlashConfig.highlightMentions]);
|
|
145666
146890
|
const editorRef = React.useRef(null);
|
|
145667
146891
|
const editor = useEditor({
|
|
145668
146892
|
extensions,
|
|
@@ -145696,12 +146920,24 @@ ${code2}
|
|
|
145696
146920
|
editorRef.current = editor;
|
|
145697
146921
|
}, [editor]);
|
|
145698
146922
|
const editorContent = editor ? editorJsonToMarkdown(editor.getJSON()) : "";
|
|
146923
|
+
const handleAIContentApplied = React.useCallback((markdown) => {
|
|
146924
|
+
lastEmittedMarkdownRef.current = markdown;
|
|
146925
|
+
if (onMarkdownChange) {
|
|
146926
|
+
onMarkdownChange(markdown);
|
|
146927
|
+
}
|
|
146928
|
+
if (onChange) {
|
|
146929
|
+
const json = markdownToEditorJson(markdown);
|
|
146930
|
+
const doc2 = editorJsonToDocument(json);
|
|
146931
|
+
onChange(doc2, markdown);
|
|
146932
|
+
}
|
|
146933
|
+
}, [onMarkdownChange, onChange]);
|
|
145699
146934
|
const { state: aiSessionState, actions: aiSessionActions, isOpen: aiPanelOpen } = useAIRefinementSession({
|
|
145700
146935
|
editor,
|
|
145701
146936
|
onRefine: onAIRefine,
|
|
145702
146937
|
editorContent,
|
|
145703
146938
|
promptType: props.promptType,
|
|
145704
|
-
agentContext: props.agentContext
|
|
146939
|
+
agentContext: props.agentContext,
|
|
146940
|
+
onContentApplied: handleAIContentApplied
|
|
145705
146941
|
});
|
|
145706
146942
|
const openAIRefine = React.useCallback(
|
|
145707
146943
|
(_type = "selection") => {
|
|
@@ -145728,6 +146964,22 @@ ${code2}
|
|
|
145728
146964
|
// autoGenerate
|
|
145729
146965
|
);
|
|
145730
146966
|
}, [aiSessionActions]);
|
|
146967
|
+
const handleDesignWithAI = React.useCallback(() => {
|
|
146968
|
+
aiSessionActions.openPanel(
|
|
146969
|
+
"generate",
|
|
146970
|
+
"",
|
|
146971
|
+
// Empty text since we're generating from scratch
|
|
146972
|
+
void 0,
|
|
146973
|
+
// No selection range
|
|
146974
|
+
void 0,
|
|
146975
|
+
// No custom prompt - AI will use context
|
|
146976
|
+
true
|
|
146977
|
+
// autoGenerate - start generation immediately
|
|
146978
|
+
);
|
|
146979
|
+
if (onDesignWithAI) {
|
|
146980
|
+
onDesignWithAI();
|
|
146981
|
+
}
|
|
146982
|
+
}, [aiSessionActions, onDesignWithAI]);
|
|
145731
146983
|
const handleCloseAIPanel = React.useCallback(() => {
|
|
145732
146984
|
if (editorRef.current) {
|
|
145733
146985
|
editorRef.current.setEditable(!readOnly);
|
|
@@ -145762,11 +147014,27 @@ ${code2}
|
|
|
145762
147014
|
from
|
|
145763
147015
|
);
|
|
145764
147016
|
if (textAfterTrigger.includes("}}")) {
|
|
147017
|
+
const pathRaw = textAfterTrigger.split("}}")[0].trim();
|
|
147018
|
+
if (pathRaw) {
|
|
147019
|
+
const varType = inferVariableType(pathRaw);
|
|
147020
|
+
const cleanPath = removeTypePrefix(pathRaw);
|
|
147021
|
+
const displayName = cleanPath.split(".").pop() || cleanPath;
|
|
147022
|
+
editor.chain().focus().deleteRange({ from: triggerPos, to: from }).insertContent({
|
|
147023
|
+
type: "variableChip",
|
|
147024
|
+
attrs: {
|
|
147025
|
+
variableType: varType,
|
|
147026
|
+
path: cleanPath,
|
|
147027
|
+
displayName
|
|
147028
|
+
}
|
|
147029
|
+
}).insertContent(" ").run();
|
|
147030
|
+
}
|
|
145765
147031
|
setVariableMenuOpen(false);
|
|
145766
147032
|
variableTriggerPosRef.current = null;
|
|
145767
147033
|
return;
|
|
145768
147034
|
}
|
|
145769
147035
|
setVariableMenuQuery(textAfterTrigger);
|
|
147036
|
+
const coords = editor.view.coordsAtPos(from);
|
|
147037
|
+
setVariableMenuPosition({ top: coords.bottom + 8, left: coords.left });
|
|
145770
147038
|
};
|
|
145771
147039
|
const editorElement = editor.view.dom;
|
|
145772
147040
|
editorElement.addEventListener("keydown", handleKeyDown2);
|
|
@@ -145776,12 +147044,36 @@ ${code2}
|
|
|
145776
147044
|
editorElement.removeEventListener("input", handleInput);
|
|
145777
147045
|
};
|
|
145778
147046
|
}, [editor, mergedFeatures.variableChips, variableMenuOpen]);
|
|
147047
|
+
React.useEffect(() => {
|
|
147048
|
+
variableMenuOpenRef.current = variableMenuOpen;
|
|
147049
|
+
}, [variableMenuOpen]);
|
|
147050
|
+
React.useEffect(() => {
|
|
147051
|
+
if (!editor || !mergedFeatures.variableChips) return;
|
|
147052
|
+
const detectVariableContext = () => {
|
|
147053
|
+
if (variableMenuOpenRef.current) return;
|
|
147054
|
+
if (!hasVariableSuggestionsRef.current) return;
|
|
147055
|
+
const { from } = editor.state.selection;
|
|
147056
|
+
const context = getVariableContextAtPosition(editor, from);
|
|
147057
|
+
if (context) {
|
|
147058
|
+
variableTriggerPosRef.current = context.triggerFrom;
|
|
147059
|
+
setVariableMenuQuery(context.query);
|
|
147060
|
+
const coords = editor.view.coordsAtPos(from);
|
|
147061
|
+
setVariableMenuPosition({ top: coords.bottom + 8, left: coords.left });
|
|
147062
|
+
setVariableMenuOpen(true);
|
|
147063
|
+
}
|
|
147064
|
+
};
|
|
147065
|
+
editor.on("focus", detectVariableContext);
|
|
147066
|
+
editor.on("selectionUpdate", detectVariableContext);
|
|
147067
|
+
return () => {
|
|
147068
|
+
editor.off("focus", detectVariableContext);
|
|
147069
|
+
editor.off("selectionUpdate", detectVariableContext);
|
|
147070
|
+
};
|
|
147071
|
+
}, [editor, mergedFeatures.variableChips]);
|
|
145779
147072
|
React.useEffect(() => {
|
|
145780
147073
|
if (!variableMenuOpen) return;
|
|
145781
147074
|
const handleKeyDown2 = (event) => {
|
|
145782
147075
|
if (event.key === "Escape") {
|
|
145783
147076
|
setVariableMenuOpen(false);
|
|
145784
|
-
setEditingVariableChip(null);
|
|
145785
147077
|
variableTriggerPosRef.current = null;
|
|
145786
147078
|
editor == null ? void 0 : editor.chain().focus().run();
|
|
145787
147079
|
}
|
|
@@ -145794,19 +147086,11 @@ ${code2}
|
|
|
145794
147086
|
const handleVariableChipEdit = (event) => {
|
|
145795
147087
|
const customEvent = event;
|
|
145796
147088
|
const { variableType, path, position, nodeSize: nodeSize2 } = customEvent.detail;
|
|
145797
|
-
const
|
|
145798
|
-
|
|
145799
|
-
|
|
145800
|
-
|
|
145801
|
-
|
|
145802
|
-
path
|
|
145803
|
-
});
|
|
145804
|
-
setVariableMenuPosition({
|
|
145805
|
-
top: coords.bottom + 8,
|
|
145806
|
-
left: coords.left
|
|
145807
|
-
});
|
|
145808
|
-
setVariableMenuQuery("");
|
|
145809
|
-
setVariableMenuOpen(true);
|
|
147089
|
+
const innerPath = variableType === "system" || variableType === "custom" ? path : `${variableType}.${path}`;
|
|
147090
|
+
const fullText = `{{${innerPath}}}`;
|
|
147091
|
+
editor.chain().focus().deleteRange({ from: position, to: position + nodeSize2 }).insertContentAt(position, fullText).run();
|
|
147092
|
+
const cursorPos = position + 2 + innerPath.length;
|
|
147093
|
+
editor.chain().focus().setTextSelection(cursorPos).run();
|
|
145810
147094
|
};
|
|
145811
147095
|
const editorElement = editor.view.dom;
|
|
145812
147096
|
editorElement.addEventListener("variable-chip-edit", handleVariableChipEdit);
|
|
@@ -145815,6 +147099,10 @@ ${code2}
|
|
|
145815
147099
|
};
|
|
145816
147100
|
}, [editor]);
|
|
145817
147101
|
React.useEffect(() => {
|
|
147102
|
+
if (skipEditorSyncRef.current) {
|
|
147103
|
+
skipEditorSyncRef.current = false;
|
|
147104
|
+
return;
|
|
147105
|
+
}
|
|
145818
147106
|
if (!editor || isInternalUpdateRef.current) {
|
|
145819
147107
|
isInternalUpdateRef.current = false;
|
|
145820
147108
|
return;
|
|
@@ -145846,6 +147134,10 @@ ${code2}
|
|
|
145846
147134
|
return () => clearTimeout(timer);
|
|
145847
147135
|
}, [rawMarkdown, isRawMode, onMarkdownChange, onChange]);
|
|
145848
147136
|
React.useEffect(() => {
|
|
147137
|
+
if (skipRawSyncRef.current) {
|
|
147138
|
+
skipRawSyncRef.current = false;
|
|
147139
|
+
return;
|
|
147140
|
+
}
|
|
145849
147141
|
if (isRawMode && markdownValue !== void 0 && markdownValue !== lastEmittedMarkdownRef.current) {
|
|
145850
147142
|
setRawMarkdown(markdownValue);
|
|
145851
147143
|
}
|
|
@@ -145986,6 +147278,13 @@ ${code2}
|
|
|
145986
147278
|
editor,
|
|
145987
147279
|
className: "k-md-editor__content w-full h-full"
|
|
145988
147280
|
}
|
|
147281
|
+
),
|
|
147282
|
+
(editor == null ? void 0 : editor.isEmpty) && emptyStatePlaceholder && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
147283
|
+
EmptyStatePlaceholder,
|
|
147284
|
+
{
|
|
147285
|
+
placeholder: emptyStatePlaceholder,
|
|
147286
|
+
example: emptyStateExample
|
|
147287
|
+
}
|
|
145989
147288
|
)
|
|
145990
147289
|
] })
|
|
145991
147290
|
) }),
|
|
@@ -145994,20 +147293,18 @@ ${code2}
|
|
|
145994
147293
|
{
|
|
145995
147294
|
position: variableMenuPosition,
|
|
145996
147295
|
query: variableMenuQuery,
|
|
145997
|
-
onQueryChange:
|
|
147296
|
+
onQueryChange: handleVariableQueryChange,
|
|
145998
147297
|
onSelect: (variable) => insertVariable(variable),
|
|
145999
147298
|
onClose: () => {
|
|
146000
147299
|
setVariableMenuOpen(false);
|
|
146001
147300
|
setVariableMenuQuery("");
|
|
146002
|
-
setEditingVariableChip(null);
|
|
146003
147301
|
variableTriggerPosRef.current = null;
|
|
146004
147302
|
},
|
|
146005
147303
|
envVariables: mergedEnvVariables,
|
|
146006
147304
|
memoryVariables: mergedMemoryVariables,
|
|
146007
147305
|
systemVariables: mergedSystemVariables,
|
|
146008
147306
|
contentVariables: mergedContentVariables,
|
|
146009
|
-
editorControlled:
|
|
146010
|
-
isEditMode: !!editingVariableChip
|
|
147307
|
+
editorControlled: true
|
|
146011
147308
|
}
|
|
146012
147309
|
)
|
|
146013
147310
|
] }),
|
|
@@ -146021,7 +147318,9 @@ ${code2}
|
|
|
146021
147318
|
onAIAction: isAIEnabled ? handleAIToolbarAction : void 0,
|
|
146022
147319
|
theme: theme === "dark" || theme.includes("dark") ? "dark" : "light",
|
|
146023
147320
|
disabled: readOnly,
|
|
146024
|
-
containerRef: editorContainerRef
|
|
147321
|
+
containerRef: editorContainerRef,
|
|
147322
|
+
showDesignWithAI: showDesignWithAI && (editor == null ? void 0 : editor.isEmpty),
|
|
147323
|
+
onDesignWithAI: isAIEnabled ? handleDesignWithAI : onDesignWithAI
|
|
146025
147324
|
}
|
|
146026
147325
|
)
|
|
146027
147326
|
] }),
|
|
@@ -149563,6 +150862,7 @@ export class AnalyticsDashboardComponent implements OnInit, AfterViewInit, OnDes
|
|
|
149563
150862
|
exports2.AIRefineDropdown = AIRefineDropdown;
|
|
149564
150863
|
exports2.AIRefineExtension = AIRefineExtension;
|
|
149565
150864
|
exports2.AIRefinePanel = AIRefinePanel;
|
|
150865
|
+
exports2.AgentDefinitionExample = AgentDefinitionExample;
|
|
149566
150866
|
exports2.AgentListView = AgentListView;
|
|
149567
150867
|
exports2.AnalyticsChart = AnalyticsChart;
|
|
149568
150868
|
exports2.AnalyticsTable = AnalyticsTable;
|
|
@@ -149588,6 +150888,7 @@ export class AnalyticsDashboardComponent implements OnInit, AfterViewInit, OnDes
|
|
|
149588
150888
|
exports2.DetailPage = DetailPage;
|
|
149589
150889
|
exports2.DetailPageService = DetailPageService;
|
|
149590
150890
|
exports2.EmptyState = EmptyState;
|
|
150891
|
+
exports2.EmptyStatePlaceholder = EmptyStatePlaceholder;
|
|
149591
150892
|
exports2.EndpointsConfigService = EndpointsConfigService;
|
|
149592
150893
|
exports2.EnvironmentContext = EnvironmentContext;
|
|
149593
150894
|
exports2.EnvironmentProvider = EnvironmentProvider;
|