@elevasis/ui 1.20.1 → 1.22.0

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.
Files changed (66) hide show
  1. package/dist/charts/index.js +3 -2
  2. package/dist/chunk-3KMDHCAR.js +52 -0
  3. package/dist/{chunk-4SY4EQSK.js → chunk-5266RV46.js} +3 -3
  4. package/dist/{chunk-UMFPUM7Q.js → chunk-7TLPKXC2.js} +12 -12
  5. package/dist/{chunk-OFAXUZPZ.js → chunk-AJPFSMEH.js} +528 -336
  6. package/dist/chunk-AWT255UH.js +255 -0
  7. package/dist/{chunk-EMN755L5.js → chunk-CTF6FS2M.js} +10 -216
  8. package/dist/{chunk-C7AD6N23.js → chunk-DLI3F5IV.js} +364 -364
  9. package/dist/{chunk-AQ5MQDSS.js → chunk-EDAYKRPJ.js} +404 -2
  10. package/dist/{chunk-XOTN3X3Z.js → chunk-FATKFO7X.js} +3 -54
  11. package/dist/{chunk-JZEXFQ6N.js → chunk-HOYZWSNV.js} +91 -80
  12. package/dist/{chunk-AWMZCYKH.js → chunk-IAZT3VO6.js} +158 -82
  13. package/dist/{chunk-ERVB3QJQ.js → chunk-N5SDJP44.js} +1 -1
  14. package/dist/{chunk-3DIU726S.js → chunk-NVSKJG3L.js} +25 -4
  15. package/dist/{chunk-VLTVZXP6.js → chunk-QZS5FOIR.js} +2 -2
  16. package/dist/chunk-ROSMICXG.js +668 -0
  17. package/dist/{chunk-JIABC3AE.js → chunk-WAEKXBP3.js} +516 -266
  18. package/dist/{chunk-COTI2QPO.js → chunk-ZHJGTOXP.js} +4 -3
  19. package/dist/components/chat/index.d.ts +202 -0
  20. package/dist/components/chat/index.js +2 -0
  21. package/dist/components/index.css +0 -3
  22. package/dist/components/index.d.ts +37 -37
  23. package/dist/components/index.js +2652 -2902
  24. package/dist/features/auth/index.css +0 -3
  25. package/dist/features/dashboard/index.css +0 -3
  26. package/dist/features/dashboard/index.js +9 -9
  27. package/dist/features/monitoring/index.css +0 -3
  28. package/dist/features/monitoring/index.js +10 -10
  29. package/dist/features/operations/index.css +0 -3
  30. package/dist/features/operations/index.d.ts +245 -10
  31. package/dist/features/operations/index.js +1115 -170
  32. package/dist/features/settings/index.css +0 -3
  33. package/dist/features/settings/index.js +9 -9
  34. package/dist/hooks/index.css +68 -3
  35. package/dist/hooks/index.d.ts +1165 -4
  36. package/dist/hooks/index.js +5 -6
  37. package/dist/hooks/published.css +68 -3
  38. package/dist/hooks/published.d.ts +1165 -4
  39. package/dist/hooks/published.js +4 -5
  40. package/dist/index.css +68 -3
  41. package/dist/index.d.ts +1166 -5
  42. package/dist/index.js +6 -7
  43. package/dist/layout/index.d.ts +4 -4
  44. package/dist/layout/index.js +3 -4
  45. package/dist/provider/index.css +0 -3
  46. package/dist/provider/index.d.ts +1 -1
  47. package/dist/provider/index.js +3 -4
  48. package/dist/provider/published.d.ts +1 -1
  49. package/dist/theme/index.d.ts +1 -1
  50. package/dist/theme/index.js +3 -3
  51. package/dist/types/index.d.ts +1 -1
  52. package/package.json +7 -2
  53. package/dist/chunk-JFRG2JJE.js +0 -47
  54. package/dist/chunk-R3R367QY.js +0 -14
  55. package/dist/theme/presets/__tests__/getPreset.test.d.ts +0 -2
  56. package/dist/theme/presets/__tests__/getPreset.test.d.ts.map +0 -1
  57. package/dist/theme/presets/__tests__/getPreset.test.js +0 -92
  58. package/dist/theme/presets/cyber-volt.d.ts +0 -12
  59. package/dist/theme/presets/cyber-volt.d.ts.map +0 -1
  60. package/dist/theme/presets/cyber-volt.js +0 -70
  61. package/dist/theme/presets/regal.d.ts +0 -8
  62. package/dist/theme/presets/regal.d.ts.map +0 -1
  63. package/dist/theme/presets/regal.js +0 -69
  64. package/dist/theme/presets/rose-gold.d.ts +0 -12
  65. package/dist/theme/presets/rose-gold.d.ts.map +0 -1
  66. package/dist/theme/presets/rose-gold.js +0 -76
@@ -1,15 +1,17 @@
1
- import { ResourceDefinitionSection, CommandQueueTaskRow, getIcon, ActionModal, CommandViewGraph, WorkflowExecutionLogs, AgentExecutionLogs } from '../../chunk-JIABC3AE.js';
2
- import { SubshellLoader, SubshellSidebarSection, PageContainer } from '../../chunk-JFRG2JJE.js';
3
- import { ResourceHealthPanel } from '../../chunk-4SY4EQSK.js';
1
+ import { ChatHeader, ChatSidebar } from '../../chunk-ROSMICXG.js';
2
+ import { ResourceDefinitionSection, CommandQueueTaskRow, getIcon, ActionModal, CommandViewGraph, WorkflowExecutionLogs, AgentExecutionLogs, ResourceFilter, getExecutionStatusConfig, SessionMemory } from '../../chunk-WAEKXBP3.js';
3
+ import { SubshellLoader, SubshellSidebarSection, PageContainer, CollapsibleSidebarGroup, SidebarListItem } from '../../chunk-AWT255UH.js';
4
+ import { ResourceHealthPanel } from '../../chunk-5266RV46.js';
4
5
  import { ConfirmationModal, CustomModal } from '../../chunk-GBMNCNHX.js';
5
- import { ExecutionStats, UnifiedWorkflowGraph, WorkflowExecutionTimeline, AgentExecutionVisualizer, AgentExecutionTimeline } from '../../chunk-C7AD6N23.js';
6
- import { useCyberColors, CyberDonut } from '../../chunk-ERVB3QJQ.js';
7
- import { PageTitleCaption, TabCountBadge, ResourceCard, ContextViewer, JsonViewer, APIErrorAlert, EmptyState } from '../../chunk-AWMZCYKH.js';
6
+ import { ExecutionStats, UnifiedWorkflowGraph, WorkflowExecutionTimeline, AgentExecutionVisualizer, AgentExecutionTimeline } from '../../chunk-DLI3F5IV.js';
7
+ import { useCyberColors, CyberDonut } from '../../chunk-N5SDJP44.js';
8
+ import { PageTitleCaption, TabCountBadge, ResourceCard, ContextViewer, JsonViewer, APIErrorAlert, EmptyState, CardHeader } from '../../chunk-IAZT3VO6.js';
9
+ import '../../chunk-3KMDHCAR.js';
8
10
  import '../../chunk-NNKKBSJN.js';
9
11
  import { AppShellLoader } from '../../chunk-WWEMNIHW.js';
10
- import '../../chunk-QJ2S46NI.js';
11
- import { useStatusFilter, useResourceSearch, useResourcesDomainFilters, filterByDomainFilters, useCommandViewDomainFilters, showApiErrorNotification } from '../../chunk-XOTN3X3Z.js';
12
- import { usePaginationState, useResources, useRecentExecutionsByResource, useResourceDefinition, isSessionCapable, useDeleteTask, useCommandQueueTotals, useCommandQueue, useSubmitAction, useCommandViewData, useCommandViewStore, useCommandViewStats, useResourceExecutions, useCheckpointTasks, useExecutionPanelState, useExecution } from '../../chunk-AQ5MQDSS.js';
12
+ import { topbarHeight } from '../../chunk-QJ2S46NI.js';
13
+ import { useStatusFilter, useResourceSearch, useResourcesDomainFilters, filterByDomainFilters, useCommandViewDomainFilters } from '../../chunk-FATKFO7X.js';
14
+ import { usePaginationState, useResources, useRecentExecutionsByResource, useResourceDefinition, isSessionCapable, useDeleteTask, useCommandQueueTotals, useCommandQueue, useSubmitAction, useCommandViewData, useCommandViewStore, useCommandViewStats, useCalibrationProjects, useCalibrationProject, useAllCalibrationProjects, useResourceExecutions, useCheckpointTasks, useCalibrationSSE, useCalibrationRunFull, useExecuteRun, useGradeRun, useCalibrationRuns, useExecutionPanelState, useExecution, useDeleteSession, useCreateSession, useSessions, useSessionExecutions, useSession, calibrationKeys, useDeleteProject, useCreateProject } from '../../chunk-EDAYKRPJ.js';
13
15
  import '../../chunk-NJJ3NQ7B.js';
14
16
  import '../../chunk-LXHZYSMQ.js';
15
17
  import '../../chunk-MHW43EOH.js';
@@ -19,11 +21,10 @@ import { ResourceStatusColors } from '../../chunk-ELJIFLCB.js';
19
21
  import '../../chunk-L4XXM55J.js';
20
22
  import '../../chunk-SLVC5OJ2.js';
21
23
  import '../../chunk-RNP5R5I3.js';
22
- import '../../chunk-VLTVZXP6.js';
23
- import '../../chunk-R3R367QY.js';
24
+ import '../../chunk-QZS5FOIR.js';
24
25
  import '../../chunk-SZHARWKU.js';
25
- import '../../chunk-OFAXUZPZ.js';
26
- import '../../chunk-3DIU726S.js';
26
+ import '../../chunk-AJPFSMEH.js';
27
+ import '../../chunk-NVSKJG3L.js';
27
28
  import '../../chunk-R7WLWGPO.js';
28
29
  import '../../chunk-NVOCKXUQ.js';
29
30
  import '../../chunk-V7XHGJQZ.js';
@@ -33,19 +34,19 @@ import '../../chunk-RWQIFKMJ.js';
33
34
  import '../../chunk-ALA56RGZ.js';
34
35
  import { useInitialization } from '../../chunk-TUXTSEAF.js';
35
36
  import { useOrganization } from '../../chunk-DD3CCMCZ.js';
36
- import { useElevasisServices } from '../../chunk-QEPXAWE2.js';
37
+ import '../../chunk-QEPXAWE2.js';
37
38
  import '../../chunk-BRJ3QZ4E.js';
38
39
  import '../../chunk-Q7DJKLEN.js';
39
- import { Stack, Card, Text, Button, Tabs, Group, Pagination, useMantineTheme, Box, Center, Loader, UnstyledButton, TextInput, Divider, Paper, Badge, ActionIcon, Title, SimpleGrid, CopyButton, SegmentedControl, ThemeIcon, Alert, Switch, Space, Collapse, Tooltip, Menu, Modal, Textarea, Table, Progress } from '@mantine/core';
40
- import { IconApps, IconRoute, IconBrain, IconRefresh, IconAdjustmentsHorizontal, IconSearch, IconChevronDown, IconCircleX, IconCircleCheck, IconCircleDashed, IconTrash, IconArrowLeft, IconClock, IconCheck, IconCopy, IconExternalLink, IconPlayerPlay, IconAlertCircle, IconPlus, IconAdjustments, IconSitemap, IconSettings, IconReportAnalytics, IconX, IconCoin, IconChevronRight, IconInfoCircle, IconMessage, IconFlask, IconDotsVertical } from '@tabler/icons-react';
40
+ import { Stack, Card, Text, Button, Tabs, Group, Pagination, useMantineTheme, Box, Center, Loader, UnstyledButton, TextInput, Divider, Paper, Badge, ActionIcon, Title, SimpleGrid, CopyButton, SegmentedControl, ThemeIcon, Alert, Switch, Space, Progress, Timeline, Collapse, ScrollArea, Tooltip, Textarea, Menu, Modal, Table } from '@mantine/core';
41
+ import { IconApps, IconRoute, IconBrain, IconRefresh, IconAdjustmentsHorizontal, IconSearch, IconChevronDown, IconCircleX, IconCircleCheck, IconCircleDashed, IconTrash, IconArrowLeft, IconClock, IconCheck, IconCopy, IconExternalLink, IconPlayerPlay, IconAlertCircle, IconPlus, IconAdjustments, IconSitemap, IconSettings, IconX, IconChartBar, IconReportAnalytics, IconCoin, IconChevronRight, IconFlask, IconInfoCircle, IconMessage, IconAlertTriangle, IconRobot, IconLayoutSidebarRightExpand, IconNote, IconArchive, IconDownload, IconTimeline, IconDotsVertical } from '@tabler/icons-react';
41
42
  import { useState, useEffect, useMemo, useRef, useCallback } from 'react';
42
43
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
43
44
  import { useClipboard } from '@mantine/hooks';
44
45
  import { notifications } from '@mantine/notifications';
45
46
  import { Link, useNavigate } from '@tanstack/react-router';
46
- import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
47
47
  import { useForm } from '@mantine/form';
48
48
  import { formatDistanceToNow } from 'date-fns';
49
+ import { useQueryClient } from '@tanstack/react-query';
49
50
 
50
51
  // ../core/src/platform/utils/debounce.ts
51
52
  function debounce(fn, wait) {
@@ -1447,99 +1448,6 @@ function CommandViewPage({ timeRange }) {
1447
1448
  }
1448
1449
  );
1449
1450
  }
1450
-
1451
- // src/hooks/operations/calibration/queryKeys.ts
1452
- var calibrationKeys = {
1453
- all: ["calibration"],
1454
- // Projects
1455
- projects: (org) => [...calibrationKeys.all, "projects", org],
1456
- projectsByResource: (org, resourceId, resourceType) => [...calibrationKeys.all, "projects", org, resourceId, resourceType],
1457
- project: (org, projectId) => [...calibrationKeys.all, "project", org, projectId],
1458
- // Runs
1459
- runs: (org, projectId) => [...calibrationKeys.all, "runs", org, projectId],
1460
- run: (org, runId) => [...calibrationKeys.all, "run", org, runId],
1461
- runFull: (org, runId) => [...calibrationKeys.all, "run-full", org, runId]
1462
- };
1463
-
1464
- // src/hooks/operations/calibration/useCalibrationProjects.ts
1465
- function useAllCalibrationProjects() {
1466
- const { apiRequest, organizationId, isReady } = useElevasisServices();
1467
- return useQuery({
1468
- queryKey: calibrationKeys.projects(organizationId ?? "none"),
1469
- queryFn: async () => {
1470
- const response = await apiRequest("/calibration/projects");
1471
- return response.projects;
1472
- },
1473
- enabled: isReady && !!organizationId
1474
- });
1475
- }
1476
- function useCalibrationProjects(resourceId, resourceType) {
1477
- const { apiRequest, organizationId, isReady } = useElevasisServices();
1478
- return useQuery({
1479
- queryKey: calibrationKeys.projectsByResource(organizationId ?? "none", resourceId, resourceType),
1480
- queryFn: async () => {
1481
- const response = await apiRequest(
1482
- `/calibration/projects?resourceId=${resourceId}&resourceType=${resourceType}`
1483
- );
1484
- return response.projects;
1485
- },
1486
- enabled: isReady && !!resourceId && !!resourceType && !!organizationId
1487
- });
1488
- }
1489
- function useCalibrationProject(projectId) {
1490
- const { apiRequest, organizationId, isReady } = useElevasisServices();
1491
- return useQuery({
1492
- queryKey: calibrationKeys.project(organizationId ?? "none", projectId),
1493
- queryFn: async () => {
1494
- const response = await apiRequest(`/calibration/projects/${projectId}`);
1495
- return response.project;
1496
- },
1497
- enabled: isReady && !!projectId && !!organizationId
1498
- });
1499
- }
1500
- function useCreateProject() {
1501
- const { apiRequest, organizationId } = useElevasisServices();
1502
- const queryClient = useQueryClient();
1503
- return useMutation({
1504
- mutationFn: async (input) => {
1505
- const response = await apiRequest("/calibration/projects", {
1506
- method: "POST",
1507
- body: JSON.stringify(input)
1508
- });
1509
- return response.project;
1510
- },
1511
- onSuccess: (data) => {
1512
- queryClient.invalidateQueries({
1513
- queryKey: calibrationKeys.projects(organizationId ?? "none")
1514
- });
1515
- queryClient.invalidateQueries({
1516
- queryKey: calibrationKeys.projectsByResource(organizationId ?? "none", data.resourceId, data.resourceType)
1517
- });
1518
- },
1519
- onError: (error) => {
1520
- showApiErrorNotification(error);
1521
- }
1522
- });
1523
- }
1524
- function useDeleteProject() {
1525
- const { apiRequest } = useElevasisServices();
1526
- const queryClient = useQueryClient();
1527
- return useMutation({
1528
- mutationFn: async (id) => {
1529
- await apiRequest(`/calibration/projects/${id}`, {
1530
- method: "DELETE"
1531
- });
1532
- },
1533
- onSuccess: () => {
1534
- queryClient.invalidateQueries({
1535
- queryKey: calibrationKeys.all
1536
- });
1537
- },
1538
- onError: (error) => {
1539
- showApiErrorNotification(error);
1540
- }
1541
- });
1542
- }
1543
1451
  function ProjectCard({ project, onNavigate }) {
1544
1452
  const deleteProject = useDeleteProject();
1545
1453
  const handleClick = () => {
@@ -2071,63 +1979,6 @@ function CommandViewSidebarContent({ timeRange }) {
2071
1979
  }
2072
1980
  );
2073
1981
  }
2074
- function useCalibrationRunFull(runId) {
2075
- const { apiRequest, organizationId, isReady } = useElevasisServices();
2076
- return useQuery({
2077
- queryKey: calibrationKeys.runFull(organizationId ?? "none", runId),
2078
- queryFn: async () => {
2079
- const response = await apiRequest(`/calibration/runs/${runId}/full`);
2080
- return response;
2081
- },
2082
- enabled: isReady && !!runId && !!organizationId
2083
- });
2084
- }
2085
- function useExecuteRun() {
2086
- const { apiRequest, organizationId } = useElevasisServices();
2087
- const queryClient = useQueryClient();
2088
- return useMutation({
2089
- mutationFn: async (runId) => {
2090
- await apiRequest(`/calibration/runs/${runId}/execute`, {
2091
- method: "POST"
2092
- });
2093
- },
2094
- onSuccess: (_, runId) => {
2095
- queryClient.invalidateQueries({
2096
- queryKey: calibrationKeys.run(organizationId ?? "none", runId)
2097
- });
2098
- },
2099
- onError: (error) => {
2100
- showApiErrorNotification(error);
2101
- }
2102
- });
2103
- }
2104
- function useGradeRun() {
2105
- const { apiRequest, organizationId } = useElevasisServices();
2106
- const queryClient = useQueryClient();
2107
- return useMutation({
2108
- mutationFn: async ({
2109
- runId,
2110
- rubric,
2111
- graderModel
2112
- }) => {
2113
- await apiRequest(`/calibration/runs/${runId}/grade`, {
2114
- method: "POST",
2115
- body: JSON.stringify({ rubric, graderModel })
2116
- });
2117
- },
2118
- onSuccess: (_, { runId }) => {
2119
- queryClient.invalidateQueries({
2120
- queryKey: calibrationKeys.run(organizationId ?? "none", runId)
2121
- });
2122
- queryClient.invalidateQueries({
2123
- queryKey: calibrationKeys.runFull(organizationId ?? "none", runId)
2124
- });
2125
- },
2126
- onError: (error) => {
2127
- showApiErrorNotification(error);
2128
- }
2129
- });
2130
- }
2131
1982
  function ComparisonTable({ run, logs, metrics }) {
2132
1983
  if (run.results.length === 0) {
2133
1984
  return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Text, { c: "dimmed", ta: "center", children: "No results yet. Execute the calibration run to see comparisons." }) });
@@ -2320,6 +2171,142 @@ function GradingPanel({ run, rubric }) {
2320
2171
  ] })
2321
2172
  ] });
2322
2173
  }
2174
+ function CalibrationProgress({ runId, manager, apiUrl }) {
2175
+ const { connected, events, summary, isComplete, error } = useCalibrationSSE({
2176
+ runId,
2177
+ manager,
2178
+ apiUrl,
2179
+ enabled: true
2180
+ });
2181
+ const executionStarted = events.filter((e) => e.type === "execution-started" || e.type === "session-started").length;
2182
+ const executionCompleted = events.filter(
2183
+ (e) => e.type === "execution-completed" || e.type === "session-completed"
2184
+ ).length;
2185
+ const executionFailed = events.filter((e) => e.type === "execution-failed").length;
2186
+ const gradingCompleted = events.filter((e) => e.type === "grading-completed").length;
2187
+ const progressPercent = summary ? (summary.completed + summary.failed) / summary.total * 100 : executionStarted > 0 ? executionCompleted / executionStarted * 100 : 0;
2188
+ return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
2189
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
2190
+ connected ? /* @__PURE__ */ jsx(Badge, { color: "green", leftSection: /* @__PURE__ */ jsx(Loader, { size: 10 }), children: "Live" }) : /* @__PURE__ */ jsx(Badge, { color: "gray", children: "Connecting..." }),
2191
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: isComplete ? "Calibration complete" : "Calibration in progress..." })
2192
+ ] }),
2193
+ /* @__PURE__ */ jsxs("div", { children: [
2194
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: "xs", children: [
2195
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: "Progress" }),
2196
+ /* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", children: [
2197
+ executionCompleted,
2198
+ "/",
2199
+ executionStarted || "?",
2200
+ " executions"
2201
+ ] })
2202
+ ] }),
2203
+ /* @__PURE__ */ jsx(
2204
+ Progress,
2205
+ {
2206
+ value: progressPercent,
2207
+ color: error ? "red" : isComplete ? "green" : void 0,
2208
+ animated: !isComplete
2209
+ }
2210
+ )
2211
+ ] }),
2212
+ /* @__PURE__ */ jsxs(Group, { gap: "xl", children: [
2213
+ /* @__PURE__ */ jsxs("div", { children: [
2214
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Completed" }),
2215
+ /* @__PURE__ */ jsx(Text, { size: "lg", fw: 500, c: "green", children: executionCompleted })
2216
+ ] }),
2217
+ /* @__PURE__ */ jsxs("div", { children: [
2218
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Failed" }),
2219
+ /* @__PURE__ */ jsx(Text, { size: "lg", fw: 500, c: "red", children: executionFailed })
2220
+ ] }),
2221
+ /* @__PURE__ */ jsxs("div", { children: [
2222
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Graded" }),
2223
+ /* @__PURE__ */ jsx(Text, { size: "lg", fw: 500, children: gradingCompleted })
2224
+ ] })
2225
+ ] }),
2226
+ /* @__PURE__ */ jsxs("div", { children: [
2227
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, mb: "xs", children: "Recent Activity" }),
2228
+ /* @__PURE__ */ jsx(Timeline, { active: events.length, bulletSize: 20, lineWidth: 2, children: events.slice(-5).map((event, index) => /* @__PURE__ */ jsx(Timeline.Item, { bullet: getEventBullet(event), title: getEventTitle(event), children: /* @__PURE__ */ jsx(Text, { c: "dimmed", size: "xs", children: getEventDescription(event) }) }, index)) })
2229
+ ] }),
2230
+ error && /* @__PURE__ */ jsxs(Text, { c: "red", size: "sm", children: [
2231
+ "Error: ",
2232
+ error
2233
+ ] })
2234
+ ] }) });
2235
+ }
2236
+ function getEventBullet(event) {
2237
+ const iconSize = 12;
2238
+ switch (event.type) {
2239
+ case "execution-started":
2240
+ case "session-started":
2241
+ case "turn-started":
2242
+ return /* @__PURE__ */ jsx(ThemeIcon, { size: 20, radius: "xl", children: /* @__PURE__ */ jsx(IconPlayerPlay, { size: iconSize }) });
2243
+ case "execution-completed":
2244
+ case "session-completed":
2245
+ case "turn-completed":
2246
+ return /* @__PURE__ */ jsx(ThemeIcon, { size: 20, color: "green", radius: "xl", children: /* @__PURE__ */ jsx(IconCheck, { size: iconSize }) });
2247
+ case "execution-failed":
2248
+ return /* @__PURE__ */ jsx(ThemeIcon, { size: 20, color: "red", radius: "xl", children: /* @__PURE__ */ jsx(IconX, { size: iconSize }) });
2249
+ case "grading-started":
2250
+ case "grading-completed":
2251
+ return /* @__PURE__ */ jsx(ThemeIcon, { size: 20, color: "violet", radius: "xl", children: /* @__PURE__ */ jsx(IconChartBar, { size: iconSize }) });
2252
+ case "grading-failed":
2253
+ return /* @__PURE__ */ jsx(ThemeIcon, { size: 20, color: "red", radius: "xl", children: /* @__PURE__ */ jsx(IconX, { size: iconSize }) });
2254
+ default:
2255
+ return /* @__PURE__ */ jsx(ThemeIcon, { size: 20, color: "gray", radius: "xl", children: /* @__PURE__ */ jsx(IconClock, { size: iconSize }) });
2256
+ }
2257
+ }
2258
+ function getEventTitle(event) {
2259
+ switch (event.type) {
2260
+ case "connected":
2261
+ return "Connected";
2262
+ case "execution-started":
2263
+ return `Started: ${event.variantName}`;
2264
+ case "execution-completed":
2265
+ return `Completed: ${event.variantName}`;
2266
+ case "execution-failed":
2267
+ return `Failed: ${event.variantName}`;
2268
+ case "session-started":
2269
+ return `Session started: ${event.variantName}`;
2270
+ case "session-completed":
2271
+ return `Session completed: ${event.variantName}`;
2272
+ case "turn-started":
2273
+ return `Turn ${event.turnNumber}: ${event.variantName}`;
2274
+ case "turn-completed":
2275
+ return `Turn ${event.turnNumber} done: ${event.variantName}`;
2276
+ case "grading-started":
2277
+ return `Grading: ${event.variantName}`;
2278
+ case "grading-completed":
2279
+ return `Graded: ${event.variantName} (${(event.score * 100).toFixed(0)}%)`;
2280
+ case "grading-failed":
2281
+ return `Grading failed: ${event.variantName}`;
2282
+ case "calibration-completed":
2283
+ return "Calibration complete";
2284
+ case "calibration-failed":
2285
+ return "Calibration failed";
2286
+ default:
2287
+ return "Unknown event";
2288
+ }
2289
+ }
2290
+ function getEventDescription(event) {
2291
+ switch (event.type) {
2292
+ case "execution-started":
2293
+ return `Input #${(event.inputIndex ?? 0) + 1}`;
2294
+ case "execution-completed":
2295
+ return `Input #${(event.inputIndex ?? 0) + 1}`;
2296
+ case "execution-failed":
2297
+ return event.error;
2298
+ case "session-completed":
2299
+ return `${event.turnCount} turns`;
2300
+ case "grading-failed":
2301
+ return event.error;
2302
+ case "calibration-completed":
2303
+ return `${event.summary.completed}/${event.summary.total} succeeded`;
2304
+ case "calibration-failed":
2305
+ return event.error;
2306
+ default:
2307
+ return "";
2308
+ }
2309
+ }
2323
2310
  var STATUS_COLORS = {
2324
2311
  pending: "gray",
2325
2312
  running: "blue",
@@ -2331,7 +2318,8 @@ function CalibrationRunDetailPage({
2331
2318
  runId,
2332
2319
  onNavigateToProject,
2333
2320
  renderSessionComparison,
2334
- renderProgressPanel
2321
+ manager,
2322
+ apiUrl
2335
2323
  }) {
2336
2324
  const { organizationReady } = useInitialization();
2337
2325
  const { data: fullData, isLoading, error, refetch } = useCalibrationRunFull(runId);
@@ -2457,7 +2445,7 @@ function CalibrationRunDetailPage({
2457
2445
  ] }, index)) }) })
2458
2446
  ] })
2459
2447
  ] }),
2460
- run.status === "running" && renderProgressPanel?.({ runId }),
2448
+ run.status === "running" && /* @__PURE__ */ jsx(CalibrationProgress, { runId, manager, apiUrl }),
2461
2449
  /* @__PURE__ */ jsxs(Tabs, { defaultValue: "comparison", children: [
2462
2450
  /* @__PURE__ */ jsxs(Tabs.List, { children: [
2463
2451
  /* @__PURE__ */ jsx(Tabs.Tab, { value: "comparison", children: "Results" }),
@@ -2468,6 +2456,100 @@ function CalibrationRunDetailPage({
2468
2456
  ] })
2469
2457
  ] });
2470
2458
  }
2459
+ function CalibrationSidebar({
2460
+ currentProjectId,
2461
+ currentRunId,
2462
+ currentPath,
2463
+ onProjectClick,
2464
+ onRunClick
2465
+ }) {
2466
+ const theme = useMantineTheme();
2467
+ const queryClient = useQueryClient();
2468
+ const { organizationReady } = useInitialization();
2469
+ const { data: projects, isLoading: isProjectsLoading } = useAllCalibrationProjects();
2470
+ const [expandedProjects, setExpandedProjects] = useState(() => {
2471
+ if (currentProjectId) {
2472
+ return { [currentProjectId]: true };
2473
+ }
2474
+ return {};
2475
+ });
2476
+ const toggleProject = (projectId) => {
2477
+ setExpandedProjects((prev) => ({
2478
+ ...prev,
2479
+ [projectId]: !prev[projectId]
2480
+ }));
2481
+ };
2482
+ const handleRefresh = () => {
2483
+ queryClient.invalidateQueries({ queryKey: [...calibrationKeys.all, "projects"] });
2484
+ };
2485
+ const hasData = projects && projects.length > 0;
2486
+ const isInitialLoading = !organizationReady || isProjectsLoading && !hasData;
2487
+ return /* @__PURE__ */ jsxs(
2488
+ Box,
2489
+ {
2490
+ style: {
2491
+ flex: 1,
2492
+ minHeight: 0,
2493
+ padding: theme.spacing.sm,
2494
+ display: "flex",
2495
+ flexDirection: "column",
2496
+ overflow: "hidden"
2497
+ },
2498
+ children: [
2499
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: "md", mt: "-4", pt: "0", style: { flexShrink: 0 }, children: [
2500
+ /* @__PURE__ */ jsx(Text, { size: "xs", fw: 600, c: "dimmed", tt: "uppercase", children: "Projects" }),
2501
+ /* @__PURE__ */ jsx(UnstyledButton, { title: "Refresh projects", onClick: handleRefresh, children: /* @__PURE__ */ jsx(IconRefresh, { size: 14, style: { opacity: 0.6 } }) })
2502
+ ] }),
2503
+ /* @__PURE__ */ jsx(ScrollArea, { style: { flex: 1, minHeight: 0 }, scrollbarSize: 8, children: isInitialLoading ? /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) }) : projects && projects.length > 0 ? /* @__PURE__ */ jsx(Stack, { gap: "xs", children: projects.map((project) => /* @__PURE__ */ jsx(
2504
+ ProjectGroup,
2505
+ {
2506
+ project,
2507
+ isExpanded: expandedProjects[project.id] || false,
2508
+ currentPath,
2509
+ currentRunId,
2510
+ onToggle: () => toggleProject(project.id),
2511
+ onProjectClick,
2512
+ onRunClick
2513
+ },
2514
+ project.id
2515
+ )) }) : /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { padding: "6px 8px" }, children: "No projects yet" }) })
2516
+ ]
2517
+ }
2518
+ );
2519
+ }
2520
+ function ProjectGroup({
2521
+ project,
2522
+ isExpanded,
2523
+ currentPath,
2524
+ currentRunId,
2525
+ onToggle,
2526
+ onProjectClick,
2527
+ onRunClick
2528
+ }) {
2529
+ const { data: runs, isLoading: isRunsLoading } = useCalibrationRuns(isExpanded ? project.id : "");
2530
+ const isProjectActive = currentPath.includes(`/project/${project.id}`);
2531
+ const hasActiveRun = runs?.some((run) => run.id === currentRunId) || false;
2532
+ const isActive = isProjectActive || hasActiveRun;
2533
+ return /* @__PURE__ */ jsx(
2534
+ CollapsibleSidebarGroup,
2535
+ {
2536
+ icon: IconFlask,
2537
+ label: project.name,
2538
+ isExpanded,
2539
+ onToggle,
2540
+ isActive,
2541
+ onLabelClick: () => onProjectClick(project.id),
2542
+ isEmpty: !runs || runs.length === 0,
2543
+ emptyMessage: "No runs yet",
2544
+ isLoading: isRunsLoading,
2545
+ loadingComponent: /* @__PURE__ */ jsx(Center, { p: "xs", children: /* @__PURE__ */ jsx(Loader, { size: "xs" }) }),
2546
+ children: runs?.map((run) => /* @__PURE__ */ jsx(RunItem, { run, isActive: currentRunId === run.id, onRunClick }, run.id))
2547
+ }
2548
+ );
2549
+ }
2550
+ function RunItem({ run, isActive, onRunClick }) {
2551
+ return /* @__PURE__ */ jsx(SidebarListItem, { icon: IconPlayerPlay, label: run.name, isActive, onClick: () => onRunClick(run.id) });
2552
+ }
2471
2553
  function WorkflowExecutionPanel({
2472
2554
  resourceId,
2473
2555
  resourceDefinition,
@@ -2642,5 +2724,868 @@ function ExecutionPanel({
2642
2724
  return isWorkflowDefinition(resourceDefinition) ? /* @__PURE__ */ jsx(WorkflowExecutionPanel, { ...diProps, resourceDefinition }) : /* @__PURE__ */ jsx(ResourceDefinitionError, { resourceId, resourceType, resourceName });
2643
2725
  }
2644
2726
  }
2727
+ function SessionListItem({ session, onClick, isSelected = false, onDeleted }) {
2728
+ const deleteSession = useDeleteSession();
2729
+ const [isDeleting, setIsDeleting] = useState(false);
2730
+ const [showConfirmation, setShowConfirmation] = useState(false);
2731
+ const handleClick = () => {
2732
+ onClick(session.sessionId);
2733
+ };
2734
+ const handleDeleteClick = (e) => {
2735
+ e.stopPropagation();
2736
+ setShowConfirmation(true);
2737
+ };
2738
+ const handleConfirmDelete = async () => {
2739
+ if (isDeleting) return;
2740
+ setIsDeleting(true);
2741
+ try {
2742
+ await deleteSession.mutateAsync(session.sessionId);
2743
+ setShowConfirmation(false);
2744
+ onDeleted?.(session.sessionId);
2745
+ } catch (error) {
2746
+ console.error("Failed to delete session:", error);
2747
+ } finally {
2748
+ setIsDeleting(false);
2749
+ }
2750
+ };
2751
+ const formatLastActivity = (date) => {
2752
+ try {
2753
+ return formatRelativeTime(date);
2754
+ } catch {
2755
+ return "unknown";
2756
+ }
2757
+ };
2758
+ const titleColor = isSelected ? "var(--color-primary)" : "var(--color-text)";
2759
+ const descriptionColor = isSelected ? "var(--color-text)" : "var(--color-text-subtle)";
2760
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2761
+ /* @__PURE__ */ jsx(
2762
+ Card,
2763
+ {
2764
+ p: "xs",
2765
+ withBorder: isSelected,
2766
+ style: {
2767
+ cursor: "pointer",
2768
+ backgroundColor: isSelected ? "color-mix(in srgb, var(--color-primary) 10%, transparent)" : "transparent",
2769
+ border: "none",
2770
+ boxShadow: "none",
2771
+ transition: "all var(--duration-fast) var(--easing)",
2772
+ opacity: isDeleting ? 0.5 : 1
2773
+ },
2774
+ onClick: handleClick,
2775
+ children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
2776
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", children: [
2777
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
2778
+ /* @__PURE__ */ jsx(IconMessage, { color: titleColor, size: 14 }),
2779
+ /* @__PURE__ */ jsxs(Text, { size: "xs", fw: 500, c: titleColor, children: [
2780
+ session.turnCount,
2781
+ " turns"
2782
+ ] })
2783
+ ] }),
2784
+ /* @__PURE__ */ jsx(
2785
+ ActionIcon,
2786
+ {
2787
+ size: "sm",
2788
+ variant: "subtle",
2789
+ color: "red",
2790
+ onClick: handleDeleteClick,
2791
+ loading: isDeleting,
2792
+ disabled: isDeleting,
2793
+ children: /* @__PURE__ */ jsx(IconTrash, { size: 16 })
2794
+ }
2795
+ )
2796
+ ] }),
2797
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: descriptionColor, children: formatLastActivity(session.updatedAt) })
2798
+ ] })
2799
+ }
2800
+ ),
2801
+ /* @__PURE__ */ jsx(
2802
+ ConfirmationModal,
2803
+ {
2804
+ opened: showConfirmation,
2805
+ onClose: () => setShowConfirmation(false),
2806
+ icon: /* @__PURE__ */ jsx(IconAlertTriangle, {}),
2807
+ title: "Delete Session",
2808
+ text: "Are you sure you want to delete this session? This action cannot be undone.",
2809
+ buttonText: "Delete",
2810
+ buttonColor: "red",
2811
+ confirmationHandler: handleConfirmDelete,
2812
+ loading: isDeleting
2813
+ }
2814
+ )
2815
+ ] });
2816
+ }
2817
+ function SessionsPage({
2818
+ isReady,
2819
+ agentParam,
2820
+ buildSessionDetailUrl,
2821
+ buildSessionListUrl,
2822
+ onNavigate
2823
+ }) {
2824
+ const { data: resourcesData, isLoading: isResourcesLoading } = useResources();
2825
+ const createSession = useCreateSession();
2826
+ const [statusFilter, setStatusFilter] = useState("all");
2827
+ const allAgents = (resourcesData?.agents || []).filter((agent) => agent.sessionCapable === true);
2828
+ const filteredAgents = statusFilter === "all" ? allAgents : allAgents.filter((agent) => agent.status === statusFilter);
2829
+ const selectedAgent = agentParam ? allAgents.find((a) => a.resourceId === agentParam) : void 0;
2830
+ const { data: sessionsData } = useSessions({
2831
+ resourceId: agentParam
2832
+ });
2833
+ const agentSessions = Array.isArray(sessionsData) ? sessionsData : [];
2834
+ const handleCreateSession = async () => {
2835
+ if (!selectedAgent) return;
2836
+ try {
2837
+ const result = await createSession.mutateAsync(selectedAgent.resourceId);
2838
+ onNavigate(buildSessionDetailUrl(result.sessionId));
2839
+ } catch (error) {
2840
+ console.error("Failed to create session:", error);
2841
+ }
2842
+ };
2843
+ const hasResourcesData = allAgents.length > 0;
2844
+ if (!isReady || isResourcesLoading && !hasResourcesData) return /* @__PURE__ */ jsx(SubshellLoader, {});
2845
+ return /* @__PURE__ */ jsxs(Stack, { style: { flex: 1 }, children: [
2846
+ /* @__PURE__ */ jsx(
2847
+ PageTitleCaption,
2848
+ {
2849
+ title: "Sessions",
2850
+ caption: "Create and manage multi-turn agent conversations",
2851
+ rightSection: !selectedAgent ? /* @__PURE__ */ jsx(ResourceFilter, { value: statusFilter, onChange: setStatusFilter }) : void 0
2852
+ }
2853
+ ),
2854
+ selectedAgent ? /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { children: [
2855
+ /* @__PURE__ */ jsx(
2856
+ CardHeader,
2857
+ {
2858
+ icon: /* @__PURE__ */ jsx(IconRobot, { size: 18 }),
2859
+ title: selectedAgent.name,
2860
+ subtitle: selectedAgent.description || "Simplest possible agent using GPT-5-mini",
2861
+ rightSection: /* @__PURE__ */ jsx(
2862
+ Button,
2863
+ {
2864
+ leftSection: /* @__PURE__ */ jsx(IconPlus, { size: 16 }),
2865
+ onClick: handleCreateSession,
2866
+ loading: createSession.isPending,
2867
+ children: "New Session"
2868
+ }
2869
+ )
2870
+ }
2871
+ ),
2872
+ agentSessions.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
2873
+ /* @__PURE__ */ jsx(Divider, {}),
2874
+ /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
2875
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Existing Sessions" }),
2876
+ agentSessions.map((session) => /* @__PURE__ */ jsx(
2877
+ SessionListItem,
2878
+ {
2879
+ session,
2880
+ onClick: (sessionId) => onNavigate(buildSessionDetailUrl(sessionId))
2881
+ },
2882
+ session.sessionId
2883
+ ))
2884
+ ] })
2885
+ ] })
2886
+ ] }) }) : /* @__PURE__ */ jsx(Stack, { children: filteredAgents.length > 0 ? /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, sm: 2, lg: 3 }, spacing: "sm", children: filteredAgents.map((agent) => /* @__PURE__ */ jsx(
2887
+ ResourceCard,
2888
+ {
2889
+ resource: { ...agent, type: "agent" },
2890
+ onClick: () => {
2891
+ onNavigate(buildSessionListUrl(agent.resourceId));
2892
+ }
2893
+ },
2894
+ agent.resourceId
2895
+ )) }) : /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { align: "center", py: "xl", children: [
2896
+ /* @__PURE__ */ jsx(Text, { c: "dimmed", children: "No agents available" }),
2897
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Register agents to start conversation sessions" })
2898
+ ] }) }) })
2899
+ ] });
2900
+ }
2901
+ function SessionHeader({
2902
+ session: _session,
2903
+ connectionState,
2904
+ onToggleSidebar,
2905
+ isSidebarOpen,
2906
+ tokenUsage
2907
+ }) {
2908
+ const mockTokenUsage = tokenUsage || { used: 45e3, total: 128e3 };
2909
+ return /* @__PURE__ */ jsx(
2910
+ ChatHeader,
2911
+ {
2912
+ title: "Session Chat",
2913
+ status: {
2914
+ label: connectionState.isConnected ? "Connected" : "Disconnected",
2915
+ color: connectionState.isConnected ? "green" : "gray"
2916
+ },
2917
+ contextUsage: mockTokenUsage,
2918
+ sidebarIcon: /* @__PURE__ */ jsx(IconLayoutSidebarRightExpand, { size: 20 }),
2919
+ onToggleSidebar,
2920
+ isSidebarOpen,
2921
+ sidebarTooltip: isSidebarOpen ? "Close details" : "Show details"
2922
+ }
2923
+ );
2924
+ }
2925
+ function SessionChatInterface({
2926
+ sessionId,
2927
+ onConnectionStateChange,
2928
+ renderConversationView
2929
+ }) {
2930
+ return /* @__PURE__ */ jsx(Fragment, { children: renderConversationView({
2931
+ sessionId,
2932
+ onConnectionStateChange,
2933
+ emptyStateText: "No messages yet",
2934
+ emptyStateSubtext: "Send a message to start the conversation",
2935
+ placeholder: "Message the agent..."
2936
+ }) });
2937
+ }
2938
+ function SessionDetailsSidebar({
2939
+ session,
2940
+ isOpen,
2941
+ onClose,
2942
+ organizationName,
2943
+ onDeleted
2944
+ }) {
2945
+ const deleteSession = useDeleteSession();
2946
+ const [isDeleting, setIsDeleting] = useState(false);
2947
+ const [showConfirmation, setShowConfirmation] = useState(false);
2948
+ const [copiedResource, setCopiedResource] = useState(false);
2949
+ const [copiedSessionId, setCopiedSessionId] = useState(false);
2950
+ const { data: executionsData } = useSessionExecutions(session.sessionId);
2951
+ const [instructions, setInstructions] = useState(session.metadata?.instructions || "");
2952
+ const [isSavingInstructions, setIsSavingInstructions] = useState(false);
2953
+ const { data: resourcesData } = useResources();
2954
+ const agent = resourcesData?.agents.find((a) => a.resourceId === session.resourceId);
2955
+ const { data: agentDefinition } = useResourceDefinition(session.resourceId);
2956
+ const agentInfo = {
2957
+ name: agent?.name || session.resourceId,
2958
+ description: agent?.description || "No description available",
2959
+ resourceId: session.resourceId
2960
+ };
2961
+ const metrics = {
2962
+ totalDuration: 0,
2963
+ avgTurnTime: 0,
2964
+ successRate: 0,
2965
+ completedTurns: 0,
2966
+ failedTurns: 0
2967
+ };
2968
+ if (executionsData?.executions) {
2969
+ const executions = executionsData.executions;
2970
+ metrics.totalDuration = executions.reduce((sum, ex) => sum + (ex.duration || 0), 0);
2971
+ metrics.avgTurnTime = executions.length > 0 ? metrics.totalDuration / executions.length : 0;
2972
+ metrics.completedTurns = executions.filter((ex) => ex.status === "completed" || ex.status === "warning").length;
2973
+ metrics.failedTurns = executions.filter((ex) => ex.status === "failed").length;
2974
+ metrics.successRate = executions.length > 0 ? metrics.completedTurns / executions.length * 100 : 0;
2975
+ }
2976
+ const handleConfirmDelete = async () => {
2977
+ if (isDeleting) return;
2978
+ setIsDeleting(true);
2979
+ try {
2980
+ await deleteSession.mutateAsync(session.sessionId);
2981
+ setShowConfirmation(false);
2982
+ onClose();
2983
+ onDeleted?.();
2984
+ } catch (error) {
2985
+ console.error("Failed to delete session:", error);
2986
+ } finally {
2987
+ setIsDeleting(false);
2988
+ }
2989
+ };
2990
+ const handleArchive = () => {
2991
+ console.log("Archive session:", session.sessionId);
2992
+ };
2993
+ const handleExport = () => {
2994
+ console.log("Export session:", session.sessionId);
2995
+ };
2996
+ const handleSaveInstructions = async () => {
2997
+ setIsSavingInstructions(true);
2998
+ try {
2999
+ console.log("Saving instructions:", instructions);
3000
+ await new Promise((resolve) => setTimeout(resolve, 500));
3001
+ } finally {
3002
+ setIsSavingInstructions(false);
3003
+ }
3004
+ };
3005
+ const handleCopyResource = async () => {
3006
+ const resourcePath = `${organizationName}/${session.resourceId}`;
3007
+ await navigator.clipboard.writeText(resourcePath);
3008
+ setCopiedResource(true);
3009
+ setTimeout(() => setCopiedResource(false), 2e3);
3010
+ };
3011
+ const handleCopySessionId = async () => {
3012
+ await navigator.clipboard.writeText(session.sessionId);
3013
+ setCopiedSessionId(true);
3014
+ setTimeout(() => setCopiedSessionId(false), 2e3);
3015
+ };
3016
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3017
+ /* @__PURE__ */ jsxs(ChatSidebar, { isOpen, title: "Session Details", children: [
3018
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, overflow: "auto" }, children: /* @__PURE__ */ jsxs(Stack, { p: "sm", children: [
3019
+ /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
3020
+ /* @__PURE__ */ jsxs("div", { children: [
3021
+ /* @__PURE__ */ jsxs(Group, { gap: 4, mb: 4, justify: "space-between", children: [
3022
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", children: "Resource (CLI)" }),
3023
+ /* @__PURE__ */ jsx(Tooltip, { label: copiedResource ? "Copied!" : "Copy resource path", position: "right", children: /* @__PURE__ */ jsx(
3024
+ ActionIcon,
3025
+ {
3026
+ variant: "subtle",
3027
+ color: copiedResource ? "green" : "gray",
3028
+ onClick: handleCopyResource,
3029
+ size: "xs",
3030
+ children: copiedResource ? /* @__PURE__ */ jsx(IconCheck, { size: 14 }) : /* @__PURE__ */ jsx(IconCopy, { size: 14 })
3031
+ }
3032
+ ) })
3033
+ ] }),
3034
+ /* @__PURE__ */ jsxs(Text, { size: "sm", ff: "monospace", style: { wordBreak: "break-all" }, children: [
3035
+ organizationName,
3036
+ "/",
3037
+ session.resourceId
3038
+ ] })
3039
+ ] }),
3040
+ /* @__PURE__ */ jsxs("div", { children: [
3041
+ /* @__PURE__ */ jsxs(Group, { gap: 4, mb: 4, justify: "space-between", children: [
3042
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", children: "Session ID" }),
3043
+ /* @__PURE__ */ jsx(Tooltip, { label: copiedSessionId ? "Copied!" : "Copy session ID", position: "right", children: /* @__PURE__ */ jsx(
3044
+ ActionIcon,
3045
+ {
3046
+ variant: "subtle",
3047
+ color: copiedSessionId ? "green" : "gray",
3048
+ onClick: handleCopySessionId,
3049
+ size: "xs",
3050
+ children: copiedSessionId ? /* @__PURE__ */ jsx(IconCheck, { size: 14 }) : /* @__PURE__ */ jsx(IconCopy, { size: 14 })
3051
+ }
3052
+ ) })
3053
+ ] }),
3054
+ /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", style: { wordBreak: "break-all" }, children: session.sessionId })
3055
+ ] })
3056
+ ] }),
3057
+ /* @__PURE__ */ jsx(Divider, {}),
3058
+ /* @__PURE__ */ jsxs("div", { children: [
3059
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", mb: 8, children: "Agent" }),
3060
+ /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
3061
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, children: agentInfo.name }),
3062
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", lineClamp: 3, children: agentInfo.description }),
3063
+ agentDefinition && "modelConfig" in agentDefinition && /* @__PURE__ */ jsxs(Fragment, { children: [
3064
+ /* @__PURE__ */ jsx(Divider, { my: "xs" }),
3065
+ /* @__PURE__ */ jsxs("div", { children: [
3066
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fw: 600, mb: 4, children: "Model Configuration" }),
3067
+ /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
3068
+ agentDefinition.modelConfig.model && /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3069
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Model" }),
3070
+ /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", children: agentDefinition.modelConfig.model })
3071
+ ] }),
3072
+ agentDefinition.modelConfig.temperature !== void 0 && /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3073
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Temperature" }),
3074
+ /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", children: agentDefinition.modelConfig.temperature })
3075
+ ] }),
3076
+ agentDefinition.modelConfig.maxOutputTokens && /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3077
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Max Tokens" }),
3078
+ /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", children: agentDefinition.modelConfig.maxOutputTokens })
3079
+ ] })
3080
+ ] })
3081
+ ] })
3082
+ ] }),
3083
+ agentDefinition && "tools" in agentDefinition && agentDefinition.tools.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
3084
+ /* @__PURE__ */ jsx(Divider, { my: "sm" }),
3085
+ /* @__PURE__ */ jsxs("div", { children: [
3086
+ /* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", fw: 600, mb: 4, children: [
3087
+ "Tools (",
3088
+ agentDefinition.tools.length,
3089
+ ")"
3090
+ ] }),
3091
+ /* @__PURE__ */ jsx(Stack, { gap: 4, children: agentDefinition.tools.map(
3092
+ (tool, index) => {
3093
+ const toolName = typeof tool === "string" ? tool : tool.name;
3094
+ const toolKey = typeof tool === "string" ? tool : `${tool.name}-${index}`;
3095
+ return /* @__PURE__ */ jsxs(Text, { size: "sm", ff: "monospace", c: "dimmed", children: [
3096
+ "\u2022 ",
3097
+ toolName
3098
+ ] }, toolKey);
3099
+ }
3100
+ ) })
3101
+ ] })
3102
+ ] })
3103
+ ] })
3104
+ ] }),
3105
+ /* @__PURE__ */ jsx(Divider, {}),
3106
+ /* @__PURE__ */ jsxs("div", { children: [
3107
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: 8, children: [
3108
+ /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
3109
+ /* @__PURE__ */ jsx(IconNote, { size: 14, color: "var(--color-text-subtle)" }),
3110
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", children: "Session Instructions" })
3111
+ ] }),
3112
+ isSavingInstructions && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", style: { fontStyle: "italic" }, children: "Saving..." })
3113
+ ] }),
3114
+ /* @__PURE__ */ jsx(
3115
+ Textarea,
3116
+ {
3117
+ placeholder: "Add custom instructions to append to the system prompt...",
3118
+ value: instructions,
3119
+ onChange: (e) => setInstructions(e.target.value),
3120
+ onBlur: handleSaveInstructions,
3121
+ autosize: true,
3122
+ minRows: 4,
3123
+ maxRows: 8,
3124
+ size: "sm",
3125
+ styles: {
3126
+ input: {
3127
+ fontSize: "var(--mantine-font-size-sm)"
3128
+ }
3129
+ }
3130
+ }
3131
+ )
3132
+ ] }),
3133
+ /* @__PURE__ */ jsxs("div", { children: [
3134
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", mb: 8, children: "Timestamps" }),
3135
+ /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
3136
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3137
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Created" }),
3138
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: new Date(session.createdAt).toLocaleString() })
3139
+ ] }),
3140
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3141
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Last Updated" }),
3142
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: new Date(session.updatedAt).toLocaleString() })
3143
+ ] }),
3144
+ session.endedAt && /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3145
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Ended" }),
3146
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: new Date(session.endedAt).toLocaleString() })
3147
+ ] })
3148
+ ] })
3149
+ ] }),
3150
+ (() => {
3151
+ const modelConfig = session.metadata?.modelConfig;
3152
+ if (!modelConfig) return null;
3153
+ return /* @__PURE__ */ jsxs("div", { children: [
3154
+ /* @__PURE__ */ jsx(Divider, {}),
3155
+ /* @__PURE__ */ jsxs("div", { children: [
3156
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", mb: 4, children: "Model Configuration" }),
3157
+ /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
3158
+ modelConfig.model && /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3159
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Model" }),
3160
+ /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", children: modelConfig.model })
3161
+ ] }),
3162
+ modelConfig.temperature !== void 0 && /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3163
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Temperature" }),
3164
+ /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", children: modelConfig.temperature })
3165
+ ] }),
3166
+ modelConfig.maxOutputTokens && /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3167
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Max Tokens" }),
3168
+ /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", children: modelConfig.maxOutputTokens })
3169
+ ] })
3170
+ ] })
3171
+ ] })
3172
+ ] });
3173
+ })(),
3174
+ /* @__PURE__ */ jsx(Divider, {}),
3175
+ /* @__PURE__ */ jsxs("div", { children: [
3176
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", mb: 8, children: "Actions" }),
3177
+ /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
3178
+ /* @__PURE__ */ jsxs(
3179
+ Button,
3180
+ {
3181
+ size: "sm",
3182
+ variant: "light",
3183
+ leftSection: /* @__PURE__ */ jsx(IconArchive, { size: 16 }),
3184
+ onClick: handleArchive,
3185
+ fullWidth: true,
3186
+ children: [
3187
+ session.isEnded ? "Reopen" : "End",
3188
+ " Session"
3189
+ ]
3190
+ }
3191
+ ),
3192
+ /* @__PURE__ */ jsx(
3193
+ Button,
3194
+ {
3195
+ size: "sm",
3196
+ variant: "light",
3197
+ leftSection: /* @__PURE__ */ jsx(IconDownload, { size: 16 }),
3198
+ onClick: handleExport,
3199
+ fullWidth: true,
3200
+ children: "Export Session"
3201
+ }
3202
+ )
3203
+ ] })
3204
+ ] })
3205
+ ] }) }),
3206
+ /* @__PURE__ */ jsx("div", { style: { borderTop: "1px solid var(--color-border)", padding: "var(--mantine-spacing-md)" }, children: /* @__PURE__ */ jsx(
3207
+ Button,
3208
+ {
3209
+ fullWidth: true,
3210
+ color: "red",
3211
+ variant: "light",
3212
+ leftSection: /* @__PURE__ */ jsx(IconTrash, { size: 16 }),
3213
+ onClick: () => setShowConfirmation(true),
3214
+ loading: isDeleting,
3215
+ disabled: isDeleting,
3216
+ children: "Delete Session"
3217
+ }
3218
+ ) })
3219
+ ] }),
3220
+ /* @__PURE__ */ jsx(
3221
+ ConfirmationModal,
3222
+ {
3223
+ opened: showConfirmation,
3224
+ onClose: () => setShowConfirmation(false),
3225
+ icon: /* @__PURE__ */ jsx(IconAlertTriangle, {}),
3226
+ title: "Delete Session",
3227
+ text: "Are you sure you want to delete this session? All messages and execution history will be permanently removed. This action cannot be undone.",
3228
+ buttonText: "Delete Session",
3229
+ buttonColor: "red",
3230
+ confirmationHandler: handleConfirmDelete,
3231
+ loading: isDeleting
3232
+ }
3233
+ )
3234
+ ] });
3235
+ }
3236
+ function SessionChatArea({
3237
+ sessionId,
3238
+ session,
3239
+ organizationName,
3240
+ onDeleted,
3241
+ renderConversationView
3242
+ }) {
3243
+ const [isSidebarOpen, setIsSidebarOpen] = useState(false);
3244
+ const [connectionState, setConnectionState] = useState({
3245
+ isConnected: false,
3246
+ isProcessing: false,
3247
+ error: null
3248
+ });
3249
+ return /* @__PURE__ */ jsxs(
3250
+ "div",
3251
+ {
3252
+ style: {
3253
+ position: "relative",
3254
+ display: "flex",
3255
+ flexDirection: "column",
3256
+ gap: "16px",
3257
+ height: `calc(100vh - ${topbarHeight}px)`,
3258
+ flexShrink: 0,
3259
+ overflowX: "hidden"
3260
+ },
3261
+ children: [
3262
+ /* @__PURE__ */ jsxs(
3263
+ "div",
3264
+ {
3265
+ style: {
3266
+ height: "100%",
3267
+ display: "flex",
3268
+ flexDirection: "column",
3269
+ gap: "16px",
3270
+ transition: "margin-right var(--duration-normal) var(--easing)",
3271
+ marginRight: isSidebarOpen ? "320px" : "0",
3272
+ overflow: "hidden",
3273
+ borderRadius: "var(--mantine-radius-md)",
3274
+ position: "relative",
3275
+ padding: 8
3276
+ },
3277
+ children: [
3278
+ /* @__PURE__ */ jsx(
3279
+ SessionHeader,
3280
+ {
3281
+ session,
3282
+ connectionState,
3283
+ onToggleSidebar: () => setIsSidebarOpen(!isSidebarOpen),
3284
+ isSidebarOpen
3285
+ }
3286
+ ),
3287
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, minHeight: 0, overflow: "hidden" }, children: /* @__PURE__ */ jsx(
3288
+ SessionChatInterface,
3289
+ {
3290
+ sessionId,
3291
+ onConnectionStateChange: setConnectionState,
3292
+ renderConversationView
3293
+ }
3294
+ ) })
3295
+ ]
3296
+ }
3297
+ ),
3298
+ /* @__PURE__ */ jsx(
3299
+ SessionDetailsSidebar,
3300
+ {
3301
+ session,
3302
+ isOpen: isSidebarOpen,
3303
+ onClose: () => setIsSidebarOpen(false),
3304
+ organizationName,
3305
+ onDeleted
3306
+ }
3307
+ )
3308
+ ]
3309
+ }
3310
+ );
3311
+ }
3312
+ function SessionExecutionLogs({ sessionId, session, buildExecutionUrl }) {
3313
+ const { data: executions, isLoading } = useSessionExecutions(sessionId);
3314
+ if (isLoading) {
3315
+ return /* @__PURE__ */ jsxs(Stack, { children: [
3316
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
3317
+ /* @__PURE__ */ jsx(IconTimeline, { size: 20 }),
3318
+ /* @__PURE__ */ jsx(Text, { fw: 600, size: "sm", style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Execution Logs" })
3319
+ ] }),
3320
+ /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) })
3321
+ ] });
3322
+ }
3323
+ if (!executions || executions.executions.length === 0) {
3324
+ return /* @__PURE__ */ jsxs(Stack, { children: [
3325
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3326
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
3327
+ /* @__PURE__ */ jsx(IconTimeline, { size: 20 }),
3328
+ /* @__PURE__ */ jsx(Text, { fw: 600, size: "sm", style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Execution Logs" })
3329
+ ] }),
3330
+ /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", children: "0 turns" })
3331
+ ] }),
3332
+ /* @__PURE__ */ jsx(EmptyState, { icon: IconTimeline, title: "No execution logs yet" })
3333
+ ] });
3334
+ }
3335
+ return /* @__PURE__ */ jsxs(Stack, { children: [
3336
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
3337
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
3338
+ /* @__PURE__ */ jsx(IconTimeline, { size: 20 }),
3339
+ /* @__PURE__ */ jsx(Text, { fw: 600, size: "sm", style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Execution Logs" })
3340
+ ] }),
3341
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", variant: "light", children: [
3342
+ executions.executions.length,
3343
+ " ",
3344
+ executions.executions.length === 1 ? "turn" : "turns"
3345
+ ] })
3346
+ ] }),
3347
+ /* @__PURE__ */ jsx(Stack, { children: executions.executions.map((execution) => /* @__PURE__ */ jsx(
3348
+ ExecutionItem,
3349
+ {
3350
+ execution,
3351
+ session,
3352
+ buildExecutionUrl
3353
+ },
3354
+ execution.executionId
3355
+ )) })
3356
+ ] });
3357
+ }
3358
+ function ExecutionItem({ execution, session: _session, buildExecutionUrl }) {
3359
+ const statusConfig = getExecutionStatusConfig(execution.status);
3360
+ const handleClick = () => {
3361
+ const url = buildExecutionUrl(execution.executionId);
3362
+ window.open(url, "_blank", "noopener,noreferrer");
3363
+ };
3364
+ return /* @__PURE__ */ jsx(
3365
+ Paper,
3366
+ {
3367
+ p: "sm",
3368
+ style: {
3369
+ cursor: "pointer",
3370
+ transition: "all var(--duration-fast) var(--easing)",
3371
+ ":hover": {
3372
+ backgroundColor: "var(--mantine-color-gray-0)"
3373
+ }
3374
+ },
3375
+ onClick: handleClick,
3376
+ children: /* @__PURE__ */ jsxs(Group, { justify: "space-between", wrap: "nowrap", children: [
3377
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", children: [
3378
+ /* @__PURE__ */ jsxs(Text, { size: "sm", fw: 500, children: [
3379
+ "Turn ",
3380
+ execution.turnNumber
3381
+ ] }),
3382
+ /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: statusConfig.color, children: statusConfig.label }),
3383
+ execution.duration && /* @__PURE__ */ jsxs(Badge, { size: "xs", variant: "light", children: [
3384
+ (execution.duration / 1e3).toFixed(2),
3385
+ "s"
3386
+ ] })
3387
+ ] }),
3388
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", children: [
3389
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatRelativeTime(execution.startedAt) }),
3390
+ /* @__PURE__ */ jsx(IconExternalLink, { size: 16 })
3391
+ ] })
3392
+ ] })
3393
+ }
3394
+ );
3395
+ }
3396
+ function AgentChatOuterSubshellContainer({ children }) {
3397
+ return /* @__PURE__ */ jsx(
3398
+ "div",
3399
+ {
3400
+ style: {
3401
+ overflow: "auto",
3402
+ minWidth: 0,
3403
+ minHeight: `calc(100vh - ${topbarHeight}px)`,
3404
+ paddingTop: `${topbarHeight}px`
3405
+ },
3406
+ children
3407
+ }
3408
+ );
3409
+ }
3410
+ function SessionChatPage({
3411
+ sessionId,
3412
+ isReady,
3413
+ renderConversationView,
3414
+ buildExecutionUrl,
3415
+ buildSessionListUrl: _buildSessionListUrl,
3416
+ organizationName
3417
+ }) {
3418
+ const { data: session, isLoading: isSessionLoading } = useSession(sessionId);
3419
+ if (!isReady || isSessionLoading) {
3420
+ return /* @__PURE__ */ jsx(SubshellLoader, {});
3421
+ }
3422
+ if (!session) {
3423
+ return /* @__PURE__ */ jsxs(Stack, { style: { flex: 1 }, children: [
3424
+ /* @__PURE__ */ jsx(PageTitleCaption, { title: "Session Not Found", caption: `Session ${sessionId} not found` }),
3425
+ /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Text, { c: "dimmed", children: "This session may have been deleted or does not exist." }) })
3426
+ ] });
3427
+ }
3428
+ return /* @__PURE__ */ jsx(
3429
+ SessionChatPageContent,
3430
+ {
3431
+ sessionId,
3432
+ session,
3433
+ renderConversationView,
3434
+ buildExecutionUrl,
3435
+ organizationName
3436
+ }
3437
+ );
3438
+ }
3439
+ function SessionChatPageContent({
3440
+ sessionId,
3441
+ session,
3442
+ renderConversationView,
3443
+ buildExecutionUrl,
3444
+ organizationName
3445
+ }) {
3446
+ const { data: resourceDefinition } = useResourceDefinition(session.resourceId);
3447
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(AgentChatOuterSubshellContainer, { children: /* @__PURE__ */ jsxs(PageContainer, { children: [
3448
+ /* @__PURE__ */ jsx(
3449
+ SessionChatArea,
3450
+ {
3451
+ sessionId,
3452
+ session,
3453
+ organizationName,
3454
+ renderConversationView
3455
+ }
3456
+ ),
3457
+ /* @__PURE__ */ jsx("div", { style: { padding: "8px", display: "flex", flexDirection: "column", gap: "8px" }, children: /* @__PURE__ */ jsxs(Stack, { style: { flex: 1, height: "100%" }, children: [
3458
+ resourceDefinition && /* @__PURE__ */ jsx(ResourceDefinitionSection, { resourceDefinition }),
3459
+ /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { children: [
3460
+ /* @__PURE__ */ jsx(SessionMemory, { memory: session.memorySnapshot }),
3461
+ /* @__PURE__ */ jsx(SessionExecutionLogs, { sessionId, session, buildExecutionUrl })
3462
+ ] }) })
3463
+ ] }) })
3464
+ ] }) }) });
3465
+ }
3466
+ function AgentSessionGroup({
3467
+ group,
3468
+ onAgentClick,
3469
+ onSessionClick,
3470
+ selectedSessionId,
3471
+ onSessionDeleted
3472
+ }) {
3473
+ const [isExpanded, setIsExpanded] = useState(group.isExpanded);
3474
+ const toggleExpanded = () => {
3475
+ setIsExpanded(!isExpanded);
3476
+ };
3477
+ const handleAgentClick = (e) => {
3478
+ onAgentClick(group.resourceId);
3479
+ e.stopPropagation();
3480
+ };
3481
+ return /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
3482
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", style: { cursor: "pointer", userSelect: "none" }, children: [
3483
+ /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", size: "sm", onClick: toggleExpanded, children: isExpanded ? /* @__PURE__ */ jsx(IconChevronDown, { size: 16 }) : /* @__PURE__ */ jsx(IconChevronRight, { size: 16 }) }),
3484
+ /* @__PURE__ */ jsxs(
3485
+ Group,
3486
+ {
3487
+ gap: "xs",
3488
+ onClick: handleAgentClick,
3489
+ style: {
3490
+ flex: 1,
3491
+ padding: "4px 8px",
3492
+ borderRadius: "var(--mantine-radius-default)",
3493
+ transition: "background-color var(--duration-fast)"
3494
+ },
3495
+ onMouseEnter: (e) => {
3496
+ e.currentTarget.style.backgroundColor = "var(--mantine-color-default-hover)";
3497
+ },
3498
+ onMouseLeave: (e) => {
3499
+ e.currentTarget.style.backgroundColor = "transparent";
3500
+ },
3501
+ children: [
3502
+ /* @__PURE__ */ jsx(IconBrain, { size: 16, color: "var(--color-primary)" }),
3503
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, style: { flex: 1, fontFamily: "var(--elevasis-font-family-subtitle)" }, children: group.agentName }),
3504
+ group.sessions.length > 0 && /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", circle: true, children: group.sessions.length })
3505
+ ]
3506
+ }
3507
+ )
3508
+ ] }),
3509
+ /* @__PURE__ */ jsx(Collapse, { in: isExpanded, children: /* @__PURE__ */ jsx(Stack, { gap: "xs", pl: "xs", children: group.sessions.length > 0 ? group.sessions.map((session) => /* @__PURE__ */ jsx(
3510
+ SessionListItem,
3511
+ {
3512
+ session,
3513
+ onClick: onSessionClick,
3514
+ isSelected: selectedSessionId === session.sessionId,
3515
+ onDeleted: onSessionDeleted
3516
+ },
3517
+ session.sessionId
3518
+ )) : /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fs: "italic", py: "sm", children: "No sessions" }) }) })
3519
+ ] });
3520
+ }
3521
+ function SessionsSidebar({
3522
+ isReady,
3523
+ onAgentClick,
3524
+ buildSessionDetailUrl,
3525
+ sessionId,
3526
+ agentParam
3527
+ }) {
3528
+ const theme = useMantineTheme();
3529
+ const { organizationReady } = useInitialization();
3530
+ const { data: resourcesData, isLoading: isResourcesLoading } = useResources();
3531
+ const agents = resourcesData?.agents || [];
3532
+ const isSessionView = !!sessionId;
3533
+ const { data: currentSession, isLoading: isCurrentSessionLoading } = useSession(sessionId || "");
3534
+ const currentAgentResourceId = currentSession?.resourceId;
3535
+ const { data: sessionsData, isLoading: isSessionsLoading } = useSessions(
3536
+ currentAgentResourceId ? { resourceId: currentAgentResourceId } : void 0,
3537
+ { enabled: !!currentAgentResourceId }
3538
+ );
3539
+ const agentSessions = isSessionView && currentAgentResourceId ? Array.isArray(sessionsData) ? sessionsData : [] : [];
3540
+ const hasResourcesData = agents.length > 0;
3541
+ const hasSessionsData = agentSessions.length > 0;
3542
+ const isInitialLoading = !isReady || !organizationReady || isResourcesLoading && !hasResourcesData || isSessionView && (isCurrentSessionLoading || isSessionsLoading) && !hasSessionsData;
3543
+ return /* @__PURE__ */ jsxs(Box, { style: { flex: 1, minHeight: 0, padding: theme.spacing.sm }, children: [
3544
+ /* @__PURE__ */ jsx(Text, { size: "xs", fw: 600, c: "dimmed", tt: "uppercase", mb: "md", children: isSessionView ? "Sessions" : "Agents" }),
3545
+ /* @__PURE__ */ jsx(ScrollArea, { style: { height: "100%" }, scrollbarSize: 8, children: isInitialLoading ? /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) }) : isSessionView ? agentSessions.length > 0 ? /* @__PURE__ */ jsx(Stack, { gap: "xs", children: agentSessions.map((session) => /* @__PURE__ */ jsx(
3546
+ SessionListItem,
3547
+ {
3548
+ session,
3549
+ onClick: (id) => window.location.assign(buildSessionDetailUrl(id)),
3550
+ isSelected: sessionId === session.sessionId
3551
+ },
3552
+ session.sessionId
3553
+ )) }) : /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "No sessions found" }) }) : agents.length > 0 ? /* @__PURE__ */ jsx(Stack, { gap: "xs", children: agents.map((agent) => /* @__PURE__ */ jsx(
3554
+ AgentListItem,
3555
+ {
3556
+ agent,
3557
+ isSelected: agentParam === agent.resourceId,
3558
+ onAgentClick
3559
+ },
3560
+ agent.resourceId
3561
+ )) }) : /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "No agents found" }) }) })
3562
+ ] });
3563
+ }
3564
+ function AgentListItem({ agent, isSelected, onAgentClick }) {
3565
+ const theme = useMantineTheme();
3566
+ const titleColor = isSelected ? "var(--color-primary)" : "var(--color-text)";
3567
+ const descriptionColor = isSelected ? "var(--color-text)" : "var(--color-text-subtle)";
3568
+ return /* @__PURE__ */ jsx(
3569
+ Card,
3570
+ {
3571
+ p: "sm",
3572
+ style: {
3573
+ cursor: "pointer",
3574
+ backgroundColor: isSelected ? "color-mix(in srgb, var(--color-primary) 10%, transparent)" : "transparent",
3575
+ boxShadow: "none",
3576
+ border: "none",
3577
+ transition: "all var(--duration-fast) var(--easing)"
3578
+ },
3579
+ onClick: () => onAgentClick(agent.resourceId),
3580
+ children: /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
3581
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
3582
+ /* @__PURE__ */ jsx(IconBrain, { size: 16, color: theme.colors[theme.primaryColor][6] }),
3583
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, c: titleColor, children: agent.name })
3584
+ ] }),
3585
+ agent.description && /* @__PURE__ */ jsx(Text, { size: "xs", c: descriptionColor, lineClamp: 2, children: agent.description })
3586
+ ] })
3587
+ }
3588
+ );
3589
+ }
2645
3590
 
2646
- export { AgentExecutionPanel, CalibrationPage, CalibrationProjectDetailPage, CalibrationProjectsPage, CalibrationRunDetailPage, CommandQueueDetailPage, CommandQueuePage, CommandViewPage, CommandViewSidebarContent, ExecutionPanel, ResourceDetailPage, ResourcesPage, ResourcesSidebar, WorkflowExecutionPanel };
3591
+ export { AgentExecutionPanel, AgentSessionGroup, CalibrationPage, CalibrationProgress, CalibrationProjectDetailPage, CalibrationProjectsPage, CalibrationRunDetailPage, CalibrationSidebar, CommandQueueDetailPage, CommandQueuePage, CommandViewPage, CommandViewSidebarContent, ExecutionPanel, ResourceDetailPage, ResourcesPage, ResourcesSidebar, SessionChatArea, SessionChatInterface, SessionChatPage, SessionDetailsSidebar, SessionExecutionLogs, SessionHeader, SessionListItem, SessionsPage, SessionsSidebar, WorkflowExecutionPanel };