@elevasis/ui 2.25.5 → 2.26.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 (101) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/app/index.css +18 -29
  3. package/dist/app/index.d.ts +118 -64
  4. package/dist/app/index.js +6 -5
  5. package/dist/charts/index.js +6 -5
  6. package/dist/chunk-3MEXPLWT.js +265 -0
  7. package/dist/{chunk-IS53MXE4.js → chunk-4KTLOK7K.js} +1 -1
  8. package/dist/{chunk-KMAXFJPH.js → chunk-CW3UNAF2.js} +5 -409
  9. package/dist/{chunk-HKBEURCV.js → chunk-G26INIF3.js} +1 -1
  10. package/dist/{chunk-NHHCUECV.js → chunk-G66QFZXD.js} +11 -214
  11. package/dist/{chunk-QIW6OCEI.js → chunk-HLFFKKT3.js} +27 -373
  12. package/dist/chunk-JDNEWB5F.js +10 -0
  13. package/dist/{chunk-VMAWXEVG.js → chunk-JKBGDFX2.js} +1136 -828
  14. package/dist/{chunk-MU4VPAMR.js → chunk-JPGX3533.js} +4 -3
  15. package/dist/chunk-KCGGA36K.js +73 -0
  16. package/dist/chunk-KEFWANZY.js +155 -0
  17. package/dist/chunk-LH4GPYDX.js +448 -0
  18. package/dist/{chunk-QNCVK3ZF.js → chunk-LWKZ3BCC.js} +5 -4
  19. package/dist/chunk-OGXKOMUT.js +412 -0
  20. package/dist/chunk-OHXU5WWK.js +3731 -0
  21. package/dist/chunk-ONFKASZI.js +2004 -0
  22. package/dist/{chunk-U36X6NZM.js → chunk-RIFTUOPE.js} +2 -14
  23. package/dist/{chunk-T6INEVX6.js → chunk-SGS4CQ2B.js} +1 -1
  24. package/dist/{chunk-KINQW4JT.js → chunk-UPMX5GJI.js} +5 -5
  25. package/dist/{chunk-N2AP4I5N.js → chunk-UY5I2KOZ.js} +223 -3857
  26. package/dist/{chunk-JMI7L7Y7.js → chunk-W2ZTLH7Y.js} +142 -4
  27. package/dist/{chunk-3KY2GNPE.js → chunk-WUVR4QY6.js} +9 -9
  28. package/dist/{chunk-Q5BEODAT.js → chunk-X2SUMO3P.js} +2 -1
  29. package/dist/{chunk-SNHGSCKH.js → chunk-XBMCDGHA.js} +1 -1
  30. package/dist/{chunk-N55DVMAG.js → chunk-XQQEKWTL.js} +2 -6
  31. package/dist/{chunk-F7JDHS2I.js → chunk-XZSEPJZQ.js} +5 -5
  32. package/dist/{chunk-5BJXMZN4.js → chunk-YHBPR67D.js} +438 -620
  33. package/dist/{chunk-FVKLHLF4.js → chunk-YO2YORW4.js} +4 -4
  34. package/dist/{chunk-TAIX4NO3.js → chunk-ZFLM2YVW.js} +2 -2
  35. package/dist/components/index.css +18 -29
  36. package/dist/components/index.d.ts +211 -383
  37. package/dist/components/index.js +43 -427
  38. package/dist/components/navigation/index.css +28 -39
  39. package/dist/execution/index.d.ts +0 -73
  40. package/dist/features/auth/index.css +28 -39
  41. package/dist/features/crm/index.css +28 -39
  42. package/dist/features/crm/index.d.ts +49 -49
  43. package/dist/features/crm/index.js +14 -14
  44. package/dist/features/dashboard/index.css +28 -39
  45. package/dist/features/dashboard/index.js +18 -15
  46. package/dist/features/delivery/index.css +18 -29
  47. package/dist/features/delivery/index.js +14 -14
  48. package/dist/features/knowledge/index.css +611 -0
  49. package/dist/features/knowledge/index.js +700 -1
  50. package/dist/features/lead-gen/index.css +28 -39
  51. package/dist/features/lead-gen/index.d.ts +212 -166
  52. package/dist/features/lead-gen/index.js +16 -15
  53. package/dist/features/monitoring/index.css +18 -29
  54. package/dist/features/monitoring/index.js +17 -16
  55. package/dist/features/monitoring/requests/index.css +28 -39
  56. package/dist/features/monitoring/requests/index.js +13 -13
  57. package/dist/features/operations/index.css +28 -39
  58. package/dist/features/operations/index.d.ts +16 -98
  59. package/dist/features/operations/index.js +26 -20
  60. package/dist/features/settings/index.css +28 -39
  61. package/dist/features/settings/index.d.ts +1 -0
  62. package/dist/features/settings/index.js +15 -15
  63. package/dist/hooks/delivery/index.css +28 -39
  64. package/dist/hooks/delivery/index.js +2 -2
  65. package/dist/hooks/index.css +18 -29
  66. package/dist/hooks/index.d.ts +180 -377
  67. package/dist/hooks/index.js +13 -13
  68. package/dist/hooks/published.css +18 -29
  69. package/dist/hooks/published.d.ts +180 -377
  70. package/dist/hooks/published.js +13 -13
  71. package/dist/index.css +18 -29
  72. package/dist/index.d.ts +1549 -946
  73. package/dist/index.js +15 -14
  74. package/dist/initialization/index.d.ts +1 -0
  75. package/dist/knowledge/index.d.ts +991 -41
  76. package/dist/knowledge/index.js +5469 -413
  77. package/dist/layout/index.d.ts +2 -0
  78. package/dist/layout/index.js +3 -2
  79. package/dist/organization/index.css +28 -39
  80. package/dist/organization/index.d.ts +1 -0
  81. package/dist/provider/index.css +28 -39
  82. package/dist/provider/index.d.ts +1147 -348
  83. package/dist/provider/index.js +11 -10
  84. package/dist/provider/published.css +28 -39
  85. package/dist/provider/published.d.ts +1146 -347
  86. package/dist/provider/published.js +8 -8
  87. package/dist/test-utils/index.js +2 -2
  88. package/dist/test-utils/setup.js +1 -1
  89. package/dist/theme/index.js +3 -2
  90. package/dist/theme/presets/index.d.ts +97 -0
  91. package/dist/theme/presets/index.js +3 -0
  92. package/dist/types/index.d.ts +71 -126
  93. package/dist/utils/index.js +1 -1
  94. package/dist/vite/index.d.ts +7 -0
  95. package/dist/vite/index.js +10 -0
  96. package/dist/vite-plugin-knowledge/index.d.ts +1 -33
  97. package/dist/vite-plugin-knowledge/index.js +1 -66
  98. package/package.json +46 -33
  99. package/src/knowledge/README.md +8 -8
  100. package/src/theme/presets/README.md +19 -0
  101. /package/dist/{chunk-SGXXJE52.js → chunk-QD4X4H5A.js} +0 -0
@@ -1,34 +1,35 @@
1
- import { SubshellSidebarLoader, SubshellLoader } from './chunk-N55DVMAG.js';
2
1
  import { ChatHeader, ChatSidebar } from './chunk-ROSMICXG.js';
3
- import { BaseNode, useGraphTheme, BaseEdge, FormFieldRenderer, ExecutionStats, UnifiedWorkflowGraph, WorkflowExecutionTimeline, AgentExecutionVisualizer, AgentExecutionTimeline, GraphBackground, GraphFitViewButton, GraphFitViewHandler } from './chunk-NHHCUECV.js';
4
- import { OrganizationModelProspectingSchema } from './chunk-IS53MXE4.js';
5
- import { ResourceHealthPanel } from './chunk-FVKLHLF4.js';
6
- import { useCyberColors, CyberDonut } from './chunk-KMAXFJPH.js';
2
+ import { getOrganizationGraphLensConfig, useOrganizationGraphFilters, createOrganizationGraphFilters, buildOrganizationGraph, filterOrganizationGraph, getCommandViewVisibilityProjection, resolveOrganizationGraphPathTrace, getCommandViewOperationalOverview, getCommandViewSelectionOperationalSummary, buildCommandViewDrillDownSections, expandAroundGraph, getConnectedHiddenResourceIds, FilterPanel, OrganizationGraphDetailPanel, ExpandAroundPanel, CommandViewSidebarContent, getOrganizationGraphTraceNodeOptions, formatOrganizationGraphTraceNodeOptionLabel } from './chunk-OHXU5WWK.js';
3
+ import { SubshellLoader } from './chunk-JDNEWB5F.js';
4
+ import { resolveSemanticIconComponent } from './chunk-KEFWANZY.js';
5
+ import { SubshellSidebarLoader } from './chunk-XQQEKWTL.js';
6
+ import { BaseNode, useGraphTheme, BaseEdge, ExecutionStats, UnifiedWorkflowGraph, WorkflowExecutionTimeline, AgentExecutionVisualizer, AgentExecutionTimeline, GraphBackground, GraphFitViewButton, GraphFitViewHandler } from './chunk-G66QFZXD.js';
7
+ import { FormFieldRenderer } from './chunk-3MEXPLWT.js';
8
+ import { ResourceHealthPanel } from './chunk-YO2YORW4.js';
9
+ import { useCyberColors, CyberDonut } from './chunk-CW3UNAF2.js';
7
10
  import { AppShellLoader } from './chunk-RYTEQBAO.js';
8
11
  import { PageContainer } from './chunk-BZZCNLT6.js';
9
12
  import { SubshellSidebarSection } from './chunk-IIMU5YAJ.js';
10
13
  import { CustomModal, ConfirmationModal } from './chunk-KVJ3LFH2.js';
11
- import { getResourceStatusColor, useTimelineData, useAgentIterationData, getStatusIcon } from './chunk-E4WQGJNS.js';
12
- import { useErrorDetail, useExecution, useArchivedLogs, useDeleteExecution, useRetryExecution, useCancelExecution, useCommandQueueTotals, useStatusFilter, useResourceSearch, useResourcesDomainFilters, usePaginationState, useResources, useRecentExecutionsByResource, filterByDomainFilters, collectResourceFilterFacets, useExecuteAsync, useResourceDefinition, isSessionCapable, useDeleteTask, useCommandQueue, useSubmitAction, useCommandViewData, useCommandViewStats, useCommandViewStore, useResourceExecutions, useCheckpointTasks, COMMAND_VIEW_VISUALIZATION_MODES, useExecutionPanelState, useDeleteSession, useCreateSession, useSessions, useSessionExecutions, useSession, useBulkDeleteExecutions, getCommandViewGraphPositions } from './chunk-5BJXMZN4.js';
13
- import { showApiErrorNotification, showSuccessNotification } from './chunk-HKBEURCV.js';
14
14
  import { useGraphHighlighting, calculateGraphHeight, Graph_module_css_default, GRAPH_CONSTANTS } from './chunk-22UVE3RA.js';
15
+ import { getResourceStatusColor, useTimelineData, useAgentIterationData, getStatusIcon } from './chunk-E4WQGJNS.js';
16
+ import { useErrorDetail, useExecution, useArchivedLogs, useDeleteExecution, useRetryExecution, useCancelExecution, useCommandQueueTotals, useStatusFilter, useResourceSearch, useResourcesDomainFilters, usePaginationState, useResources, useRecentExecutionsByResource, filterByDomainFilters, collectResourceFilterFacets, useResourceDefinition, isSessionCapable, useDeleteTask, useCommandQueue, useSubmitAction, useCommandViewData, useCommandViewStats, useCommandViewStore, useResourceExecutions, useCheckpointTasks, COMMAND_VIEW_VISUALIZATION_MODES, useExecutionPanelState, useDeleteSession, useCreateSession, useSessions, useSessionExecutions, useSession, useBulkDeleteExecutions, getCommandViewGraphPositions } from './chunk-YHBPR67D.js';
17
+ import { showApiErrorNotification, showSuccessNotification } from './chunk-G26INIF3.js';
15
18
  import { useMergedExecution } from './chunk-3ZMAGTWF.js';
19
+ import { JsonViewer, CardHeader, PageTitleCaption, CollapsibleSection, TabCountBadge, ResourceCard, ContextViewer, EmptyState, APIErrorAlert } from './chunk-RIFTUOPE.js';
20
+ import { StyledMarkdown } from './chunk-3KMDHCAR.js';
21
+ import { useOptionalElevasisFeatures, useElevasisFeatures } from './chunk-V3HUIZJX.js';
16
22
  import { SubshellContentContainer } from './chunk-TKAYX2SP.js';
17
- import { JsonViewer, CardHeader, PageTitleCaption, CollapsibleSection, TabCountBadge, ResourceCard, ContextViewer, EmptyState, APIErrorAlert } from './chunk-U36X6NZM.js';
18
23
  import { NavigationButton } from './chunk-NYBEU5TE.js';
19
- import { LabelSchema, ColorTokenSchema, IconNameSchema, PathSchema, DescriptionSchema, DisplayMetadataSchema, ModelIdSchema, ReferenceIdsSchema, OrganizationModelSalesSchema } from './chunk-JMI7L7Y7.js';
20
- import { useOptionalElevasisFeatures, useElevasisFeatures } from './chunk-V3HUIZJX.js';
21
- import { StyledMarkdown } from './chunk-3KMDHCAR.js';
22
24
  import { useRouterContext } from './chunk-Q7DJKLEN.js';
23
25
  import { useAppearance } from './chunk-E565XMTQ.js';
24
26
  import { topbarHeight } from './chunk-DT3QYZVU.js';
25
- import { getErrorInfo, formatErrorMessage, getResourceIcon, formatRelativeTime, getNodeId, PAGE_SIZE_DEFAULT, debounce } from './chunk-SGXXJE52.js';
27
+ import { getErrorInfo, formatErrorMessage, getResourceIcon, formatRelativeTime, PAGE_SIZE_DEFAULT, debounce } from './chunk-QD4X4H5A.js';
26
28
  import { ResourceStatusColors, toWorkflowLogMessages } from './chunk-KRWALB24.js';
27
29
  import { useInitialization } from './chunk-WKJ47GIW.js';
28
30
  import { useOrganization } from './chunk-DD3CCMCZ.js';
29
- import { z } from 'zod';
30
- import { Stack, Group, Text, Badge, Title, Textarea, Alert, Button, ActionIcon, Collapse, Card, ThemeIcon, SimpleGrid, Divider, Paper, Space, CopyButton, Center, Tooltip, Code, Menu, useMantineTheme, UnstyledButton, Select, RangeSlider, Box, Progress, Tabs, Pagination, TextInput, Modal, LoadingOverlay, Loader, SegmentedControl, ScrollArea, Checkbox, NumberInput, MultiSelect, Switch } from '@mantine/core';
31
- import { IconBrain, IconFileText, IconMail, IconSend, IconClock, IconArrowUp, IconMessageCircle, IconRocket, IconEye, IconEdit, IconAlertTriangle, IconRefresh, IconX, IconCheck, IconCode, IconAlertCircle, IconChevronRight, IconTool, IconSettings, IconCpu, IconClockHour4, IconVersions, IconPlayerPlay, IconNetwork, IconSitemap, IconCopy, IconPlayerStop, IconReload, IconTrash, IconTerminal2, IconBug, IconChevronDown, IconMessage, IconArrowLeft, IconRobot, IconGitBranch, IconDotsVertical, IconFilter, IconCircleCheck, IconCategory, IconDatabase, IconApps, IconRoute, IconAdjustmentsHorizontal, IconSearch, IconCircleX, IconCircleDashed, IconExternalLink, IconFolders, IconBraces, IconBolt, IconTopologyStar3, IconInfoCircle, IconPlus, IconLayoutSidebarRightExpand, IconNote, IconArchive, IconDownload, IconTimeline, IconActivityHeartbeat, IconClockPause, IconArrowsMaximize, IconShare2, IconHistory } from '@tabler/icons-react';
31
+ import { Stack, Group, Text, Badge, Title, Textarea, Alert, Button, ActionIcon, Collapse, Card, ThemeIcon, SimpleGrid, Divider, Paper, Space, CopyButton, Center, Tooltip, Code, Menu, useMantineTheme, UnstyledButton, Select, RangeSlider, Box, Progress, Tabs, Pagination, TextInput, Loader, SegmentedControl, Modal, LoadingOverlay, ScrollArea } from '@mantine/core';
32
+ import { IconBrain, IconFileText, IconMail, IconSend, IconClock, IconArrowUp, IconMessageCircle, IconRocket, IconEye, IconEdit, IconAlertTriangle, IconRefresh, IconX, IconCheck, IconCode, IconAlertCircle, IconChevronRight, IconTool, IconSettings, IconCpu, IconClockHour4, IconVersions, IconNetwork, IconSitemap, IconCopy, IconPlayerStop, IconReload, IconTrash, IconTerminal2, IconBug, IconChevronDown, IconPlayerPlay, IconMessage, IconArrowLeft, IconRobot, IconGitBranch, IconDotsVertical, IconFilter, IconCircleCheck, IconCategory, IconDatabase, IconApps, IconRoute, IconAdjustmentsHorizontal, IconSearch, IconCircleX, IconCircleDashed, IconExternalLink, IconFolders, IconBraces, IconBolt, IconTopologyStar3, IconInfoCircle, IconPlus, IconLayoutSidebarRightExpand, IconNote, IconArchive, IconDownload, IconTimeline, IconActivityHeartbeat, IconClockPause, IconArrowsMaximize, IconHistory } from '@tabler/icons-react';
32
33
  import { useForm } from '@mantine/form';
33
34
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
34
35
  import { memo, useState, useMemo, useRef, useCallback, useEffect, useDeferredValue, useEffectEvent } from 'react';
@@ -39,725 +40,7 @@ import { useClipboard } from '@mantine/hooks';
39
40
  import { notifications } from '@mantine/notifications';
40
41
  import { useNavigate } from '@tanstack/react-router';
41
42
  import cytoscape from 'cytoscape';
42
- import { create } from 'zustand';
43
- import { formatDistanceToNow } from 'date-fns';
44
-
45
- var NodeIdPathSchema = z.string().trim().min(1).max(100).regex(/^([a-z0-9-]+)(\.[a-z0-9-]+)*$/, "Node IDs must be lowercase dotted paths");
46
- var NodeIdStringSchema = z.string().trim().min(1).max(200).regex(/^[a-z]+:([a-z0-9-]+)(\.[a-z0-9-]+)*$/, "Node references must use kind:dotted-path");
47
- var UiPositionSchema = z.enum(["sidebar-primary", "sidebar-bottom"]);
48
- var FeatureSchema = z.object({
49
- id: NodeIdPathSchema,
50
- label: LabelSchema,
51
- description: DescriptionSchema.optional(),
52
- enabled: z.boolean().default(true),
53
- path: PathSchema.optional(),
54
- icon: IconNameSchema.optional(),
55
- color: ColorTokenSchema.optional(),
56
- uiPosition: UiPositionSchema.optional(),
57
- requiresAdmin: z.boolean().optional(),
58
- devOnly: z.boolean().optional()
59
- });
60
- var OrganizationModelBrandingSchema = z.object({
61
- organizationName: LabelSchema,
62
- productName: LabelSchema,
63
- shortName: z.string().trim().min(1).max(40),
64
- description: DescriptionSchema.optional(),
65
- logos: z.object({
66
- light: z.string().trim().min(1).max(2048).optional(),
67
- dark: z.string().trim().min(1).max(2048).optional()
68
- }).default({})
69
- });
70
- var ProjectsDomainStateSchema = DisplayMetadataSchema.extend({
71
- id: ModelIdSchema,
72
- order: z.number().int().min(0)
73
- });
74
- var OrganizationModelProjectsSchema = z.object({
75
- projectEntityId: ModelIdSchema,
76
- milestoneEntityId: ModelIdSchema,
77
- taskEntityId: ModelIdSchema,
78
- projectStatuses: z.array(ProjectsDomainStateSchema).min(1),
79
- milestoneStatuses: z.array(ProjectsDomainStateSchema).min(1),
80
- taskStatuses: z.array(ProjectsDomainStateSchema).min(1)
81
- });
82
- var SurfaceTypeSchema = z.enum(["page", "dashboard", "graph", "detail", "list", "settings"]);
83
- var SurfaceDefinitionSchema = z.object({
84
- id: ModelIdSchema,
85
- label: LabelSchema,
86
- path: PathSchema,
87
- surfaceType: SurfaceTypeSchema,
88
- description: DescriptionSchema.optional(),
89
- enabled: z.boolean().default(true),
90
- devOnly: z.boolean().optional(),
91
- icon: IconNameSchema.optional(),
92
- featureId: ModelIdSchema.optional(),
93
- featureIds: ReferenceIdsSchema,
94
- entityIds: ReferenceIdsSchema,
95
- resourceIds: ReferenceIdsSchema,
96
- capabilityIds: ReferenceIdsSchema,
97
- parentId: ModelIdSchema.optional()
98
- });
99
- var NavigationGroupSchema = z.object({
100
- id: ModelIdSchema,
101
- label: LabelSchema,
102
- placement: z.string().trim().min(1).max(50),
103
- surfaceIds: z.array(ModelIdSchema).default([])
104
- });
105
- var OrganizationModelNavigationSchema = z.object({
106
- defaultSurfaceId: ModelIdSchema.optional(),
107
- surfaces: z.array(SurfaceDefinitionSchema).default([]),
108
- groups: z.array(NavigationGroupSchema).default([])
109
- });
110
- var BusinessHoursDaySchema = z.object({
111
- open: z.string().trim().regex(/^\d{2}:\d{2}$/, "Expected HH:MM format"),
112
- close: z.string().trim().regex(/^\d{2}:\d{2}$/, "Expected HH:MM format")
113
- });
114
- var BusinessHoursSchema = z.object({
115
- monday: BusinessHoursDaySchema.optional(),
116
- tuesday: BusinessHoursDaySchema.optional(),
117
- wednesday: BusinessHoursDaySchema.optional(),
118
- thursday: BusinessHoursDaySchema.optional(),
119
- friday: BusinessHoursDaySchema.optional(),
120
- saturday: BusinessHoursDaySchema.optional(),
121
- sunday: BusinessHoursDaySchema.optional()
122
- }).default({});
123
- var IdentityDomainSchema = z.object({
124
- /** Why the organization exists — one or two plain-language sentences. */
125
- mission: z.string().trim().max(1e3).default(""),
126
- /** Long-term direction the organization is moving toward. */
127
- vision: z.string().trim().max(1e3).default(""),
128
- /** Legal registered name of the entity. */
129
- legalName: z.string().trim().max(200).default(""),
130
- /**
131
- * Type of legal entity (e.g. "LLC", "Corporation", "Sole Proprietor",
132
- * "Non-profit"). Free-form string so it covers any jurisdiction.
133
- */
134
- entityType: z.string().trim().max(100).default(""),
135
- /**
136
- * Primary jurisdiction of registration or operation
137
- * (e.g. "United States – Delaware", "Canada – Ontario").
138
- */
139
- jurisdiction: z.string().trim().max(200).default(""),
140
- /**
141
- * Industry category — broad classification (e.g. "Marketing Agency",
142
- * "Software / SaaS", "Professional Services").
143
- */
144
- industryCategory: z.string().trim().max(200).default(""),
145
- /**
146
- * Geographic focus — where the organization primarily operates or serves
147
- * (e.g. "North America", "Global", "Southeast Asia").
148
- */
149
- geographicFocus: z.string().trim().max(200).default(""),
150
- /**
151
- * IANA timezone identifier for the organization's primary operating timezone
152
- * (e.g. "America/Los_Angeles", "Europe/London", "UTC").
153
- */
154
- timeZone: z.string().trim().max(100).default("UTC"),
155
- /** Typical operating hours per day of week. Empty object means not configured. */
156
- businessHours: BusinessHoursSchema,
157
- /**
158
- * Long-form markdown capturing client context, problem narrative, and domain
159
- * background. Populated by /setup; surfaced to agents as organizational context.
160
- * Optional — many projects have no external client.
161
- */
162
- clientBrief: z.string().trim().default("")
163
- });
164
- var DEFAULT_ORGANIZATION_MODEL_IDENTITY = {
165
- mission: "",
166
- vision: "",
167
- legalName: "",
168
- entityType: "",
169
- jurisdiction: "",
170
- industryCategory: "",
171
- geographicFocus: "",
172
- timeZone: "UTC",
173
- businessHours: {},
174
- clientBrief: ""
175
- };
176
- var FirmographicsSchema = z.object({
177
- /** Industry vertical (e.g. "Marketing Agency", "Legal", "Real Estate"). */
178
- industry: z.string().trim().max(200).optional(),
179
- /**
180
- * Company headcount band (e.g. "1–10", "11–50", "51–200", "200+").
181
- * Free-form string to accommodate any band notation.
182
- */
183
- companySize: z.string().trim().max(100).optional(),
184
- /**
185
- * Primary geographic region the segment operates in or is targeted from
186
- * (e.g. "North America", "Europe", "Global").
187
- */
188
- region: z.string().trim().max(200).optional()
189
- });
190
- var CustomerSegmentSchema = z.object({
191
- /** Stable unique identifier for the segment (e.g. "segment-smb-agencies"). */
192
- id: z.string().trim().min(1).max(100),
193
- /** Human-readable name shown to agents and in UI (e.g. "SMB Marketing Agencies"). */
194
- name: z.string().trim().max(200).default(""),
195
- /** One or two sentences describing who this segment is. */
196
- description: z.string().trim().max(2e3).default(""),
197
- /**
198
- * The primary job(s) this segment is trying to get done — the goal they hire
199
- * a product/service to accomplish. Plain-language narrative or bullet list.
200
- */
201
- jobsToBeDone: z.string().trim().max(2e3).default(""),
202
- /**
203
- * Pains — frustrations, obstacles, and risks the segment experiences
204
- * when trying to accomplish their jobs-to-be-done.
205
- */
206
- pains: z.array(z.string().trim().max(500)).default([]),
207
- /**
208
- * Gains — outcomes and benefits the segment desires; positive motivators
209
- * beyond merely resolving pains.
210
- */
211
- gains: z.array(z.string().trim().max(500)).default([]),
212
- /** Firmographic profile for targeting and filtering. */
213
- firmographics: FirmographicsSchema.default({}),
214
- /**
215
- * Value proposition — one or two sentences stating why this organization's
216
- * offering is uniquely suited for this segment's needs.
217
- */
218
- valueProp: z.string().trim().max(2e3).default("")
219
- });
220
- var CustomersDomainSchema = z.object({
221
- segments: z.array(CustomerSegmentSchema).default([])
222
- });
223
- var DEFAULT_ORGANIZATION_MODEL_CUSTOMERS = {
224
- segments: []
225
- };
226
- var PricingModelSchema = z.enum(["one-time", "subscription", "usage-based", "custom"]);
227
- var ProductSchema = z.object({
228
- /** Stable unique identifier for the product (e.g. "product-starter-plan"). */
229
- id: z.string().trim().min(1).max(100),
230
- /** Human-readable name shown to agents and in UI (e.g. "Starter Plan"). */
231
- name: z.string().trim().max(200).default(""),
232
- /** One or two sentences describing what this product/service delivers. */
233
- description: z.string().trim().max(2e3).default(""),
234
- /**
235
- * How this product is priced:
236
- * - "one-time" — single purchase (setup fee, project fee)
237
- * - "subscription" — recurring (monthly/annual SaaS, retainer)
238
- * - "usage-based" — metered by consumption (API calls, seats)
239
- * - "custom" — negotiated or bespoke pricing
240
- */
241
- pricingModel: PricingModelSchema.default("custom"),
242
- /** Base price amount (≥ 0). Currency unit defined by `currency`. */
243
- price: z.number().min(0).default(0),
244
- /**
245
- * ISO 4217 currency code (e.g. "USD", "EUR", "GBP").
246
- * Free-form string to accommodate any currency; defaults to "USD".
247
- */
248
- currency: z.string().trim().max(10).default("USD"),
249
- /**
250
- * IDs of customer segments this product targets.
251
- * Each id must reference a declared `customers.segments[].id`.
252
- * Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
253
- */
254
- targetSegmentIds: z.array(z.string().trim().min(1)).default([]),
255
- /**
256
- * Optional: ID of the platform feature responsible for delivering this product.
257
- * When present, must reference a declared `features[].id`.
258
- * Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
259
- */
260
- deliveryFeatureId: z.string().trim().min(1).optional()
261
- });
262
- var OfferingsDomainSchema = z.object({
263
- products: z.array(ProductSchema).default([])
264
- });
265
- var DEFAULT_ORGANIZATION_MODEL_OFFERINGS = {
266
- products: []
267
- };
268
- var RoleSchema = z.object({
269
- /** Stable unique identifier for the role (e.g. "role-ceo", "role-head-of-sales"). */
270
- id: z.string().trim().min(1).max(100),
271
- /** Human-readable title shown to agents and in UI (e.g. "CEO", "Head of Sales"). */
272
- title: z.string().trim().min(1).max(200),
273
- /**
274
- * List of responsibilities this role owns — plain-language descriptions of
275
- * what the person in this role is accountable for delivering.
276
- * Defaults to empty array so minimal role definitions stay concise.
277
- */
278
- responsibilities: z.array(z.string().trim().max(500)).default([]),
279
- /**
280
- * Optional: ID of another role this role reports to.
281
- * When present, must reference another `roles[].id` in the same organization.
282
- * Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
283
- * Absence indicates a top-level role (no reporting line).
284
- */
285
- reportsToId: z.string().trim().min(1).max(100).optional(),
286
- /**
287
- * Optional: name or email of the person currently holding this role.
288
- * Free-form string — supports "Alice Johnson", "alice@example.com", or
289
- * any human-readable identifier. Not validated against any user registry.
290
- */
291
- heldBy: z.string().trim().max(200).optional()
292
- });
293
- var RolesDomainSchema = z.object({
294
- roles: z.array(RoleSchema).default([])
295
- });
296
- var DEFAULT_ORGANIZATION_MODEL_ROLES = {
297
- roles: []
298
- };
299
- var KeyResultSchema = z.object({
300
- /** Stable unique identifier for the measurable outcome (e.g. "kr-revenue-q1"). */
301
- id: z.string().trim().min(1).max(100),
302
- /** Plain-language description of this measurable outcome (e.g. "Increase trial-to-paid conversion"). */
303
- description: z.string().trim().min(1).max(500),
304
- /**
305
- * What is being measured — the metric name (e.g. "monthly revenue", "NPS score",
306
- * "trial-to-paid conversion rate"). Free-form string.
307
- */
308
- targetMetric: z.string().trim().min(1).max(200),
309
- /** Current measured value. Defaults to 0 when not yet tracked. */
310
- currentValue: z.number().default(0),
311
- /**
312
- * Target value to reach for this measurable outcome to be considered achieved.
313
- * Optional — omit if the outcome is directional (e.g. "reduce churn") without
314
- * a hard numeric target.
315
- */
316
- targetValue: z.number().optional()
317
- });
318
- var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
319
- var ObjectiveSchema = z.object({
320
- /** Stable unique identifier for the goal (e.g. "goal-grow-arr-q1-2026"). */
321
- id: z.string().trim().min(1).max(100),
322
- /** Plain-language description of what the organization wants to achieve. */
323
- description: z.string().trim().min(1).max(1e3),
324
- /**
325
- * Start of the period this goal is active for — ISO 8601 date string (YYYY-MM-DD).
326
- * Must be strictly before `periodEnd`.
327
- */
328
- periodStart: z.string().regex(ISO_DATE_REGEX, "periodStart must be an ISO date string (YYYY-MM-DD)"),
329
- /**
330
- * End of the period this goal is active for — ISO 8601 date string (YYYY-MM-DD).
331
- * Must be strictly after `periodStart`.
332
- * Enforced via `OrganizationModelSchema.superRefine()`.
333
- */
334
- periodEnd: z.string().regex(ISO_DATE_REGEX, "periodEnd must be an ISO date string (YYYY-MM-DD)"),
335
- /**
336
- * List of measurable outcomes that define success for this goal.
337
- * Defaults to empty array so goals can be declared before outcomes are defined.
338
- */
339
- keyResults: z.array(KeyResultSchema).default([])
340
- });
341
- var GoalsDomainSchema = z.object({
342
- objectives: z.array(ObjectiveSchema).default([])
343
- });
344
- var DEFAULT_ORGANIZATION_MODEL_GOALS = {
345
- objectives: []
346
- };
347
- var OperationSemanticClassSchema = z.enum(["queue", "executions", "sessions", "notifications", "schedules"]);
348
- var OperationEntrySchema = z.object({
349
- id: z.string().trim().min(1).max(100),
350
- label: z.string().trim().min(1).max(120),
351
- semanticClass: OperationSemanticClassSchema,
352
- /** Optional reference to the feature that owns this runtime entity. */
353
- featureId: z.string().trim().min(1).max(100).optional(),
354
- /**
355
- * Optional pointer to the status semanticClass values that apply to this
356
- * entity — ties operations back to the statuses domain for vibe rendering.
357
- */
358
- supportedStatusSemanticClass: z.array(z.string().trim().min(1).max(80)).optional()
359
- });
360
- var OperationsDomainSchema = z.object({
361
- entries: z.array(OperationEntrySchema).default([])
362
- });
363
- var StatusSemanticClassSchema = z.enum([
364
- "delivery.task",
365
- "delivery.project",
366
- "delivery.milestone",
367
- "queue",
368
- "execution",
369
- "schedule",
370
- "schedule.run",
371
- "request"
372
- ]);
373
- var StatusEntrySchema = z.object({
374
- id: z.string().trim().min(1).max(100),
375
- label: z.string().trim().min(1).max(120),
376
- semanticClass: StatusSemanticClassSchema,
377
- category: z.string().trim().min(1).max(80).optional()
378
- });
379
- var StatusesDomainSchema = z.object({
380
- entries: z.array(StatusEntrySchema).default([])
381
- });
382
- var KnowledgeLinkSchema = z.object({
383
- nodeId: NodeIdStringSchema
384
- });
385
- var OrgKnowledgeKindSchema = z.enum(["playbook", "strategy", "reference"]);
386
- var OrgKnowledgeNodeSchema = z.object({
387
- id: ModelIdSchema,
388
- kind: OrgKnowledgeKindSchema,
389
- title: z.string().trim().min(1).max(200),
390
- summary: z.string().trim().min(1).max(1e3),
391
- /** Raw MDX string. Phase 2 will introduce a structured block format. */
392
- body: z.string().trim().min(1),
393
- /**
394
- * Graph links to other OM nodes this knowledge node governs.
395
- * Each link emits a `governs` edge: knowledge-node -> target node.
396
- */
397
- links: z.array(KnowledgeLinkSchema).default([]),
398
- /** Identifiers of the roles or members who own this knowledge node. */
399
- ownerIds: z.array(ModelIdSchema).default([]),
400
- /** ISO date string (YYYY-MM-DD or full ISO 8601) of last meaningful update. */
401
- updatedAt: z.string().trim().min(1).max(50)
402
- });
403
- var KnowledgeDomainSchema = z.object({
404
- nodes: z.array(OrgKnowledgeNodeSchema).default([])
405
- });
406
-
407
- // ../core/src/organization-model/schema.ts
408
- var OrganizationModelSchemaBase = z.object({
409
- version: z.literal(1).default(1),
410
- features: z.array(FeatureSchema).default([]),
411
- branding: OrganizationModelBrandingSchema,
412
- navigation: OrganizationModelNavigationSchema.default({ surfaces: [], groups: [] }),
413
- sales: OrganizationModelSalesSchema,
414
- prospecting: OrganizationModelProspectingSchema,
415
- projects: OrganizationModelProjectsSchema,
416
- identity: IdentityDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_IDENTITY),
417
- customers: CustomersDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_CUSTOMERS),
418
- offerings: OfferingsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_OFFERINGS),
419
- roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
420
- goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
421
- statuses: StatusesDomainSchema.default({ entries: [] }),
422
- operations: OperationsDomainSchema.default({ entries: [] }),
423
- knowledge: KnowledgeDomainSchema.default({ nodes: [] })
424
- });
425
- function addIssue(ctx, path, message) {
426
- ctx.addIssue({
427
- code: z.ZodIssueCode.custom,
428
- path,
429
- message
430
- });
431
- }
432
- function collectIds(items, ctx, collectionPath, label) {
433
- const itemsById = /* @__PURE__ */ new Map();
434
- items.forEach((item, index) => {
435
- if (itemsById.has(item.id)) {
436
- addIssue(ctx, [...collectionPath, index, "id"], `${label} id "${item.id}" must be unique`);
437
- return;
438
- }
439
- itemsById.set(item.id, item);
440
- });
441
- return itemsById;
442
- }
443
- var LEGACY_FEATURE_ALIASES = /* @__PURE__ */ new Map([
444
- ["crm", "sales.crm"],
445
- ["lead-gen", "sales.lead-gen"],
446
- ["submitted-requests", "monitoring.submitted-requests"]
447
- ]);
448
- function hasFeature(featuresById, featureId) {
449
- return featuresById.has(featureId) || featuresById.has(LEGACY_FEATURE_ALIASES.get(featureId) ?? "");
450
- }
451
- var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ctx) => {
452
- const featuresById = collectIds(model.features, ctx, ["features"], "Feature");
453
- model.features.forEach((feature, featureIndex) => {
454
- const segments = feature.id.split(".");
455
- if (segments.length > 1) {
456
- const parentId = segments.slice(0, -1).join(".");
457
- if (!featuresById.has(parentId)) {
458
- addIssue(
459
- ctx,
460
- ["features", featureIndex, "id"],
461
- `Feature "${feature.id}" references unknown parent "${parentId}"`
462
- );
463
- }
464
- }
465
- const hasChildren = model.features.some(
466
- (candidate) => candidate.id.startsWith(`${feature.id}.`) && candidate.id !== feature.id
467
- );
468
- if (hasChildren && feature.enabled) {
469
- const hasEnabledDescendant = model.features.some(
470
- (candidate) => candidate.id.startsWith(`${feature.id}.`) && candidate.enabled
471
- );
472
- if (!hasEnabledDescendant) {
473
- addIssue(
474
- ctx,
475
- ["features", featureIndex, "enabled"],
476
- `Feature "${feature.id}" is enabled but has no enabled descendants`
477
- );
478
- }
479
- }
480
- });
481
- const segmentsById = new Map(model.customers.segments.map((seg) => [seg.id, seg]));
482
- model.offerings.products.forEach((product, productIndex) => {
483
- product.targetSegmentIds.forEach((segmentId, segmentIndex) => {
484
- if (!segmentsById.has(segmentId)) {
485
- addIssue(
486
- ctx,
487
- ["offerings", "products", productIndex, "targetSegmentIds", segmentIndex],
488
- `Product "${product.id}" references unknown customer segment "${segmentId}"`
489
- );
490
- }
491
- });
492
- if (product.deliveryFeatureId !== void 0 && !hasFeature(featuresById, product.deliveryFeatureId)) {
493
- addIssue(
494
- ctx,
495
- ["offerings", "products", productIndex, "deliveryFeatureId"],
496
- `Product "${product.id}" references unknown delivery feature "${product.deliveryFeatureId}"`
497
- );
498
- }
499
- });
500
- model.goals.objectives.forEach((objective, index) => {
501
- if (objective.periodEnd <= objective.periodStart) {
502
- addIssue(
503
- ctx,
504
- ["goals", "objectives", index, "periodEnd"],
505
- `Goal "${objective.id}" has periodEnd "${objective.periodEnd}" which must be strictly after periodStart "${objective.periodStart}"`
506
- );
507
- }
508
- });
509
- const rolesById = new Map(model.roles.roles.map((role) => [role.id, role]));
510
- model.roles.roles.forEach((role, roleIndex) => {
511
- if (role.reportsToId !== void 0 && !rolesById.has(role.reportsToId)) {
512
- addIssue(
513
- ctx,
514
- ["roles", "roles", roleIndex, "reportsToId"],
515
- `Role "${role.id}" references unknown reportsToId "${role.reportsToId}"`
516
- );
517
- }
518
- });
519
- });
520
-
521
- // ../core/src/organization-model/graph/schema.ts
522
- var OrganizationGraphNodeKindSchema = z.enum([
523
- "organization",
524
- "feature",
525
- "surface",
526
- "entity",
527
- "capability",
528
- "resource",
529
- "knowledge"
530
- ]);
531
- var OrganizationGraphEdgeKindSchema = z.enum([
532
- "contains",
533
- "references",
534
- "exposes",
535
- "maps_to",
536
- "operates-on",
537
- "uses",
538
- "governs"
539
- ]);
540
- var OrganizationGraphNodeSchema = z.object({
541
- id: z.string().trim().min(1).max(200),
542
- kind: OrganizationGraphNodeKindSchema,
543
- label: LabelSchema,
544
- sourceId: z.string().trim().min(1).max(255).optional(),
545
- description: DescriptionSchema.optional(),
546
- enabled: z.boolean().optional(),
547
- featureId: z.string().trim().min(1).max(100).optional(),
548
- resourceType: z.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint"]).optional()
549
- });
550
- var OrganizationGraphEdgeSchema = z.object({
551
- id: z.string().trim().min(1).max(250),
552
- kind: OrganizationGraphEdgeKindSchema,
553
- sourceId: z.string().trim().min(1).max(200),
554
- targetId: z.string().trim().min(1).max(200),
555
- label: z.string().trim().min(1).max(120).optional(),
556
- relationshipType: z.enum(["triggers", "uses", "approval"]).optional()
557
- });
558
- var OrganizationGraphSchema = z.object({
559
- version: z.literal(1),
560
- organizationModelVersion: OrganizationModelSchema.shape.version,
561
- nodes: z.array(OrganizationGraphNodeSchema),
562
- edges: z.array(OrganizationGraphEdgeSchema)
563
- });
564
- var BuildOrganizationGraphInputSchema = z.object({
565
- organizationModel: OrganizationModelSchema,
566
- commandViewData: z.unknown().optional()
567
- });
568
43
 
569
- // ../core/src/organization-model/graph/build.ts
570
- function nodeId(kind, sourceId) {
571
- return kind === "organization" ? "organization-model" : `${kind}:${sourceId ?? ""}`;
572
- }
573
- function edgeId(kind, sourceId, targetId, variant) {
574
- return variant ? `edge:${kind}:${variant}:${sourceId}:${targetId}` : `edge:${kind}:${sourceId}:${targetId}`;
575
- }
576
- function pushUniqueNode(nodes, seen, node) {
577
- if (seen.has(node.id)) return;
578
- seen.add(node.id);
579
- nodes.push(node);
580
- }
581
- function pushUniqueEdge(edges, seen, edge) {
582
- if (seen.has(edge.id)) return;
583
- seen.add(edge.id);
584
- edges.push(edge);
585
- }
586
- function upsertResourceNode(nodes, seen, resourceNodesById, node) {
587
- const existing = resourceNodesById.get(node.id);
588
- if (existing) {
589
- if (!existing.label || existing.label === existing.sourceId) {
590
- existing.label = node.label;
591
- }
592
- if (!existing.description && node.description) {
593
- existing.description = node.description;
594
- }
595
- if (!existing.sourceId && node.sourceId) {
596
- existing.sourceId = node.sourceId;
597
- }
598
- if (!existing.resourceType && node.resourceType) {
599
- existing.resourceType = node.resourceType;
600
- }
601
- return existing;
602
- }
603
- resourceNodesById.set(node.id, node);
604
- pushUniqueNode(nodes, seen, node);
605
- return node;
606
- }
607
- function ensureResourceNode(nodes, seen, resourceNodesById, resourceId) {
608
- const existing = resourceNodesById.get(nodeId("resource", resourceId));
609
- if (existing) return existing;
610
- return upsertResourceNode(nodes, seen, resourceNodesById, {
611
- id: nodeId("resource", resourceId),
612
- kind: "resource",
613
- label: resourceId,
614
- sourceId: resourceId
615
- });
616
- }
617
- function normalizeCommandViewResourceType(resourceType) {
618
- return resourceType === "human" ? "human_checkpoint" : resourceType;
619
- }
620
- function collectCommandViewResources(commandViewData) {
621
- return [
622
- ...commandViewData.workflows,
623
- ...commandViewData.agents,
624
- ...commandViewData.triggers,
625
- ...commandViewData.integrations,
626
- ...commandViewData.externalResources,
627
- ...commandViewData.humanCheckpoints
628
- ];
629
- }
630
- function pushResourceLinks(edges, edgeIds, resourceNodeId, links) {
631
- for (const link of links ?? []) {
632
- pushUniqueEdge(edges, edgeIds, {
633
- id: edgeId(link.kind, resourceNodeId, link.nodeId),
634
- kind: link.kind,
635
- sourceId: resourceNodeId,
636
- targetId: link.nodeId
637
- });
638
- }
639
- }
640
- function buildOrganizationGraph(input) {
641
- const parsed = BuildOrganizationGraphInputSchema.parse(input);
642
- const organizationModel = parsed.organizationModel;
643
- const commandViewData = parsed.commandViewData;
644
- const nodes = [];
645
- const edges = [];
646
- const nodeIds = /* @__PURE__ */ new Set();
647
- const edgeIds = /* @__PURE__ */ new Set();
648
- const resourceNodesById = /* @__PURE__ */ new Map();
649
- const organizationNode = {
650
- id: nodeId("organization"),
651
- kind: "organization",
652
- label: "Organization Model"
653
- };
654
- pushUniqueNode(nodes, nodeIds, organizationNode);
655
- for (const feature of [...organizationModel.features].sort((a, b) => a.id.localeCompare(b.id))) {
656
- const id = nodeId("feature", feature.id);
657
- pushUniqueNode(nodes, nodeIds, {
658
- id,
659
- kind: "feature",
660
- label: feature.label,
661
- sourceId: feature.id,
662
- description: feature.description,
663
- enabled: feature.enabled,
664
- featureId: feature.id
665
- });
666
- pushUniqueEdge(edges, edgeIds, {
667
- id: edgeId("contains", organizationNode.id, id),
668
- kind: "contains",
669
- sourceId: organizationNode.id,
670
- targetId: id
671
- });
672
- const parentId = feature.id.includes(".") ? feature.id.slice(0, feature.id.lastIndexOf(".")) : void 0;
673
- if (parentId) {
674
- pushUniqueEdge(edges, edgeIds, {
675
- id: edgeId("contains", nodeId("feature", parentId), id),
676
- kind: "contains",
677
- sourceId: nodeId("feature", parentId),
678
- targetId: id
679
- });
680
- }
681
- }
682
- for (const node of [...organizationModel.knowledge?.nodes ?? []].sort((a, b) => a.id.localeCompare(b.id))) {
683
- const id = nodeId("knowledge", node.id);
684
- pushUniqueNode(nodes, nodeIds, {
685
- id,
686
- kind: "knowledge",
687
- label: node.title,
688
- sourceId: node.id,
689
- description: node.summary
690
- });
691
- pushUniqueEdge(edges, edgeIds, {
692
- id: edgeId("contains", organizationNode.id, id),
693
- kind: "contains",
694
- sourceId: organizationNode.id,
695
- targetId: id
696
- });
697
- for (const link of node.links) {
698
- pushUniqueEdge(edges, edgeIds, {
699
- id: edgeId("governs", id, link.nodeId),
700
- kind: "governs",
701
- sourceId: id,
702
- targetId: link.nodeId
703
- });
704
- }
705
- }
706
- if (commandViewData) {
707
- const commandViewResources = collectCommandViewResources(commandViewData).sort(
708
- (a, b) => a.resourceId.localeCompare(b.resourceId)
709
- );
710
- for (const resource of commandViewResources) {
711
- const id = nodeId("resource", resource.resourceId);
712
- const resourceNode = upsertResourceNode(nodes, nodeIds, resourceNodesById, {
713
- id,
714
- kind: "resource",
715
- label: resource.name,
716
- sourceId: resource.resourceId,
717
- description: resource.description,
718
- resourceType: normalizeCommandViewResourceType(resource.type)
719
- });
720
- pushUniqueEdge(edges, edgeIds, {
721
- id: edgeId("contains", organizationNode.id, resourceNode.id),
722
- kind: "contains",
723
- sourceId: organizationNode.id,
724
- targetId: resourceNode.id
725
- });
726
- pushResourceLinks(edges, edgeIds, resourceNode.id, resource.links);
727
- }
728
- for (const relationship of [...commandViewData.edges].sort((a, b) => a.id.localeCompare(b.id))) {
729
- const sourceNode = ensureResourceNode(nodes, nodeIds, resourceNodesById, relationship.source);
730
- const targetNode = ensureResourceNode(nodes, nodeIds, resourceNodesById, relationship.target);
731
- pushUniqueEdge(edges, edgeIds, {
732
- id: edgeId("contains", organizationNode.id, sourceNode.id),
733
- kind: "contains",
734
- sourceId: organizationNode.id,
735
- targetId: sourceNode.id
736
- });
737
- pushUniqueEdge(edges, edgeIds, {
738
- id: edgeId("contains", organizationNode.id, targetNode.id),
739
- kind: "contains",
740
- sourceId: organizationNode.id,
741
- targetId: targetNode.id
742
- });
743
- pushUniqueEdge(edges, edgeIds, {
744
- id: edgeId("references", sourceNode.id, targetNode.id, relationship.relationship),
745
- kind: "references",
746
- sourceId: sourceNode.id,
747
- targetId: targetNode.id,
748
- label: relationship.relationship,
749
- relationshipType: relationship.relationship
750
- });
751
- }
752
- }
753
- const graph = {
754
- version: 1,
755
- organizationModelVersion: organizationModel.version,
756
- nodes,
757
- edges
758
- };
759
- return OrganizationGraphSchema.parse(graph);
760
- }
761
44
  var iconMap = {
762
45
  IconCheck,
763
46
  IconX,
@@ -773,13 +56,35 @@ var iconMap = {
773
56
  IconSend,
774
57
  IconMail
775
58
  };
59
+ var semanticActionIconMap = {
60
+ "action.approve": IconCheck,
61
+ "action.reject": IconX,
62
+ "action.retry": IconRefresh,
63
+ "action.escalate": IconAlertTriangle,
64
+ "action.edit": IconEdit,
65
+ "action.view": IconEye,
66
+ "action.launch": IconRocket,
67
+ "action.message": IconMessageCircle,
68
+ "action.promote": IconArrowUp,
69
+ "action.submit": IconSend,
70
+ "action.email": IconMail,
71
+ "status.pending": IconClock,
72
+ "status.success": IconCheck,
73
+ "status.error": IconX,
74
+ "status.warning": IconAlertTriangle
75
+ };
776
76
  function getIcon(iconName) {
777
77
  if (!iconName) return null;
778
- const icon = iconMap[iconName];
779
- if (!icon && process.env.NODE_ENV !== "production") {
780
- console.warn(`[iconMap] Unknown icon "${iconName}". Allowed: ${Object.keys(iconMap).join(", ")}`);
78
+ const icon = iconMap[iconName] ?? semanticActionIconMap[iconName];
79
+ if (icon) return icon;
80
+ const semanticIcon = resolveSemanticIconComponent(iconName);
81
+ if (semanticIcon) return semanticIcon;
82
+ if (process.env.NODE_ENV !== "production") {
83
+ console.warn(
84
+ `[iconMap] Unknown icon "${iconName}". Allowed legacy names: ${Object.keys(iconMap).join(", ")}. Semantic action/status tokens are also supported.`
85
+ );
781
86
  }
782
- return icon || null;
87
+ return null;
783
88
  }
784
89
  function resolveDefaultValue(context, path) {
785
90
  if (!context || typeof context !== "object") return void 0;
@@ -1305,20 +610,6 @@ function AgentDefinitionDisplay({ agent, defaultExpanded = false }) {
1305
610
  }
1306
611
  ]
1307
612
  }
1308
- ),
1309
- /* @__PURE__ */ jsx(
1310
- ConfigCard,
1311
- {
1312
- icon: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 14 }),
1313
- title: "Execution Interface",
1314
- color: "teal",
1315
- items: [
1316
- {
1317
- label: "Has Interface",
1318
- value: agent.interface ? /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "green", children: "Yes" }) : /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "gray", children: "No" })
1319
- }
1320
- ]
1321
- }
1322
613
  )
1323
614
  ] }),
1324
615
  /* @__PURE__ */ jsx("div", { style: { paddingLeft: "var(--mantine-spacing-xl)", marginTop: "var(--mantine-spacing-sm)" }, children: /* @__PURE__ */ jsx(ContractDisplay, { contract: agent.contract, defaultExpanded }) })
@@ -1437,36 +728,20 @@ function WorkflowDefinitionDisplay({ workflow, defaultExpanded = false }) {
1437
728
  }
1438
729
  ),
1439
730
  /* @__PURE__ */ jsxs(Collapse, { in: configExpanded, children: [
1440
- /* @__PURE__ */ jsxs(SimpleGrid, { cols: 2, spacing: "sm", mt: "xs", pl: "xl", children: [
1441
- /* @__PURE__ */ jsx(
1442
- ConfigCard,
1443
- {
1444
- icon: /* @__PURE__ */ jsx(IconVersions, { size: 14 }),
1445
- title: "Version",
1446
- color: "grape",
1447
- items: [
1448
- {
1449
- label: "Version",
1450
- value: /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", children: workflow.config.version })
1451
- }
1452
- ]
1453
- }
1454
- ),
1455
- /* @__PURE__ */ jsx(
1456
- ConfigCard,
1457
- {
1458
- icon: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 14 }),
1459
- title: "Execution Interface",
1460
- color: "teal",
1461
- items: [
1462
- {
1463
- label: "Has Interface",
1464
- value: workflow.interface ? /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "green", children: "Yes" }) : /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "gray", children: "No" })
1465
- }
1466
- ]
1467
- }
1468
- )
1469
- ] }),
731
+ /* @__PURE__ */ jsx("div", { style: { paddingLeft: "var(--mantine-spacing-xl)" }, children: /* @__PURE__ */ jsx(
732
+ ConfigCard,
733
+ {
734
+ icon: /* @__PURE__ */ jsx(IconVersions, { size: 14 }),
735
+ title: "Version",
736
+ color: "grape",
737
+ items: [
738
+ {
739
+ label: "Version",
740
+ value: /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", children: workflow.config.version })
741
+ }
742
+ ]
743
+ }
744
+ ) }),
1470
745
  /* @__PURE__ */ jsx("div", { style: { paddingLeft: "var(--mantine-spacing-xl)", marginTop: "var(--mantine-spacing-sm)" }, children: /* @__PURE__ */ jsx(ContractDisplay, { contract: workflow.contract, defaultExpanded }) })
1471
746
  ] })
1472
747
  ] }) });
@@ -3441,174 +2716,12 @@ function ResourceNotFoundState2({ type, resourceId, onNavigateBack }) {
3441
2716
  /* @__PURE__ */ jsx(Button, { variant: "light", leftSection: /* @__PURE__ */ jsx(IconArrowLeft, { size: 16 }), onClick: handleBack, children: "Back to Operations" })
3442
2717
  ] }) }) });
3443
2718
  }
3444
- function ExecuteWorkflowModal({
3445
- opened,
3446
- onClose,
3447
- resource,
3448
- isPending = false,
3449
- error,
3450
- result,
3451
- onViewExecution,
3452
- onReset,
3453
- children
3454
- }) {
3455
- const canClose = !isPending;
3456
- const title = resource.name ?? resource.resourceId;
3457
- return /* @__PURE__ */ jsx(
3458
- Modal,
3459
- {
3460
- opened,
3461
- onClose: canClose ? onClose : () => void 0,
3462
- centered: true,
3463
- size: "lg",
3464
- closeOnClickOutside: canClose,
3465
- closeOnEscape: canClose,
3466
- withCloseButton: canClose,
3467
- title: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
3468
- /* @__PURE__ */ jsxs(Text, { fw: 600, children: [
3469
- "Run ",
3470
- resource.resourceType
3471
- ] }),
3472
- /* @__PURE__ */ jsx(Badge, { color: "blue", variant: "light", size: "sm", children: resource.resourceType })
3473
- ] }),
3474
- children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
3475
- /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", children: [
3476
- /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Target:" }),
3477
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, children: title }),
3478
- /* @__PURE__ */ jsx(Code, { children: resource.resourceId })
3479
- ] }),
3480
- /* @__PURE__ */ jsx(Divider, {}),
3481
- result ? /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
3482
- /* @__PURE__ */ jsx(Alert, { variant: "light", color: "teal", title: "Execution started", icon: /* @__PURE__ */ jsx(IconCheck, { size: 16 }), children: /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
3483
- /* @__PURE__ */ jsxs(Text, { size: "sm", children: [
3484
- "The ",
3485
- resource.resourceType,
3486
- " is now running."
3487
- ] }),
3488
- /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
3489
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Execution ID:" }),
3490
- /* @__PURE__ */ jsx(Code, { children: result.executionId })
3491
- ] })
3492
- ] }) }),
3493
- /* @__PURE__ */ jsxs(Group, { justify: "flex-end", gap: "xs", children: [
3494
- onReset && /* @__PURE__ */ jsx(Button, { variant: "default", onClick: onReset, children: "Run again" }),
3495
- onViewExecution && /* @__PURE__ */ jsx(
3496
- Button,
3497
- {
3498
- leftSection: /* @__PURE__ */ jsx(IconExternalLink, { size: 16 }),
3499
- onClick: () => onViewExecution(result.executionId),
3500
- children: "View execution"
3501
- }
3502
- ),
3503
- /* @__PURE__ */ jsx(Button, { variant: "light", onClick: onClose, children: "Close" })
3504
- ] })
3505
- ] }) : error ? /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
3506
- /* @__PURE__ */ jsx(Alert, { variant: "light", color: "red", title: "Execution failed to start", icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), children: /* @__PURE__ */ jsx(Text, { size: "sm", children: error.message || "An unknown error occurred." }) }),
3507
- /* @__PURE__ */ jsxs(Group, { justify: "flex-end", gap: "xs", children: [
3508
- onReset && /* @__PURE__ */ jsx(Button, { variant: "default", onClick: onReset, children: "Try again" }),
3509
- /* @__PURE__ */ jsx(Button, { variant: "light", onClick: onClose, children: "Close" })
3510
- ] })
3511
- ] }) : /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
3512
- /* @__PURE__ */ jsx(LoadingOverlay, { visible: isPending, zIndex: 1e3, overlayProps: { blur: 2 } }),
3513
- children ?? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No input form provided." })
3514
- ] })
3515
- ] })
3516
- }
3517
- );
3518
- }
3519
- function getInitialValues(fields) {
3520
- const values = {};
3521
- for (const field of fields) {
3522
- values[field.name] = field.defaultValue ?? (field.type === "checkbox" ? false : "");
3523
- }
3524
- return values;
3525
- }
3526
- function applyFieldMappings(values, mappings) {
3527
- if (!mappings) return values;
3528
- const mapped = {};
3529
- for (const [key, value] of Object.entries(values)) {
3530
- const targetKey = mappings[key] ?? key;
3531
- mapped[targetKey] = value;
3532
- }
3533
- return mapped;
3534
- }
3535
- function ResourceExecuteForm({
3536
- formSchema,
3537
- onSubmit,
3538
- isPending = false,
3539
- disabled = false,
3540
- submitLabel = "Run"
3541
- }) {
3542
- const hasFields = formSchema?.fields?.length > 0;
3543
- const form = useForm({
3544
- initialValues: hasFields ? getInitialValues(formSchema.fields) : {},
3545
- validate: hasFields ? Object.fromEntries(
3546
- formSchema.fields.filter((f) => f.required).map((f) => [
3547
- f.name,
3548
- (value) => !value && value !== false ? `${f.label} is required` : null
3549
- ])
3550
- ) : {}
3551
- });
3552
- const handleSubmit = (values) => {
3553
- const input = applyFieldMappings(values, formSchema?.fieldMappings);
3554
- void onSubmit(input);
3555
- };
3556
- if (!hasFields) {
3557
- return /* @__PURE__ */ jsxs(Stack, { children: [
3558
- /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "This workflow takes no input." }),
3559
- /* @__PURE__ */ jsx(Button, { onClick: () => void onSubmit({}), loading: isPending, disabled, fullWidth: true, children: isPending ? formSchema?.submitButton?.loadingLabel ?? "Running..." : submitLabel })
3560
- ] });
3561
- }
3562
- return /* @__PURE__ */ jsx("form", { onSubmit: form.onSubmit(handleSubmit), children: /* @__PURE__ */ jsxs(Stack, { children: [
3563
- formSchema.fields.map((field) => /* @__PURE__ */ jsx(FormFieldRenderer, { field, form }, field.name)),
3564
- /* @__PURE__ */ jsx(Button, { type: "submit", loading: isPending, disabled, fullWidth: true, children: isPending ? formSchema.submitButton?.loadingLabel ?? "Running..." : submitLabel })
3565
- ] }) });
3566
- }
3567
- function ResourceExecuteDialog({ opened, onClose, resource, onViewExecution }) {
3568
- const mutation = useExecuteAsync();
3569
- const handleSubmit = async (input) => {
3570
- await mutation.mutateAsync({
3571
- resourceId: resource.resourceId,
3572
- resourceType: resource.resourceType,
3573
- input
3574
- });
3575
- };
3576
- const handleReset = () => {
3577
- mutation.reset();
3578
- };
3579
- const modalResource = {
3580
- resourceId: resource.resourceId,
3581
- resourceType: resource.resourceType,
3582
- name: resource.name
3583
- };
3584
- return /* @__PURE__ */ jsx(
3585
- ExecuteWorkflowModal,
3586
- {
3587
- opened,
3588
- onClose,
3589
- resource: modalResource,
3590
- isPending: mutation.isPending,
3591
- error: mutation.error,
3592
- result: mutation.data ?? null,
3593
- onViewExecution,
3594
- onReset: handleReset,
3595
- children: /* @__PURE__ */ jsx(
3596
- ResourceExecuteForm,
3597
- {
3598
- formSchema: resource.formSchema ?? { fields: [] },
3599
- onSubmit: handleSubmit,
3600
- isPending: mutation.isPending,
3601
- disabled: mutation.isPending
3602
- }
3603
- )
3604
- }
3605
- );
3606
- }
3607
2719
  function ResourceDetailPage({
3608
2720
  type,
3609
2721
  resourceId,
3610
2722
  timeRange,
3611
2723
  renderExecutionPanel,
2724
+ renderExecuteDialog,
3612
2725
  onNavigateToResources,
3613
2726
  onNavigateToSessions,
3614
2727
  onNavigateBack
@@ -3644,19 +2757,13 @@ function ResourceDetailPage({
3644
2757
  const validResource = resource;
3645
2758
  const sessionCapable = isSessionCapable(type, resourceDefinition);
3646
2759
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3647
- /* @__PURE__ */ jsx(
3648
- ResourceExecuteDialog,
3649
- {
3650
- opened: runOpened,
3651
- onClose: () => setRunOpened(false),
3652
- resource: {
3653
- resourceId,
3654
- resourceType: type,
3655
- name: validResource.name,
3656
- formSchema: resourceDefinition?.interface?.form
3657
- }
3658
- }
3659
- ),
2760
+ renderExecuteDialog({
2761
+ opened: runOpened,
2762
+ onClose: () => setRunOpened(false),
2763
+ resourceId,
2764
+ resourceType: type,
2765
+ name: validResource.name
2766
+ }),
3660
2767
  /* @__PURE__ */ jsxs(Stack, { children: [
3661
2768
  /* @__PURE__ */ jsx(
3662
2769
  ResourceHeader,
@@ -4265,2534 +3372,74 @@ function CommandQueueDetailPage({
4265
3372
  ] }) })
4266
3373
  ] });
4267
3374
  }
4268
-
4269
- // src/features/operations/organization-graph/organizationGraphDetail.ts
4270
- var NODE_KIND_LABELS = {
4271
- organization: "Organization root",
4272
- feature: "Feature",
4273
- surface: "Surface",
4274
- entity: "Entity",
4275
- capability: "Capability",
4276
- resource: "Resource",
4277
- knowledge: "Knowledge"
4278
- };
4279
- var NODE_KIND_MEANINGS = {
4280
- organization: "The root of the shared organization model and the parent for every derived node.",
4281
- feature: "A feature that enables or disables downstream surfaces and model surfaces.",
4282
- surface: "A user-facing or operational surface that exposes feature behavior in the model.",
4283
- entity: "A shared business concept that can be referenced by surfaces, resources, or capabilities.",
4284
- capability: "A reusable capability that can be attached to a feature or surface.",
4285
- resource: "A concrete command-view or mapped resource that bridges execution topology into the model.",
4286
- knowledge: "An operational knowledge node that documents a process, strategy, or runbook in the org model."
4287
- };
4288
- var EDGE_KIND_LABELS = {
4289
- contains: "Containment",
4290
- references: "Reference",
4291
- exposes: "Exposure",
4292
- maps_to: "Mapping",
4293
- "operates-on": "Operates on",
4294
- uses: "Uses",
4295
- governs: "Governs"
4296
- };
4297
- var EDGE_KIND_MEANINGS = {
4298
- contains: "A hierarchy or ownership link inside the shared graph.",
4299
- references: "A semantic association or dependency between two graph nodes.",
4300
- exposes: "A feature enables a surface to be visible or reachable.",
4301
- maps_to: "A concrete resource is aligned to a domain, entity, capability, or surface.",
4302
- "operates-on": "A concrete resource operates on an Organization Model node.",
4303
- uses: "A concrete resource depends on another graph node or integration.",
4304
- governs: "A knowledge node governs or provides authoritative guidance for another node."
4305
- };
4306
- var RELATIONSHIP_MEANINGS = {
4307
- triggers: "Executable handoff: the source resource starts the target resource.",
4308
- uses: "Operational dependency: the source resource relies on the target integration.",
4309
- approval: "Human gate: the source resource pauses for approval at the target checkpoint."
3375
+ var cellStyle = {
3376
+ padding: "var(--mantine-spacing-sm) var(--mantine-spacing-md)",
3377
+ display: "flex",
3378
+ alignItems: "center",
3379
+ gap: "var(--mantine-spacing-sm)",
3380
+ minWidth: 0
4310
3381
  };
4311
- function titleCase(value) {
4312
- return value.replace(/[-_.]+/g, " ").replace(/\s+/g, " ").trim().split(" ").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
4313
- }
4314
- function getGraphIndex(graph) {
4315
- const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));
4316
- const edgesById = new Map(graph.edges.map((edge) => [edge.id, edge]));
4317
- return { nodesById, edgesById };
4318
- }
4319
- function getNodeKindLabel(kind) {
4320
- return NODE_KIND_LABELS[kind];
4321
- }
4322
- function getNodeMeaning(node) {
4323
- const baseMeaning = NODE_KIND_MEANINGS[node.kind];
4324
- if (node.kind === "feature") {
4325
- return node.enabled === false ? `${baseMeaning} This feature is currently disabled in the organization model.` : `${baseMeaning} This feature is currently enabled in the organization model.`;
4326
- }
4327
- if (node.kind === "resource" && node.resourceType) {
4328
- return `${baseMeaning} Resource type: ${titleCase(node.resourceType)}.`;
4329
- }
4330
- if (node.description) {
4331
- return `${baseMeaning} ${node.description}`;
4332
- }
4333
- return baseMeaning;
4334
- }
4335
- function getEdgeKindLabel(kind) {
4336
- return EDGE_KIND_LABELS[kind];
4337
- }
4338
- function getEdgeMeaning(edge, sourceNode, targetNode) {
4339
- const sourceLabel = sourceNode?.label ?? edge.sourceId;
4340
- const targetLabel = targetNode?.label ?? edge.targetId;
4341
- if (edge.relationshipType) {
4342
- const relationshipMeaning = RELATIONSHIP_MEANINGS[edge.relationshipType];
4343
- return `${relationshipMeaning} The graph renders the link from ${sourceLabel} to ${targetLabel} as a ${getEdgeKindLabel(edge.kind).toLowerCase()} edge.`;
4344
- }
4345
- return `${EDGE_KIND_MEANINGS[edge.kind]} This link connects ${sourceLabel} to ${targetLabel}.`;
4346
- }
4347
- function countByKind(nodes) {
4348
- const counts = /* @__PURE__ */ new Map();
4349
- for (const node of nodes) {
4350
- counts.set(node.kind, (counts.get(node.kind) ?? 0) + 1);
4351
- }
4352
- return [...counts.entries()].map(([kind, count]) => ({
4353
- kind,
4354
- label: getNodeKindLabel(kind),
4355
- count
4356
- })).sort((left, right) => left.label.localeCompare(right.label));
4357
- }
4358
- function uniqueNodesById(nodes) {
4359
- const byId = /* @__PURE__ */ new Map();
4360
- for (const node of nodes) {
4361
- byId.set(node.id, node);
4362
- }
4363
- return [...byId.values()];
4364
- }
4365
- function uniqueEdgesById(edges) {
4366
- const byId = /* @__PURE__ */ new Map();
4367
- for (const edge of edges) {
4368
- byId.set(edge.id, edge);
4369
- }
4370
- return [...byId.values()];
4371
- }
4372
- function buildNodeState(graph, node, nodesById) {
4373
- const incidentEdges = graph.edges.filter((edge) => edge.sourceId === node.id || edge.targetId === node.id);
4374
- const incomingEdges = incidentEdges.filter((edge) => edge.targetId === node.id);
4375
- const outgoingEdges = incidentEdges.filter((edge) => edge.sourceId === node.id);
4376
- const adjacentNodes = uniqueNodesById(
4377
- incidentEdges.map((edge) => edge.sourceId === node.id ? nodesById.get(edge.targetId) : nodesById.get(edge.sourceId)).filter((value) => Boolean(value))
4378
- );
4379
- const relatedNodes = adjacentNodes.slice().sort((left, right) => left.label.localeCompare(right.label)).map((adjacentNode) => {
4380
- const contexts = incidentEdges.filter(
4381
- (edge) => edge.sourceId === node.id ? edge.targetId === adjacentNode.id : edge.sourceId === adjacentNode.id
4382
- ).map(
4383
- (edge) => `${edge.sourceId === node.id ? "outgoing" : "incoming"} via ${edge.label ?? getEdgeKindLabel(edge.kind).toLowerCase()}`
4384
- );
4385
- return {
4386
- id: adjacentNode.id,
4387
- label: adjacentNode.label,
4388
- kind: adjacentNode.kind,
4389
- kindLabel: getNodeKindLabel(adjacentNode.kind),
4390
- context: contexts.slice(0, 2).join(", ")
4391
- };
4392
- });
4393
- const relatedEdges = incidentEdges.slice().sort((left, right) => left.id.localeCompare(right.id)).map((edge) => {
4394
- const connectedId = edge.sourceId === node.id ? edge.targetId : edge.sourceId;
4395
- const connectedNode = nodesById.get(connectedId);
4396
- return {
4397
- id: edge.id,
4398
- label: edge.label ?? edge.relationshipType ?? getEdgeKindLabel(edge.kind),
4399
- kind: edge.kind,
4400
- kindLabel: getEdgeKindLabel(edge.kind),
4401
- context: `${edge.sourceId === node.id ? "outgoing" : "incoming"}${connectedNode ? ` to ${connectedNode.label}` : ""}`
4402
- };
4403
- });
4404
- const metadata = [
4405
- { label: "Graph ID", value: node.id },
4406
- { label: "Source ID", value: node.sourceId ?? node.id },
4407
- { label: "Kind", value: getNodeKindLabel(node.kind) }
4408
- ];
4409
- if (node.enabled !== void 0) {
4410
- metadata.push({ label: "Enabled", value: node.enabled ? "Yes" : "No" });
4411
- }
4412
- if (node.featureId) {
4413
- metadata.push({ label: "Feature ID", value: node.featureId });
4414
- }
4415
- if (node.resourceType) {
4416
- metadata.push({ label: "Resource Type", value: titleCase(node.resourceType) });
4417
- }
4418
- const meaningfulEdges = incidentEdges.filter((edge) => edge.kind !== "contains" || edge.relationshipType);
4419
- return {
4420
- state: "node",
4421
- title: node.label,
4422
- semanticCategory: getNodeKindLabel(node.kind),
4423
- operationalMeaning: getNodeMeaning(node),
4424
- description: node.description,
4425
- metrics: [
4426
- {
4427
- label: "Connected edges",
4428
- value: String(incidentEdges.length),
4429
- hint: "All direct relationships attached to this node"
4430
- },
4431
- { label: "Incoming", value: String(incomingEdges.length), hint: "Edges that point into this node" },
4432
- { label: "Outgoing", value: String(outgoingEdges.length), hint: "Edges that start at this node" },
4433
- {
4434
- label: "Meaningful links",
4435
- value: String(meaningfulEdges.length),
4436
- hint: "Edges with semantic or operational meaning"
4437
- }
4438
- ],
4439
- metadata,
4440
- adjacentKindCounts: countByKind(adjacentNodes),
4441
- node,
4442
- relatedNodes,
4443
- relatedEdges
4444
- };
4445
- }
4446
- function buildEdgeState(graph, edge, nodesById) {
4447
- const sourceNode = nodesById.get(edge.sourceId);
4448
- const targetNode = nodesById.get(edge.targetId);
4449
- const sourceIncidentEdges = graph.edges.filter(
4450
- (candidate) => candidate.sourceId === edge.sourceId || candidate.targetId === edge.sourceId
4451
- );
4452
- const targetIncidentEdges = graph.edges.filter(
4453
- (candidate) => candidate.sourceId === edge.targetId || candidate.targetId === edge.targetId
4454
- );
4455
- const adjacentNodes = uniqueNodesById(
4456
- [...sourceIncidentEdges, ...targetIncidentEdges].map((candidate) => {
4457
- if (candidate.sourceId === edge.sourceId) return nodesById.get(candidate.targetId);
4458
- if (candidate.targetId === edge.sourceId) return nodesById.get(candidate.sourceId);
4459
- if (candidate.sourceId === edge.targetId) return nodesById.get(candidate.targetId);
4460
- if (candidate.targetId === edge.targetId) return nodesById.get(candidate.sourceId);
4461
- return null;
4462
- }).filter((value) => Boolean(value)).filter((candidate) => candidate.id !== edge.sourceId && candidate.id !== edge.targetId)
4463
- );
4464
- const sourceNeighborIds = new Set(
4465
- sourceIncidentEdges.map((candidate) => {
4466
- if (candidate.sourceId === edge.sourceId) return candidate.targetId;
4467
- if (candidate.targetId === edge.sourceId) return candidate.sourceId;
4468
- return null;
4469
- }).filter((value) => Boolean(value))
4470
- );
4471
- const targetNeighborIds = new Set(
4472
- targetIncidentEdges.map((candidate) => {
4473
- if (candidate.sourceId === edge.targetId) return candidate.targetId;
4474
- if (candidate.targetId === edge.targetId) return candidate.sourceId;
4475
- return null;
4476
- }).filter((value) => Boolean(value))
4477
- );
4478
- const sharedNeighborCount = [...sourceNeighborIds].filter((neighborId) => targetNeighborIds.has(neighborId)).length;
4479
- const relatedNodes = adjacentNodes.slice().sort((left, right) => left.label.localeCompare(right.label)).map((adjacentNode) => {
4480
- const sourceContext = sourceIncidentEdges.some(
4481
- (candidate) => candidate.sourceId === edge.sourceId && candidate.targetId === adjacentNode.id || candidate.targetId === edge.sourceId && candidate.sourceId === adjacentNode.id
4482
- );
4483
- const targetContext = targetIncidentEdges.some(
4484
- (candidate) => candidate.sourceId === edge.targetId && candidate.targetId === adjacentNode.id || candidate.targetId === edge.targetId && candidate.sourceId === adjacentNode.id
4485
- );
4486
- const contextParts = [];
4487
- if (sourceContext) contextParts.push("source neighborhood");
4488
- if (targetContext) contextParts.push("target neighborhood");
4489
- return {
4490
- id: adjacentNode.id,
4491
- label: adjacentNode.label,
4492
- kind: adjacentNode.kind,
4493
- kindLabel: getNodeKindLabel(adjacentNode.kind),
4494
- context: contextParts.join(" + ")
4495
- };
4496
- });
4497
- const surroundingEdges = uniqueEdgesById([...sourceIncidentEdges, ...targetIncidentEdges]).filter((candidate) => candidate.id !== edge.id).sort((left, right) => left.id.localeCompare(right.id)).map((candidate) => {
4498
- const leftNode = nodesById.get(candidate.sourceId);
4499
- const rightNode = nodesById.get(candidate.targetId);
4500
- return {
4501
- id: candidate.id,
4502
- label: candidate.label ?? candidate.relationshipType ?? getEdgeKindLabel(candidate.kind),
4503
- kind: candidate.kind,
4504
- kindLabel: getEdgeKindLabel(candidate.kind),
4505
- context: `${leftNode?.label ?? candidate.sourceId} -> ${rightNode?.label ?? candidate.targetId}`
4506
- };
4507
- });
4508
- const metadata = [
4509
- { label: "Graph ID", value: edge.id },
4510
- { label: "Source ID", value: edge.sourceId },
4511
- { label: "Target ID", value: edge.targetId },
4512
- { label: "Edge kind", value: getEdgeKindLabel(edge.kind) }
4513
- ];
4514
- if (edge.label) {
4515
- metadata.push({ label: "Label", value: edge.label });
4516
- }
4517
- if (edge.relationshipType) {
4518
- metadata.push({ label: "Relationship", value: titleCase(edge.relationshipType) });
4519
- }
4520
- return {
4521
- state: "edge",
4522
- title: edge.label ?? `${sourceNode?.label ?? edge.sourceId} \u2192 ${targetNode?.label ?? edge.targetId}`,
4523
- semanticCategory: edge.relationshipType ? titleCase(edge.relationshipType) : getEdgeKindLabel(edge.kind),
4524
- operationalMeaning: getEdgeMeaning(edge, sourceNode, targetNode),
4525
- description: edge.label,
4526
- metrics: [
4527
- {
4528
- label: "Source degree",
4529
- value: String(sourceIncidentEdges.length),
4530
- hint: "Relationships attached to the source node"
4531
- },
4532
- {
4533
- label: "Target degree",
4534
- value: String(targetIncidentEdges.length),
4535
- hint: "Relationships attached to the target node"
4536
- },
4537
- {
4538
- label: "Nearby nodes",
4539
- value: String(adjacentNodes.length),
4540
- hint: "Unique nodes in the source and target neighborhoods"
4541
- },
4542
- {
4543
- label: "Shared peers",
4544
- value: String(sharedNeighborCount),
4545
- hint: "Neighbors that appear in both node neighborhoods"
4546
- }
4547
- ],
4548
- metadata,
4549
- adjacentKindCounts: countByKind(adjacentNodes),
4550
- edge,
4551
- sourceNode,
4552
- targetNode,
4553
- relatedNodes,
4554
- relatedEdges: surroundingEdges
4555
- };
4556
- }
4557
- function getOrganizationGraphDetailState(graph, selectedElement) {
4558
- if (!selectedElement) {
4559
- return {
4560
- state: "empty",
4561
- title: "No element selected",
4562
- semanticCategory: "Selection",
4563
- operationalMeaning: "Select a node or edge to inspect its semantic and operational context.",
4564
- metrics: [],
4565
- metadata: [],
4566
- adjacentKindCounts: []
4567
- };
4568
- }
4569
- if (!graph) {
4570
- return {
4571
- state: "missing",
4572
- title: "Graph unavailable",
4573
- semanticCategory: selectedElement.type === "node" ? "Selected node" : "Selected edge",
4574
- operationalMeaning: "The graph data is not available yet, so this selection cannot be resolved.",
4575
- metrics: [],
4576
- metadata: [{ label: "Selected ID", value: selectedElement.id }],
4577
- adjacentKindCounts: [],
4578
- missingId: selectedElement.id
4579
- };
4580
- }
4581
- const { nodesById, edgesById } = getGraphIndex(graph);
4582
- if (selectedElement.type === "node") {
4583
- const node = nodesById.get(selectedElement.id);
4584
- if (!node) {
4585
- return {
4586
- state: "missing",
4587
- title: "Selected node unavailable",
4588
- semanticCategory: "Node",
4589
- operationalMeaning: "The selected node is no longer present in the current graph build.",
4590
- metrics: [],
4591
- metadata: [{ label: "Selected ID", value: selectedElement.id }],
4592
- adjacentKindCounts: [],
4593
- missingId: selectedElement.id
4594
- };
4595
- }
4596
- return buildNodeState(graph, node, nodesById);
4597
- }
4598
- const edge = edgesById.get(selectedElement.id);
4599
- if (!edge) {
4600
- return {
4601
- state: "missing",
4602
- title: "Selected edge unavailable",
4603
- semanticCategory: "Edge",
4604
- operationalMeaning: "The selected edge is no longer present in the current graph build.",
4605
- metrics: [],
4606
- metadata: [{ label: "Selected ID", value: selectedElement.id }],
4607
- adjacentKindCounts: [],
4608
- missingId: selectedElement.id
4609
- };
4610
- }
4611
- return buildEdgeState(graph, edge, nodesById);
4612
- }
4613
- function getNodeKindColor(kind) {
4614
- switch (kind) {
4615
- case "organization":
4616
- return "gray";
4617
- case "feature":
4618
- return "blue";
4619
- case "domain":
4620
- return "violet";
4621
- case "surface":
4622
- return "cyan";
4623
- case "entity":
4624
- return "pink";
4625
- case "capability":
4626
- return "green";
4627
- case "resource":
4628
- return "orange";
4629
- default:
4630
- return "gray";
4631
- }
4632
- }
4633
- function getEdgeKindColor(kind) {
4634
- switch (kind) {
4635
- case "contains":
4636
- return "gray";
4637
- case "references":
4638
- return "cyan";
4639
- case "exposes":
4640
- return "blue";
4641
- case "maps_to":
4642
- return "violet";
4643
- default:
4644
- return "gray";
4645
- }
4646
- }
4647
- function getNodeKindLabel2(kind) {
4648
- switch (kind) {
4649
- case "organization":
4650
- return "Organization root";
4651
- case "feature":
4652
- return "Feature gate";
4653
- case "domain":
4654
- return "Domain boundary";
4655
- case "surface":
4656
- return "Surface";
4657
- case "entity":
4658
- return "Entity";
4659
- case "capability":
4660
- return "Capability";
4661
- case "resource":
4662
- return "Resource";
4663
- default:
4664
- return kind;
4665
- }
4666
- }
4667
- function titleCase2(value) {
4668
- return value.charAt(0).toUpperCase() + value.slice(1);
4669
- }
4670
- function MetricCard({ metric }) {
4671
- return /* @__PURE__ */ jsx(Card, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
4672
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, c: "dimmed", children: metric.label }),
4673
- /* @__PURE__ */ jsx(Text, { size: "lg", fw: 800, children: metric.value }),
4674
- metric.hint ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: metric.hint }) : null
4675
- ] }) });
4676
- }
4677
- function RelatedItemCard({ item, itemType }) {
4678
- const badgeColor = itemType === "node" ? getNodeKindColor(item.kind) : getEdgeKindColor(item.kind);
4679
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
4680
- /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", align: "flex-start", children: [
4681
- /* @__PURE__ */ jsx(Text, { fw: 700, size: "sm", style: { lineHeight: 1.2 }, children: item.label }),
4682
- /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: badgeColor, children: item.kindLabel })
4683
- ] }),
4684
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: item.context }),
4685
- /* @__PURE__ */ jsx(Text, { size: "xs", ff: "monospace", c: "dimmed", children: item.id })
4686
- ] }) });
4687
- }
4688
- function getStatusColor3(value) {
4689
- switch (value) {
4690
- case "failed":
4691
- return "red";
4692
- case "warning":
4693
- return "yellow";
4694
- case "running":
4695
- case "processing":
4696
- return "blue";
4697
- case "completed":
4698
- return "green";
4699
- case "pending":
4700
- return "orange";
4701
- case "expired":
4702
- return "gray";
4703
- default:
4704
- return "gray";
4705
- }
4706
- }
4707
- function FollowUpSectionCard({ section }) {
4708
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
4709
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "flex-start", children: [
4710
- /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
4711
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, children: section.title }),
4712
- section.description ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: section.description }) : null
4713
- ] }),
4714
- section.primaryAction ? /* @__PURE__ */ jsx(
4715
- Button,
4716
- {
4717
- size: "xs",
4718
- variant: "light",
4719
- component: "a",
4720
- href: section.primaryAction.href,
4721
- target: "_blank",
4722
- rel: "noreferrer",
4723
- children: section.primaryAction.label
4724
- }
4725
- ) : null
4726
- ] }),
4727
- section.items.length > 0 ? /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, sm: 2 }, spacing: "sm", children: section.items.map((item) => /* @__PURE__ */ jsx(
4728
- Paper,
4729
- {
4730
- withBorder: true,
4731
- radius: "md",
4732
- p: "sm",
4733
- component: "a",
4734
- href: item.href,
4735
- target: "_blank",
4736
- rel: "noreferrer",
4737
- style: { display: "block", textDecoration: "none", color: "inherit" },
4738
- children: /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
4739
- /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", align: "flex-start", children: [
4740
- /* @__PURE__ */ jsx(Text, { fw: 700, size: "sm", style: { lineHeight: 1.2 }, children: item.label }),
4741
- item.badgeLabel ? /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: item.badgeColor ?? getStatusColor3(item.badgeLabel), children: item.badgeLabel }) : null
4742
- ] }),
4743
- item.description ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: item.description }) : null,
4744
- item.meta ? /* @__PURE__ */ jsx(Text, { size: "xs", ff: "monospace", c: "dimmed", children: item.meta }) : null
4745
- ] })
4746
- },
4747
- item.id
4748
- )) }) : /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: section.emptyMessage })
4749
- ] }) });
4750
- }
4751
- function OrganizationGraphDetailPanel({
4752
- graph,
4753
- selectedElement,
4754
- supplementalSummary,
4755
- followUpSections,
4756
- expandAroundPanel,
4757
- onClearSelection,
4758
- className
3382
+ function CommandViewHealthStrip({
3383
+ overview,
3384
+ hotspots,
3385
+ visibleResources,
3386
+ hiddenResources = 0,
3387
+ resourcesHidden,
3388
+ selectedLabel,
3389
+ onFocusHotspot,
3390
+ onResourcesHiddenChange,
3391
+ onResetFocus
4759
3392
  }) {
4760
- const state = getOrganizationGraphDetailState(graph, selectedElement);
4761
- if (state.state === "empty") {
4762
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "lg", p: "md", className, children: /* @__PURE__ */ jsx(EmptyState, { icon: IconShare2, title: state.title, description: state.operationalMeaning, py: "md" }) });
4763
- }
4764
- if (state.state === "missing") {
4765
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "lg", p: "md", className, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
4766
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "flex-start", children: [
4767
- /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
4768
- /* @__PURE__ */ jsx(Text, { fw: 800, size: "lg", children: state.title }),
4769
- /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: state.operationalMeaning })
4770
- ] }),
4771
- onClearSelection ? /* @__PURE__ */ jsx(Button, { size: "xs", variant: "subtle", onClick: onClearSelection, children: "Clear" }) : null
4772
- ] }),
4773
- /* @__PURE__ */ jsx(Badge, { variant: "light", color: "gray", children: state.semanticCategory }),
4774
- /* @__PURE__ */ jsxs(Paper, { withBorder: true, radius: "md", p: "sm", children: [
4775
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, c: "dimmed", children: "Selected ID" }),
4776
- /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", children: state.missingId })
4777
- ] })
4778
- ] }) });
4779
- }
4780
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "lg", p: "md", className, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
4781
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "flex-start", children: [
4782
- /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
4783
- /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
4784
- /* @__PURE__ */ jsx(Badge, { variant: "light", color: "violet", children: state.semanticCategory }),
4785
- state.state === "node" ? /* @__PURE__ */ jsx(Badge, { variant: "light", color: state.node.enabled === false ? "gray" : "green", children: state.node.enabled === false ? "Disabled" : "Enabled" }) : null,
4786
- state.state === "edge" && state.edge.relationshipType ? /* @__PURE__ */ jsx(Badge, { variant: "light", color: "orange", children: titleCase2(state.edge.relationshipType) }) : null
4787
- ] }),
4788
- /* @__PURE__ */ jsx(Text, { fw: 800, size: "lg", children: state.title }),
4789
- /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: state.operationalMeaning })
3393
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between" }, children: [
3394
+ /* @__PURE__ */ jsxs("div", { style: cellStyle, children: [
3395
+ /* @__PURE__ */ jsx(IconActivityHeartbeat, { size: 16, style: { flexShrink: 0, color: "var(--color-text-dimmed)" } }),
3396
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, style: { flexShrink: 0 }, children: overview?.successRate == null ? "N/A" : `${Math.round(overview.successRate)}%` }),
3397
+ /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", children: [
3398
+ /* @__PURE__ */ jsx(Badge, { variant: "light", color: "green", size: "xs", children: overview?.successCount ?? 0 }),
3399
+ /* @__PURE__ */ jsx(Badge, { variant: "light", color: "red", size: "xs", children: overview?.failureCount ?? 0 }),
3400
+ /* @__PURE__ */ jsx(Badge, { variant: "light", color: "yellow", size: "xs", children: overview?.warningCount ?? 0 })
4790
3401
  ] }),
4791
- onClearSelection ? /* @__PURE__ */ jsx(Button, { size: "xs", variant: "subtle", onClick: onClearSelection, children: "Clear" }) : null
3402
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", truncate: true, style: { flexShrink: 1, minWidth: 0 }, children: overview ? `${overview.totalRuns} runs / ${overview.trackedResources} resources` : "" })
4792
3403
  ] }),
4793
- /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 2, md: 4 }, spacing: "sm", children: state.metrics.map((metric) => /* @__PURE__ */ jsx(MetricCard, { metric }, metric.label)) }),
4794
- expandAroundPanel,
4795
- supplementalSummary && (supplementalSummary.metrics.length > 0 || supplementalSummary.metadata.length > 0) ? /* @__PURE__ */ jsxs(Fragment, { children: [
4796
- /* @__PURE__ */ jsx(
4797
- Divider,
4798
- {
4799
- label: /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
4800
- /* @__PURE__ */ jsx(IconTopologyStar3, { size: 14 }),
4801
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, children: supplementalSummary.title })
4802
- ] }),
4803
- labelPosition: "center"
4804
- }
4805
- ),
4806
- supplementalSummary.description ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: supplementalSummary.description }) : null,
4807
- supplementalSummary.metrics.length > 0 ? /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 2, md: 4 }, spacing: "sm", children: supplementalSummary.metrics.map((metric) => /* @__PURE__ */ jsx(MetricCard, { metric }, `supplemental-${metric.label}`)) }) : null,
4808
- supplementalSummary.metadata.length > 0 ? /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, sm: 2 }, spacing: "sm", children: supplementalSummary.metadata.map((item) => /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
4809
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, c: "dimmed", children: item.label }),
4810
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, children: item.value })
4811
- ] }) }, `supplemental-${item.label}`)) }) : null
4812
- ] }) : null,
4813
- followUpSections && followUpSections.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
4814
- /* @__PURE__ */ jsx(
4815
- Divider,
4816
- {
4817
- label: /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
4818
- /* @__PURE__ */ jsx(IconShare2, { size: 14 }),
4819
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, children: "Follow-up actions" })
4820
- ] }),
4821
- labelPosition: "center"
4822
- }
4823
- ),
4824
- /* @__PURE__ */ jsx(Stack, { gap: "sm", children: followUpSections.map((section) => /* @__PURE__ */ jsx(FollowUpSectionCard, { section }, section.title)) })
4825
- ] }) : null,
4826
- /* @__PURE__ */ jsx(
4827
- Divider,
4828
- {
4829
- label: /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
4830
- /* @__PURE__ */ jsx(IconTopologyStar3, { size: 14 }),
4831
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, children: "Linked metadata" })
4832
- ] }),
4833
- labelPosition: "center"
4834
- }
4835
- ),
4836
- /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, sm: 2 }, spacing: "sm", children: state.metadata.map((item) => /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
4837
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, c: "dimmed", children: item.label }),
4838
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, children: item.value })
4839
- ] }) }, item.label)) }),
4840
- state.adjacentKindCounts.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
4841
- /* @__PURE__ */ jsx(
4842
- Divider,
4843
- {
4844
- label: /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
4845
- /* @__PURE__ */ jsx(IconShare2, { size: 14 }),
4846
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, children: "Nearby kinds" })
4847
- ] }),
4848
- labelPosition: "center"
4849
- }
4850
- ),
4851
- /* @__PURE__ */ jsx(Group, { gap: "xs", children: state.adjacentKindCounts.map((item) => /* @__PURE__ */ jsxs(Badge, { variant: "light", color: getNodeKindColor(item.kind), children: [
4852
- item.count,
4853
- " ",
4854
- item.label
4855
- ] }, item.kind)) })
4856
- ] }) : null,
4857
- state.state === "edge" ? /* @__PURE__ */ jsxs(Fragment, { children: [
4858
- /* @__PURE__ */ jsx(
4859
- Divider,
3404
+ /* @__PURE__ */ jsxs("div", { style: cellStyle, children: [
3405
+ /* @__PURE__ */ jsx(IconAlertTriangle, { size: 16, style: { flexShrink: 0, color: "var(--color-text-dimmed)" } }),
3406
+ hotspots.length > 0 ? /* @__PURE__ */ jsx(Group, { gap: "xs", wrap: "nowrap", style: { minWidth: 0, overflow: "hidden" }, children: hotspots.map((hotspot) => /* @__PURE__ */ jsx(Group, { gap: 4, wrap: "nowrap", children: /* @__PURE__ */ jsx(
3407
+ Badge,
4860
3408
  {
4861
- label: /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
4862
- /* @__PURE__ */ jsx(IconShare2, { size: 14 }),
4863
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, children: "Endpoints" })
4864
- ] }),
4865
- labelPosition: "center"
4866
- }
4867
- ),
4868
- /* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, sm: 2 }, spacing: "sm", children: [
4869
- /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
4870
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, c: "dimmed", children: "Source" }),
4871
- /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
4872
- /* @__PURE__ */ jsx(Text, { fw: 700, children: state.sourceNode?.label ?? state.edge.sourceId }),
4873
- /* @__PURE__ */ jsx(
4874
- Badge,
4875
- {
4876
- size: "xs",
4877
- variant: "light",
4878
- color: state.sourceNode ? getNodeKindColor(state.sourceNode.kind) : "gray",
4879
- children: state.sourceNode ? getNodeKindLabel2(state.sourceNode.kind) : "unresolved"
4880
- }
4881
- )
4882
- ] })
4883
- ] }) }),
4884
- /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
4885
- /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, c: "dimmed", children: "Target" }),
4886
- /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
4887
- /* @__PURE__ */ jsx(Text, { fw: 700, children: state.targetNode?.label ?? state.edge.targetId }),
4888
- /* @__PURE__ */ jsx(
4889
- Badge,
4890
- {
4891
- size: "xs",
4892
- variant: "light",
4893
- color: state.targetNode ? getNodeKindColor(state.targetNode.kind) : "gray",
4894
- children: state.targetNode ? getNodeKindLabel2(state.targetNode.kind) : "unresolved"
4895
- }
4896
- )
4897
- ] })
4898
- ] }) })
4899
- ] })
4900
- ] }) : null,
4901
- /* @__PURE__ */ jsx(
4902
- Divider,
4903
- {
4904
- label: /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, children: state.state === "edge" ? "Surrounding nodes" : "Direct nodes" }),
4905
- labelPosition: "center"
4906
- }
4907
- ),
4908
- state.relatedNodes.length > 0 ? /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, sm: 2 }, spacing: "sm", children: state.relatedNodes.map((item) => /* @__PURE__ */ jsx(RelatedItemCard, { item, itemType: "node" }, item.id)) }) : /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No nearby nodes were found in the current graph selection." }),
4909
- /* @__PURE__ */ jsx(
4910
- Divider,
4911
- {
4912
- label: /* @__PURE__ */ jsx(Text, { size: "xs", tt: "uppercase", fw: 700, children: state.state === "edge" ? "Surrounding edges" : "Direct edges" }),
4913
- labelPosition: "center"
4914
- }
4915
- ),
4916
- state.relatedEdges.length > 0 ? /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, sm: 2 }, spacing: "sm", children: state.relatedEdges.map((item) => /* @__PURE__ */ jsx(RelatedItemCard, { item, itemType: "edge" }, item.id)) }) : /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No adjacent edges were found for the current selection." })
4917
- ] }) });
4918
- }
4919
-
4920
- // src/features/operations/organization-graph/types.ts
4921
- var ORGANIZATION_GRAPH_NODE_KIND_ORDER = [
4922
- "organization",
4923
- "feature",
4924
- "surface",
4925
- "entity",
4926
- "capability",
4927
- "resource",
4928
- "knowledge"
4929
- ];
4930
- var ORGANIZATION_GRAPH_NODE_KIND_LABELS = {
4931
- organization: "Organization",
4932
- feature: "Feature",
4933
- surface: "Surface",
4934
- entity: "Entity",
4935
- capability: "Capability",
4936
- resource: "Resource",
4937
- knowledge: "Knowledge"
4938
- };
4939
- var DEFAULT_ORGANIZATION_GRAPH_FILTERS = {
4940
- search: "",
4941
- nodeKinds: [],
4942
- topologyPresence: "all",
4943
- environmentStatus: "all",
4944
- resourceTypes: [],
4945
- showIntegrations: true,
4946
- domainFilters: {}
4947
- };
4948
-
4949
- // src/features/operations/organization-graph/helpers.ts
4950
- var TOPLOGY_EDGE_TYPES = /* @__PURE__ */ new Set(["maps_to", "triggers", "uses", "approval"]);
4951
- function getCommandViewNodes(data) {
4952
- return [
4953
- ...data.agents,
4954
- ...data.workflows,
4955
- ...data.triggers,
4956
- ...data.integrations,
4957
- ...data.externalResources,
4958
- ...data.humanCheckpoints
4959
- ];
4960
- }
4961
- function getCommandViewNodeForGraphNode(node, commandViewData) {
4962
- if (!commandViewData || node.kind !== "resource" || !node.sourceId) {
4963
- return null;
4964
- }
4965
- return getCommandViewNodes(commandViewData).find((item) => item.resourceId === node.sourceId) ?? null;
4966
- }
4967
- function normalizeText(value) {
4968
- return value.trim().toLowerCase();
4969
- }
4970
- function includesQuery(value, query) {
4971
- if (!value) return false;
4972
- return normalizeText(value).includes(query);
4973
- }
4974
- function titleCase3(value) {
4975
- return value.replace(/_/g, " ").split(" ").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
4976
- }
4977
- function isTopologyEdge(edge) {
4978
- return TOPLOGY_EDGE_TYPES.has(edge.kind) || Boolean(edge.relationshipType);
4979
- }
4980
- function isSemanticEdge(edge) {
4981
- return !isTopologyEdge(edge);
4982
- }
4983
- function getIncidentEdges(graph, nodeId2) {
4984
- return graph.edges.filter((edge) => edge.sourceId === nodeId2 || edge.targetId === nodeId2);
4985
- }
4986
- function createOrganizationGraphFilters(partial) {
4987
- return {
4988
- search: partial?.search ?? DEFAULT_ORGANIZATION_GRAPH_FILTERS.search,
4989
- nodeKinds: partial?.nodeKinds ? [...partial.nodeKinds] : [...DEFAULT_ORGANIZATION_GRAPH_FILTERS.nodeKinds],
4990
- topologyPresence: partial?.topologyPresence ?? DEFAULT_ORGANIZATION_GRAPH_FILTERS.topologyPresence,
4991
- environmentStatus: partial?.environmentStatus ?? DEFAULT_ORGANIZATION_GRAPH_FILTERS.environmentStatus,
4992
- resourceTypes: partial?.resourceTypes ? [...partial.resourceTypes] : [...DEFAULT_ORGANIZATION_GRAPH_FILTERS.resourceTypes],
4993
- showIntegrations: partial?.showIntegrations ?? DEFAULT_ORGANIZATION_GRAPH_FILTERS.showIntegrations,
4994
- domainFilters: partial?.domainFilters ? { ...partial.domainFilters } : { ...DEFAULT_ORGANIZATION_GRAPH_FILTERS.domainFilters }
4995
- };
4996
- }
4997
- function normalizeOrganizationGraphSearch(search) {
4998
- return search.trim().toLowerCase();
4999
- }
5000
- function getOrganizationGraphNodePresence(node, incidentEdges) {
5001
- if (node.kind === "resource") {
5002
- const relevantEdges = incidentEdges.filter((edge) => edge.kind !== "contains");
5003
- const hasTopologyEdges2 = relevantEdges.some(isTopologyEdge);
5004
- const hasSemanticEdges2 = relevantEdges.some(isSemanticEdge);
5005
- if (hasTopologyEdges2 && hasSemanticEdges2) {
5006
- return "bridge";
5007
- }
5008
- if (hasTopologyEdges2) {
5009
- return "topology-only";
5010
- }
5011
- return "semantic-only";
5012
- }
5013
- const hasTopologyEdges = incidentEdges.some(isTopologyEdge);
5014
- const hasSemanticEdges = incidentEdges.some(isSemanticEdge);
5015
- if (hasTopologyEdges && hasSemanticEdges) {
5016
- return "bridge";
5017
- }
5018
- if (hasTopologyEdges) {
5019
- return "topology-only";
5020
- }
5021
- return "semantic-only";
5022
- }
5023
- function getOrganizationGraphNodePresenceMap(graph) {
5024
- const presenceByNodeId = /* @__PURE__ */ new Map();
5025
- for (const node of graph.nodes) {
5026
- presenceByNodeId.set(node.id, getOrganizationGraphNodePresence(node, getIncidentEdges(graph, node.id)));
5027
- }
5028
- return presenceByNodeId;
5029
- }
5030
- function getOrganizationGraphNodeKindOptions(kinds = ORGANIZATION_GRAPH_NODE_KIND_ORDER) {
5031
- return kinds.map((kind) => ({
5032
- kind,
5033
- label: ORGANIZATION_GRAPH_NODE_KIND_LABELS[kind]
5034
- }));
5035
- }
5036
- function getOrganizationGraphResourceTypeOptions(resourceTypes = [
5037
- "workflow",
5038
- "agent",
5039
- "trigger",
5040
- "integration",
5041
- "external",
5042
- "human_checkpoint"
5043
- ]) {
5044
- return resourceTypes.map((resourceType) => ({
5045
- resourceType,
5046
- label: titleCase3(resourceType)
5047
- }));
5048
- }
5049
- function getNodeStatus(node, commandViewData) {
5050
- const commandViewNode = getCommandViewNodeForGraphNode(node, commandViewData);
5051
- if (commandViewNode) {
5052
- return commandViewNode.status;
5053
- }
5054
- return "status" in node && typeof node.status === "string" ? node.status : void 0;
5055
- }
5056
- function getExplicitNodeFacets(node, commandViewData) {
5057
- const commandViewNode = getCommandViewNodeForGraphNode(node, commandViewData);
5058
- if (commandViewNode) {
5059
- return [
5060
- ...commandViewNode.category ? [`category:${commandViewNode.category}`] : [],
5061
- ...commandViewNode.links?.map((link) => link.nodeId) ?? []
5062
- ];
5063
- }
5064
- return [];
5065
- }
5066
- function getNodeFacets(graph, node, commandViewData) {
5067
- const explicitFacets = getExplicitNodeFacets(node, commandViewData);
5068
- if (explicitFacets.length > 0) {
5069
- return explicitFacets;
5070
- }
5071
- if (node.kind === "feature") {
5072
- return node.sourceId ? [node.sourceId] : [];
5073
- }
5074
- if (node.kind !== "resource") {
5075
- return [];
5076
- }
5077
- const facetIds = /* @__PURE__ */ new Set();
5078
- for (const edge of graph.edges) {
5079
- if (edge.sourceId !== node.id) {
5080
- continue;
5081
- }
5082
- const targetNode = graph.nodes.find((candidate) => candidate.id === edge.targetId);
5083
- if (targetNode?.kind === "feature" && targetNode.sourceId) {
5084
- facetIds.add(targetNode.id);
5085
- }
5086
- }
5087
- return [...facetIds];
5088
- }
5089
- function matchesOrganizationGraphNodeSearch(node, search) {
5090
- const query = normalizeOrganizationGraphSearch(search);
5091
- if (!query) return true;
5092
- const nodeStatus = getNodeStatus(node);
5093
- const nodeFacets = getExplicitNodeFacets(node);
5094
- return includesQuery(node.id, query) || includesQuery(node.label, query) || includesQuery(node.description, query) || includesQuery(node.sourceId, query) || includesQuery(node.featureId, query) || includesQuery(node.resourceType, query) || includesQuery(nodeStatus, query) || nodeFacets.some((facet) => includesQuery(facet, query)) || includesQuery(node.kind, query);
5095
- }
5096
- function matchesOrganizationGraphEdgeSearch(edge, graph, search) {
5097
- const query = normalizeOrganizationGraphSearch(search);
5098
- if (!query) return true;
5099
- const sourceNode = graph.nodes.find((node) => node.id === edge.sourceId);
5100
- const targetNode = graph.nodes.find((node) => node.id === edge.targetId);
5101
- return includesQuery(edge.id, query) || includesQuery(edge.label, query) || includesQuery(edge.kind, query) || includesQuery(edge.relationshipType, query) || includesQuery(sourceNode?.label, query) || includesQuery(sourceNode?.sourceId, query) || includesQuery(targetNode?.label, query) || includesQuery(targetNode?.sourceId, query);
5102
- }
5103
- function matchesTopologyPresence(nodePresence, topologyPresence) {
5104
- if (topologyPresence === "all") return true;
5105
- return nodePresence === topologyPresence;
5106
- }
5107
- function hasActiveDomainFilters(domainFilters) {
5108
- return Object.values(domainFilters).some((filterState) => filterState !== "neutral");
5109
- }
5110
- function matchesDomainFilters(graph, node, domainFilters, commandViewData) {
5111
- if (!hasActiveDomainFilters(domainFilters)) {
5112
- return true;
5113
- }
5114
- const includedDomains = Object.entries(domainFilters).filter(([, filterState]) => filterState === "include").map(([domainId]) => domainId);
5115
- const excludedDomains = Object.entries(domainFilters).filter(([, filterState]) => filterState === "exclude").map(([domainId]) => domainId);
5116
- const nodeFacets = getNodeFacets(graph, node, commandViewData);
5117
- if (excludedDomains.length > 0 && nodeFacets.some((domainId) => excludedDomains.includes(domainId))) {
5118
- return false;
5119
- }
5120
- if (includedDomains.length > 0 && !nodeFacets.some((domainId) => includedDomains.includes(domainId))) {
5121
- return false;
5122
- }
5123
- return true;
5124
- }
5125
- function matchesEnvironmentStatus(node, environmentStatus, commandViewData) {
5126
- if (environmentStatus === "all") {
5127
- return true;
5128
- }
5129
- const nodeStatus = getNodeStatus(node, commandViewData);
5130
- if (!nodeStatus) {
5131
- return true;
5132
- }
5133
- return nodeStatus === environmentStatus;
5134
- }
5135
- function matchesResourceTypeFilters(node, resourceTypes) {
5136
- if (node.kind !== "resource" || resourceTypes.length === 0) {
5137
- return true;
5138
- }
5139
- return Boolean(node.resourceType && resourceTypes.includes(node.resourceType));
5140
- }
5141
- function matchesIntegrationVisibility(node, showIntegrations) {
5142
- if (showIntegrations) {
5143
- return true;
5144
- }
5145
- return !(node.kind === "resource" && node.resourceType === "integration");
5146
- }
5147
- function filterOrganizationGraph(graph, filters, options) {
5148
- const normalizedFilters = createOrganizationGraphFilters(filters);
5149
- const normalizedSearch = normalizeOrganizationGraphSearch(normalizedFilters.search);
5150
- const nodePresenceMap = getOrganizationGraphNodePresenceMap(graph);
5151
- const selectedKinds = new Set(normalizedFilters.nodeKinds);
5152
- const commandViewData = options?.commandViewData;
5153
- const visibleNodeIds = /* @__PURE__ */ new Set();
5154
- for (const node of graph.nodes) {
5155
- if (selectedKinds.size > 0 && !selectedKinds.has(node.kind)) {
5156
- continue;
5157
- }
5158
- if (!matchesIntegrationVisibility(node, normalizedFilters.showIntegrations)) {
5159
- continue;
5160
- }
5161
- if (!matchesResourceTypeFilters(node, normalizedFilters.resourceTypes)) {
5162
- continue;
5163
- }
5164
- if (!matchesEnvironmentStatus(node, normalizedFilters.environmentStatus, commandViewData)) {
5165
- continue;
5166
- }
5167
- if (!matchesDomainFilters(graph, node, normalizedFilters.domainFilters, commandViewData)) {
5168
- continue;
5169
- }
5170
- const presence = nodePresenceMap.get(node.id) ?? "semantic-only";
5171
- if (!matchesTopologyPresence(presence, normalizedFilters.topologyPresence)) {
5172
- continue;
5173
- }
5174
- if (normalizedSearch && !matchesOrganizationGraphNodeSearch(node, normalizedSearch)) {
5175
- const incidentEdges = getIncidentEdges(graph, node.id);
5176
- const edgeMatch = incidentEdges.some((edge) => matchesOrganizationGraphEdgeSearch(edge, graph, normalizedSearch));
5177
- if (!edgeMatch) {
5178
- continue;
5179
- }
5180
- }
5181
- visibleNodeIds.add(node.id);
5182
- }
5183
- const visibleEdges = graph.edges.filter((edge) => {
5184
- const sourceVisible = visibleNodeIds.has(edge.sourceId);
5185
- const targetVisible = visibleNodeIds.has(edge.targetId);
5186
- if (!sourceVisible || !targetVisible) {
5187
- return false;
5188
- }
5189
- if (normalizedSearch && !matchesOrganizationGraphEdgeSearch(edge, graph, normalizedSearch)) {
5190
- const sourceNode = graph.nodes.find((node) => node.id === edge.sourceId);
5191
- const targetNode = graph.nodes.find((node) => node.id === edge.targetId);
5192
- const nodeSearchMatch = Boolean(sourceNode && matchesOrganizationGraphNodeSearch(sourceNode, normalizedSearch)) || Boolean(targetNode && matchesOrganizationGraphNodeSearch(targetNode, normalizedSearch));
5193
- if (!nodeSearchMatch) {
5194
- return false;
5195
- }
5196
- }
5197
- return true;
5198
- });
5199
- return {
5200
- ...graph,
5201
- nodes: graph.nodes.filter((node) => visibleNodeIds.has(node.id)),
5202
- edges: visibleEdges
5203
- };
5204
- }
5205
- function getCommandViewResourceCategory(node, commandViewData) {
5206
- return getCommandViewNodeForGraphNode(node, commandViewData)?.category ?? null;
5207
- }
5208
- function getConnectedHiddenResourceIds(graph, nodeId2, hiddenIds) {
5209
- if (!nodeId2) {
5210
- return /* @__PURE__ */ new Set();
5211
- }
5212
- const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));
5213
- const connectedIds = /* @__PURE__ */ new Set();
5214
- for (const edge of graph.edges) {
5215
- const neighborId = edge.sourceId === nodeId2 ? edge.targetId : edge.targetId === nodeId2 ? edge.sourceId : null;
5216
- if (!neighborId || !hiddenIds.has(neighborId)) {
5217
- continue;
5218
- }
5219
- if (nodesById.get(neighborId)?.kind === "resource") {
5220
- connectedIds.add(neighborId);
5221
- }
5222
- }
5223
- return connectedIds;
5224
- }
5225
- function getCommandViewVisibilityProjection({
5226
- graph,
5227
- commandViewData,
5228
- resourcesHidden,
5229
- diagnosticsHidden,
5230
- diagnosticCategories,
5231
- revealedIds = /* @__PURE__ */ new Set(),
5232
- mode
5233
- }) {
5234
- const hiddenIds = /* @__PURE__ */ new Set();
5235
- const hiddenEdgeIds = /* @__PURE__ */ new Set();
5236
- const diagnosticCategorySet = new Set(diagnosticCategories);
5237
- let totalResourceCount = 0;
5238
- let hiddenDiagnosticResourceCount = 0;
5239
- if (mode === "trace" || mode === "impact") {
5240
- const resourceCount = graph.nodes.filter((node) => node.kind === "resource").length;
5241
- return {
5242
- hiddenIds,
5243
- hiddenEdgeIds,
5244
- totalResourceCount: resourceCount,
5245
- visibleResourceCount: resourceCount,
5246
- hiddenResourceCount: 0,
5247
- hiddenDiagnosticResourceCount: 0
5248
- };
5249
- }
5250
- for (const node of graph.nodes) {
5251
- if (node.kind !== "resource") {
5252
- continue;
5253
- }
5254
- totalResourceCount += 1;
5255
- const category = getCommandViewResourceCategory(node, commandViewData);
5256
- const isDiagnostic = Boolean(category && diagnosticCategorySet.has(category));
5257
- if (isDiagnostic && diagnosticsHidden) {
5258
- hiddenDiagnosticResourceCount += 1;
5259
- }
5260
- if (revealedIds.has(node.id)) {
5261
- continue;
5262
- }
5263
- if (resourcesHidden || diagnosticsHidden && isDiagnostic) {
5264
- hiddenIds.add(node.id);
5265
- }
5266
- }
5267
- for (const edge of graph.edges) {
5268
- if (hiddenIds.has(edge.sourceId) || hiddenIds.has(edge.targetId)) {
5269
- hiddenEdgeIds.add(edge.id);
5270
- }
5271
- }
5272
- const hiddenResourceCount = hiddenIds.size;
5273
- return {
5274
- hiddenIds,
5275
- hiddenEdgeIds,
5276
- totalResourceCount,
5277
- visibleResourceCount: totalResourceCount - hiddenResourceCount,
5278
- hiddenResourceCount,
5279
- hiddenDiagnosticResourceCount
5280
- };
5281
- }
5282
- function isOrganizationGraphFilterPristine(filters) {
5283
- return normalizeOrganizationGraphSearch(filters.search) === "" && filters.nodeKinds.length === 0 && filters.topologyPresence === DEFAULT_ORGANIZATION_GRAPH_FILTERS.topologyPresence && filters.environmentStatus === DEFAULT_ORGANIZATION_GRAPH_FILTERS.environmentStatus && filters.resourceTypes.length === 0 && filters.showIntegrations === DEFAULT_ORGANIZATION_GRAPH_FILTERS.showIntegrations && !hasActiveDomainFilters(filters.domainFilters);
5284
- }
5285
- var TOPOLOGY_PRESENCE_OPTIONS = [
5286
- { label: "All", value: "all" },
5287
- { label: "Semantic only", value: "semantic-only" },
5288
- { label: "Topology only", value: "topology-only" }
5289
- ];
5290
- var ENVIRONMENT_STATUS_OPTIONS = [
5291
- { label: "All", value: "all" },
5292
- { label: "Prod", value: "prod" },
5293
- { label: "Dev", value: "dev" }
5294
- ];
5295
- function OrganizationGraphFilterToolbar({
5296
- value,
5297
- onChange,
5298
- availableKinds,
5299
- disabled = false,
5300
- searchPlaceholder = "Search nodes, relationships, or IDs",
5301
- kindLabel = "Node kinds",
5302
- resourceTypeLabel = "Resource types",
5303
- topologyLabel = "Relationship presence",
5304
- environmentLabel = "Environment",
5305
- showIntegrationsLabel = "Show integrations",
5306
- resetLabel = "Reset filters",
5307
- resetValue = createOrganizationGraphFilters()
5308
- }) {
5309
- const kindOptions = getOrganizationGraphNodeKindOptions(availableKinds);
5310
- const resourceTypeOptions = getOrganizationGraphResourceTypeOptions();
5311
- const canReset = !isOrganizationGraphFilterPristine(value);
5312
- return /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
5313
- /* @__PURE__ */ jsx(
5314
- TextInput,
5315
- {
5316
- label: "Search",
5317
- placeholder: searchPlaceholder,
5318
- value: value.search,
5319
- onChange: (event) => onChange({
5320
- ...value,
5321
- search: event.currentTarget.value
5322
- }),
5323
- leftSection: /* @__PURE__ */ jsx(IconSearch, { size: 14 }),
5324
- disabled
5325
- }
5326
- ),
5327
- /* @__PURE__ */ jsx(
5328
- MultiSelect,
5329
- {
5330
- label: kindLabel,
5331
- placeholder: "All kinds",
5332
- data: kindOptions.map((option) => ({ value: option.kind, label: option.label })),
5333
- value: value.nodeKinds,
5334
- onChange: (nodeKinds) => onChange({
5335
- ...value,
5336
- nodeKinds
5337
- }),
5338
- searchable: true,
5339
- clearable: true,
5340
- disabled
5341
- }
5342
- ),
5343
- /* @__PURE__ */ jsx(
5344
- MultiSelect,
5345
- {
5346
- label: resourceTypeLabel,
5347
- placeholder: "All resource types",
5348
- data: resourceTypeOptions.map((option) => ({ value: option.resourceType, label: option.label })),
5349
- value: value.resourceTypes,
5350
- onChange: (resourceTypes) => onChange({
5351
- ...value,
5352
- resourceTypes
5353
- }),
5354
- searchable: true,
5355
- clearable: true,
5356
- disabled
5357
- }
5358
- ),
5359
- /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
5360
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, children: topologyLabel }),
5361
- /* @__PURE__ */ jsx(
5362
- SegmentedControl,
5363
- {
5364
- value: value.topologyPresence,
5365
- onChange: (topologyPresence) => onChange({
5366
- ...value,
5367
- topologyPresence
5368
- }),
5369
- data: TOPOLOGY_PRESENCE_OPTIONS,
5370
- size: "sm",
5371
- fullWidth: true,
5372
- disabled
5373
- }
5374
- )
5375
- ] }),
5376
- /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
5377
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, children: environmentLabel }),
5378
- /* @__PURE__ */ jsx(
5379
- SegmentedControl,
5380
- {
5381
- value: value.environmentStatus,
5382
- onChange: (environmentStatus) => onChange({
5383
- ...value,
5384
- environmentStatus
5385
- }),
5386
- data: ENVIRONMENT_STATUS_OPTIONS,
5387
- size: "sm",
5388
- fullWidth: true,
5389
- disabled
5390
- }
5391
- )
5392
- ] }),
5393
- /* @__PURE__ */ jsx(
5394
- Switch,
5395
- {
5396
- label: showIntegrationsLabel,
5397
- description: "Hide integration resources and their relationship edges.",
5398
- checked: value.showIntegrations,
5399
- onChange: (event) => onChange({
5400
- ...value,
5401
- showIntegrations: event.currentTarget.checked
5402
- }),
5403
- size: "sm",
5404
- disabled
5405
- }
5406
- ),
5407
- /* @__PURE__ */ jsx(Group, { justify: "flex-end", children: /* @__PURE__ */ jsx(
5408
- Button,
5409
- {
5410
- variant: "subtle",
5411
- leftSection: /* @__PURE__ */ jsx(IconRefresh, { size: 14 }),
5412
- onClick: () => onChange(resetValue),
5413
- disabled: disabled || !canReset,
5414
- children: resetLabel
5415
- }
5416
- ) })
5417
- ] });
5418
- }
5419
- var useOrganizationGraphFiltersStore = create((set) => ({
5420
- filtersByScope: {},
5421
- initializeScope: (scope, initialFilters) => set((state) => {
5422
- if (state.filtersByScope[scope]) {
5423
- return state;
5424
- }
5425
- return {
5426
- filtersByScope: {
5427
- ...state.filtersByScope,
5428
- [scope]: createOrganizationGraphFilters(initialFilters)
5429
- }
5430
- };
5431
- }),
5432
- updateScope: (scope, next) => set((state) => ({
5433
- filtersByScope: {
5434
- ...state.filtersByScope,
5435
- [scope]: createOrganizationGraphFilters({
5436
- ...state.filtersByScope[scope],
5437
- ...next
5438
- })
5439
- }
5440
- })),
5441
- resetScope: (scope, initialFilters) => set((state) => ({
5442
- filtersByScope: {
5443
- ...state.filtersByScope,
5444
- [scope]: createOrganizationGraphFilters(initialFilters)
5445
- }
5446
- }))
5447
- }));
5448
- function getOrganizationGraphFilterScope(initialFilters) {
5449
- return JSON.stringify(createOrganizationGraphFilters(initialFilters));
5450
- }
5451
- function useOrganizationGraphFilters(initialFilters) {
5452
- const scopeRef = useRef(getOrganizationGraphFilterScope(initialFilters));
5453
- const fallbackFiltersRef = useRef(createOrganizationGraphFilters(initialFilters));
5454
- const filters = useOrganizationGraphFiltersStore(
5455
- (state) => state.filtersByScope[scopeRef.current] ?? fallbackFiltersRef.current
5456
- );
5457
- const initializeScope = useOrganizationGraphFiltersStore((state) => state.initializeScope);
5458
- const updateScope = useOrganizationGraphFiltersStore((state) => state.updateScope);
5459
- const resetScope = useOrganizationGraphFiltersStore((state) => state.resetScope);
5460
- useEffect(() => {
5461
- initializeScope(scopeRef.current, initialFilters);
5462
- }, [initialFilters, initializeScope]);
5463
- const updateFilters = (next) => {
5464
- updateScope(scopeRef.current, next);
5465
- };
5466
- const setSearch = (search) => {
5467
- updateFilters({ search });
5468
- };
5469
- const setNodeKinds = (nodeKinds) => {
5470
- updateFilters({ nodeKinds });
5471
- };
5472
- const setTopologyPresence = (topologyPresence) => {
5473
- updateFilters({ topologyPresence });
5474
- };
5475
- const resetFilters = () => {
5476
- resetScope(scopeRef.current, initialFilters);
5477
- };
5478
- return {
5479
- filters,
5480
- setSearch,
5481
- setNodeKinds,
5482
- setTopologyPresence,
5483
- resetFilters,
5484
- updateFilters
5485
- };
5486
- }
5487
-
5488
- // src/features/operations/organization-graph/lenses.ts
5489
- var COMMAND_VIEW_NODE_KINDS = [
5490
- "organization",
5491
- "feature",
5492
- "surface",
5493
- "entity",
5494
- "capability",
5495
- "resource"
5496
- ];
5497
- function getOrganizationGraphLensConfig(lens) {
5498
- if (lens === "command-view") {
5499
- return {
5500
- title: "Command View",
5501
- caption: "Operations lens backed by the shared organization graph. This preset focuses the graph on bridged runtime resources and their operational relationships.",
5502
- initialMode: "map",
5503
- initialFilters: {
5504
- nodeKinds: COMMAND_VIEW_NODE_KINDS,
5505
- topologyPresence: "all"
5506
- },
5507
- filterSummary: "Command View lens keeps the organization structure visible while resource visibility is controlled progressively."
5508
- };
5509
- }
5510
- return {
5511
- title: "Organization Graph",
5512
- caption: "Cytoscape-based shared graph surface built from the organization model and bridged Command View topology.",
5513
- initialMode: "map",
5514
- filterSummary: "Filter by node kind, semantic-vs-topology presence, and free-text search across nodes and relationships."
5515
- };
5516
- }
5517
-
5518
- // src/features/operations/organization-graph/commandViewOperationalSummary.ts
5519
- function toPercentage(numerator, denominator) {
5520
- if (denominator <= 0) return null;
5521
- return numerator / denominator * 100;
5522
- }
5523
- function formatPercent(value) {
5524
- return value == null ? "N/A" : `${Math.round(value)}%`;
5525
- }
5526
- function formatTimestamp(value) {
5527
- if (!value) return "N/A";
5528
- return new Intl.DateTimeFormat("en-US", {
5529
- month: "short",
5530
- day: "numeric",
5531
- hour: "numeric",
5532
- minute: "2-digit"
5533
- }).format(new Date(value));
5534
- }
5535
- function getCommandViewNodes2(data) {
5536
- return [
5537
- ...data.agents,
5538
- ...data.workflows,
5539
- ...data.triggers,
5540
- ...data.integrations,
5541
- ...data.externalResources,
5542
- ...data.humanCheckpoints
5543
- ];
5544
- }
5545
- function getNodeByResourceId(data, resourceId) {
5546
- return getCommandViewNodes2(data).find((node) => node.resourceId === resourceId) ?? null;
5547
- }
5548
- function getCommandViewOperationalOverview(data, stats) {
5549
- if (!stats) {
5550
- return null;
5551
- }
5552
- const resourceEntries = Object.entries(stats.resources);
5553
- const humanEntries = Object.entries(stats.humanCheckpoints);
5554
- const totalRuns = resourceEntries.reduce((sum, [, item]) => sum + item.totalRuns, 0);
5555
- const successCount = resourceEntries.reduce((sum, [, item]) => sum + item.successCount, 0);
5556
- const failureCount = resourceEntries.reduce((sum, [, item]) => sum + item.failureCount, 0);
5557
- const warningCount = resourceEntries.reduce((sum, [, item]) => sum + item.warningCount, 0);
5558
- const pendingApprovals = humanEntries.reduce((sum, [, item]) => sum + item.pendingCount, 0);
5559
- const activeHumanCheckpoints = humanEntries.filter(([, item]) => item.pendingCount > 0).length;
5560
- const topFailingResources = resourceEntries.map(([resourceId, item]) => ({
5561
- id: resourceId,
5562
- label: data ? getNodeByResourceId(data, resourceId)?.name ?? resourceId : resourceId,
5563
- failureCount: item.failureCount,
5564
- warningCount: item.warningCount
5565
- })).filter((item) => item.failureCount > 0 || item.warningCount > 0).sort((left, right) => {
5566
- if (right.failureCount !== left.failureCount) {
5567
- return right.failureCount - left.failureCount;
5568
- }
5569
- if (right.warningCount !== left.warningCount) {
5570
- return right.warningCount - left.warningCount;
5571
- }
5572
- return left.label.localeCompare(right.label);
5573
- }).slice(0, 3);
5574
- return {
5575
- totalRuns,
5576
- successCount,
5577
- failureCount,
5578
- warningCount,
5579
- successRate: toPercentage(successCount, totalRuns),
5580
- trackedResources: resourceEntries.length,
5581
- pendingApprovals,
5582
- activeHumanCheckpoints,
5583
- topFailingResources,
5584
- timeRange: stats.timeRange,
5585
- generatedAt: stats.generatedAt
5586
- };
5587
- }
5588
- function buildResourceSelectionSummary(node, stats) {
5589
- const successRate = toPercentage(stats.successCount, stats.totalRuns);
5590
- const metadata = [
5591
- { label: "Operational Type", value: node.type },
5592
- { label: "Environment", value: node.status.toUpperCase() },
5593
- { label: "Version", value: node.version },
5594
- { label: "Origin", value: node.origin ? node.origin : "local" }
5595
- ];
5596
- if (node.category) {
5597
- metadata.push({ label: "Category", value: node.category });
5598
- }
5599
- if (node.links?.length) {
5600
- metadata.push({ label: "Links", value: node.links.map((link) => `${link.kind} ${link.nodeId}`).join(", ") });
5601
- }
5602
- if (node.type === "agent") {
5603
- metadata.push({ label: "Model", value: `${node.modelProvider}/${node.modelId}` });
5604
- metadata.push({ label: "Tools", value: String(node.toolCount) });
5605
- metadata.push({ label: "Memory", value: node.hasMemory ? "Enabled" : "Disabled" });
5606
- }
5607
- if (node.type === "workflow") {
5608
- metadata.push({ label: "Entry Point", value: node.entryPoint });
5609
- metadata.push({ label: "Steps", value: String(node.stepCount) });
5610
- }
5611
- if (node.type === "integration") {
5612
- metadata.push({ label: "Provider", value: node.provider });
5613
- metadata.push({ label: "Credential", value: node.credentialName });
5614
- }
5615
- if (node.type === "trigger") {
5616
- metadata.push({ label: "Trigger Type", value: node.triggerType });
5617
- }
5618
- if (node.type === "external") {
5619
- metadata.push({ label: "Platform", value: node.platform });
5620
- }
5621
- return {
5622
- title: "Operational Summary",
5623
- description: "Execution telemetry for this resource inside the Command View lens.",
5624
- metrics: [
5625
- { label: "Runs", value: String(stats.totalRuns), hint: "Total tracked executions in the selected time range" },
5626
- { label: "Success rate", value: formatPercent(successRate), hint: "Completed and warning runs as a percentage of all runs" },
5627
- { label: "Failures", value: String(stats.failureCount), hint: "Runs that ended in a failed state" },
5628
- { label: "Warnings", value: String(stats.warningCount), hint: "Completed runs that surfaced warnings" }
5629
- ],
5630
- metadata: [...metadata, { label: "Last Run", value: formatTimestamp(stats.lastRunAt) }]
5631
- };
5632
- }
5633
- function buildHumanSelectionSummary(node, stats) {
5634
- const metadata = [
5635
- { label: "Operational Type", value: "human checkpoint" },
5636
- { label: "Environment", value: node.status.toUpperCase() },
5637
- { label: "Version", value: node.version },
5638
- { label: "Origin", value: node.origin ? node.origin : "local" }
5639
- ];
5640
- if (node.category) {
5641
- metadata.push({ label: "Category", value: node.category });
5642
- }
5643
- if (node.links?.length) {
5644
- metadata.push({ label: "Links", value: node.links.map((link) => `${link.kind} ${link.nodeId}`).join(", ") });
5645
- }
5646
- return {
5647
- title: "Approval Queue Summary",
5648
- description: "Human checkpoint activity for the current Command View lens.",
5649
- metrics: [
5650
- { label: "Pending", value: String(stats.pendingCount), hint: "Tasks currently waiting on a decision" },
5651
- { label: "Completed", value: String(stats.completedCount), hint: "Tasks completed in the selected time range" },
5652
- { label: "Expired", value: String(stats.expiredCount), hint: "Tasks that expired before resolution" }
5653
- ],
5654
- metadata: [...metadata, { label: "Last Decision", value: formatTimestamp(stats.lastDecisionAt) }]
5655
- };
5656
- }
5657
- function getCommandViewSelectionOperationalSummary(data, stats, selectedElement) {
5658
- if (!data || !stats || !selectedElement || selectedElement.type !== "node") {
5659
- return null;
5660
- }
5661
- if (!selectedElement.id.startsWith("resource:")) {
5662
- return null;
5663
- }
5664
- const resourceId = selectedElement.id.slice("resource:".length);
5665
- const node = getNodeByResourceId(data, resourceId);
5666
- if (!node) {
5667
- return null;
5668
- }
5669
- if (node.type === "human") {
5670
- const checkpointStats = stats.humanCheckpoints[resourceId];
5671
- return checkpointStats ? buildHumanSelectionSummary(node, checkpointStats) : null;
5672
- }
5673
- const resourceStats = stats.resources[resourceId];
5674
- return resourceStats ? buildResourceSelectionSummary(node, resourceStats) : null;
5675
- }
5676
- function formatRelativeTime3(date) {
5677
- if (!date) return "N/A";
5678
- const dateObj = typeof date === "string" ? new Date(date) : date;
5679
- return formatDistanceToNow(dateObj, { addSuffix: true });
5680
- }
5681
-
5682
- // src/hooks/operations/command-view/utils/mergeStatsWithTopology.ts
5683
- function mergeStatsWithTopology(topology, stats) {
5684
- return {
5685
- ...topology,
5686
- agents: topology.agents.map((agent) => ({
5687
- ...agent,
5688
- stats: stats.resources[agent.resourceId] || null
5689
- })),
5690
- workflows: topology.workflows.map((workflow) => ({
5691
- ...workflow,
5692
- stats: stats.resources[workflow.resourceId] || null
5693
- })),
5694
- humanCheckpoints: topology.humanCheckpoints.map((checkpoint) => ({
5695
- ...checkpoint,
5696
- stats: stats.humanCheckpoints[checkpoint.resourceId] || null
5697
- }))
5698
- };
5699
- }
5700
-
5701
- // src/features/operations/organization-graph/commandViewDrillDown.ts
5702
- function titleCase4(value) {
5703
- return value.replace(/[-_.]+/g, " ").replace(/\s+/g, " ").trim().split(" ").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
5704
- }
5705
- function getResourceHref(resourceType, resourceId) {
5706
- if (resourceType === "agent") {
5707
- return `/operations/resources/agent/${resourceId}`;
5708
- }
5709
- if (resourceType === "workflow") {
5710
- return `/operations/resources/workflow/${resourceId}`;
5711
- }
5712
- if (resourceType === "human_checkpoint") {
5713
- return `/operations/command-queue?checkpoint=${resourceId}`;
5714
- }
5715
- return null;
5716
- }
5717
- function getExecutionBadgeColor(status) {
5718
- switch (status) {
5719
- case "failed":
5720
- return "red";
5721
- case "warning":
5722
- return "yellow";
5723
- case "running":
5724
- return "blue";
5725
- case "completed":
5726
- return "green";
5727
- case "pending":
5728
- default:
5729
- return "gray";
5730
- }
5731
- }
5732
- function getTaskBadgeColor(status) {
5733
- switch (status) {
5734
- case "pending":
5735
- return "orange";
5736
- case "processing":
5737
- return "blue";
5738
- case "completed":
5739
- return "green";
5740
- case "failed":
5741
- return "red";
5742
- case "expired":
5743
- default:
5744
- return "gray";
5745
- }
5746
- }
5747
- function getExecutionDescription(execution) {
5748
- if (execution.errorMessage) {
5749
- return execution.errorMessage;
5750
- }
5751
- if (execution.status === "running") {
5752
- return "Currently running";
5753
- }
5754
- if (execution.status === "warning") {
5755
- return "Completed with warnings";
5756
- }
5757
- if (execution.status === "completed") {
5758
- return "Completed successfully";
5759
- }
5760
- return titleCase4(execution.status);
5761
- }
5762
- function getTaskDescription(task) {
5763
- if (task.description) {
5764
- return task.description;
5765
- }
5766
- if (task.humanCheckpoint) {
5767
- return `Checkpoint: ${task.humanCheckpoint}`;
5768
- }
5769
- return "Pending approval task";
5770
- }
5771
- function buildCommandViewDrillDownSections({
5772
- node,
5773
- timeRange,
5774
- executions,
5775
- checkpointTasks
5776
- }) {
5777
- if (!node || node.kind !== "resource" || !node.sourceId || !node.resourceType) {
5778
- return [];
5779
- }
5780
- const sections = [];
5781
- const resourceHref = getResourceHref(node.resourceType, node.sourceId);
5782
- if ((node.resourceType === "agent" || node.resourceType === "workflow") && executions) {
5783
- sections.push({
5784
- title: "Recent executions",
5785
- description: `Latest runs for this ${titleCase4(node.resourceType)} in the ${timeRange} window.`,
5786
- emptyMessage: `No executions were recorded for this ${titleCase4(node.resourceType).toLowerCase()} in the current window.`,
5787
- primaryAction: resourceHref ? {
5788
- label: "Open resource",
5789
- href: resourceHref
5790
- } : void 0,
5791
- items: executions.map((execution) => ({
5792
- id: execution.executionId,
5793
- label: execution.executionId,
5794
- href: `${resourceHref ?? "#"}?exec=${execution.executionId}`,
5795
- description: getExecutionDescription(execution),
5796
- badgeLabel: execution.status,
5797
- badgeColor: getExecutionBadgeColor(execution.status),
5798
- meta: `Started ${formatRelativeTime3(execution.startedAt)}`
5799
- }))
5800
- });
5801
- }
5802
- if (node.resourceType === "human_checkpoint" && checkpointTasks) {
5803
- sections.push({
5804
- title: "Pending tasks",
5805
- description: "Human approval tasks waiting on this checkpoint.",
5806
- emptyMessage: "No pending tasks are currently assigned to this checkpoint.",
5807
- primaryAction: resourceHref ? {
5808
- label: "Open queue",
5809
- href: resourceHref
5810
- } : void 0,
5811
- items: checkpointTasks.map((task) => ({
5812
- id: task.id,
5813
- label: task.description ?? task.id,
5814
- href: `/operations/command-queue?task=${task.id}`,
5815
- description: getTaskDescription(task),
5816
- badgeLabel: task.status,
5817
- badgeColor: getTaskBadgeColor(task.status),
5818
- meta: `Created ${formatRelativeTime3(task.createdAt)}`
5819
- }))
5820
- });
5821
- }
5822
- return sections;
5823
- }
5824
-
5825
- // src/features/operations/organization-graph/path-tracing/trace.ts
5826
- var NODE_KIND_ORDER = {
5827
- organization: 0,
5828
- feature: 1,
5829
- surface: 2,
5830
- capability: 3,
5831
- entity: 4,
5832
- resource: 5,
5833
- knowledge: 6
5834
- };
5835
- var NODE_KIND_LABEL = {
5836
- organization: "Organization",
5837
- feature: "Feature",
5838
- surface: "Surface",
5839
- capability: "Capability",
5840
- entity: "Entity",
5841
- resource: "Resource",
5842
- knowledge: "Knowledge"
5843
- };
5844
- function getNodeLabel(node) {
5845
- return node.label || node.sourceId || node.id;
5846
- }
5847
- function compareTraceNodes(a, b) {
5848
- const kindDelta = NODE_KIND_ORDER[a.kind] - NODE_KIND_ORDER[b.kind];
5849
- if (kindDelta !== 0) {
5850
- return kindDelta;
5851
- }
5852
- const labelDelta = getNodeLabel(a).localeCompare(getNodeLabel(b));
5853
- if (labelDelta !== 0) {
5854
- return labelDelta;
5855
- }
5856
- return a.id.localeCompare(b.id);
5857
- }
5858
- function buildMissingNodeMessage(selection, missingNodeIds) {
5859
- if (missingNodeIds.length === 0) {
5860
- return "The selected trace is not available.";
5861
- }
5862
- if (missingNodeIds.length === 1) {
5863
- const missingId = missingNodeIds[0];
5864
- return `Graph node "${missingId}" is not available.`;
5865
- }
5866
- return `Graph nodes "${selection.sourceId}" and "${selection.targetId}" are not available.`;
5867
- }
5868
- function buildPathNotFoundMessage(source, target) {
5869
- return `No directed path found from "${source.label}" to "${target.label}".`;
5870
- }
5871
- function buildOrganizationGraphTraceIndex(graph) {
5872
- const nodesById = /* @__PURE__ */ new Map();
5873
- const edgesById = /* @__PURE__ */ new Map();
5874
- const outgoingEdgesByNodeId = /* @__PURE__ */ new Map();
5875
- const incomingEdgesByNodeId = /* @__PURE__ */ new Map();
5876
- for (const node of graph.nodes) {
5877
- nodesById.set(node.id, node);
5878
- outgoingEdgesByNodeId.set(node.id, []);
5879
- incomingEdgesByNodeId.set(node.id, []);
5880
- }
5881
- for (const edge of graph.edges) {
5882
- edgesById.set(edge.id, edge);
5883
- const outgoingEdges = outgoingEdgesByNodeId.get(edge.sourceId);
5884
- if (outgoingEdges) {
5885
- outgoingEdges.push(edge);
5886
- }
5887
- const incomingEdges = incomingEdgesByNodeId.get(edge.targetId);
5888
- if (incomingEdges) {
5889
- incomingEdges.push(edge);
5890
- }
5891
- }
5892
- return {
5893
- nodesById,
5894
- edgesById,
5895
- outgoingEdgesByNodeId,
5896
- incomingEdgesByNodeId
5897
- };
5898
- }
5899
- function getOrganizationGraphTraceNodeKindLabel(kind) {
5900
- return NODE_KIND_LABEL[kind];
5901
- }
5902
- function formatOrganizationGraphTraceNodeOptionLabel(option) {
5903
- return `${option.label} \xB7 ${getOrganizationGraphTraceNodeKindLabel(option.kind)}`;
5904
- }
5905
- function getOrganizationGraphTraceNodeOptions(graph) {
5906
- return [...graph.nodes].sort(compareTraceNodes).map((node) => ({
5907
- id: node.id,
5908
- label: getNodeLabel(node),
5909
- kind: node.kind,
5910
- sourceId: node.sourceId,
5911
- description: node.description,
5912
- enabled: node.enabled
5913
- }));
5914
- }
5915
- function resolveOrganizationGraphPathTrace(graph, selection) {
5916
- const index = buildOrganizationGraphTraceIndex(graph);
5917
- const source = selection.sourceId ? index.nodesById.get(selection.sourceId) ?? null : null;
5918
- const target = selection.targetId ? index.nodesById.get(selection.targetId) ?? null : null;
5919
- const missingNodeIds = [
5920
- selection.sourceId && !source ? selection.sourceId : null,
5921
- selection.targetId && !target ? selection.targetId : null
5922
- ].filter((value) => Boolean(value));
5923
- if (!selection.sourceId && !selection.targetId) {
5924
- return {
5925
- status: "idle",
5926
- selection,
5927
- source,
5928
- target,
5929
- missingNodeIds: [],
5930
- pathNodes: [],
5931
- pathEdges: [],
5932
- highlightNodeIds: [],
5933
- highlightEdgeIds: [],
5934
- distance: 0,
5935
- message: "Select a source and target to trace a path."
5936
- };
5937
- }
5938
- if (!selection.sourceId || !selection.targetId) {
5939
- return {
5940
- status: "incomplete",
5941
- selection,
5942
- source,
5943
- target,
5944
- missingNodeIds,
5945
- pathNodes: [],
5946
- pathEdges: [],
5947
- highlightNodeIds: [],
5948
- highlightEdgeIds: [],
5949
- distance: 0,
5950
- message: "Select both a source and a target to resolve a path."
5951
- };
5952
- }
5953
- if (missingNodeIds.length > 0 || !source || !target) {
5954
- return {
5955
- status: "missing-node",
5956
- selection,
5957
- source,
5958
- target,
5959
- missingNodeIds,
5960
- pathNodes: [],
5961
- pathEdges: [],
5962
- highlightNodeIds: [],
5963
- highlightEdgeIds: [],
5964
- distance: 0,
5965
- message: buildMissingNodeMessage(selection, missingNodeIds)
5966
- };
5967
- }
5968
- if (source.id === target.id) {
5969
- return {
5970
- status: "found",
5971
- selection,
5972
- source,
5973
- target,
5974
- missingNodeIds: [],
5975
- pathNodes: [source],
5976
- pathEdges: [],
5977
- highlightNodeIds: [source.id],
5978
- highlightEdgeIds: [],
5979
- distance: 0,
5980
- message: `Source and target already point to "${source.label}".`
5981
- };
5982
- }
5983
- const visitedNodeIds = /* @__PURE__ */ new Set([source.id]);
5984
- const predecessorByNodeId = /* @__PURE__ */ new Map();
5985
- const queue = [source.id];
5986
- while (queue.length > 0) {
5987
- const currentNodeId = queue.shift();
5988
- if (!currentNodeId) {
5989
- continue;
5990
- }
5991
- const outgoingEdges = index.outgoingEdgesByNodeId.get(currentNodeId) ?? [];
5992
- for (const edge of outgoingEdges) {
5993
- if (visitedNodeIds.has(edge.targetId)) {
5994
- continue;
5995
- }
5996
- visitedNodeIds.add(edge.targetId);
5997
- predecessorByNodeId.set(edge.targetId, {
5998
- nodeId: currentNodeId,
5999
- edgeId: edge.id
6000
- });
6001
- if (edge.targetId === target.id) {
6002
- queue.length = 0;
6003
- break;
6004
- }
6005
- queue.push(edge.targetId);
6006
- }
6007
- }
6008
- if (!predecessorByNodeId.has(target.id)) {
6009
- return {
6010
- status: "not-found",
6011
- selection,
6012
- source,
6013
- target,
6014
- missingNodeIds: [],
6015
- pathNodes: [],
6016
- pathEdges: [],
6017
- highlightNodeIds: [],
6018
- highlightEdgeIds: [],
6019
- distance: 0,
6020
- message: buildPathNotFoundMessage(source, target)
6021
- };
6022
- }
6023
- const pathNodes = [target];
6024
- const pathEdges = [];
6025
- let cursorNodeId = target.id;
6026
- while (cursorNodeId !== source.id) {
6027
- const predecessor = predecessorByNodeId.get(cursorNodeId);
6028
- if (!predecessor) {
6029
- break;
6030
- }
6031
- const edge = index.edgesById.get(predecessor.edgeId);
6032
- const previousNode = index.nodesById.get(predecessor.nodeId);
6033
- if (edge) {
6034
- pathEdges.push(edge);
6035
- }
6036
- if (previousNode) {
6037
- pathNodes.push(previousNode);
6038
- }
6039
- cursorNodeId = predecessor.nodeId;
6040
- }
6041
- pathNodes.reverse();
6042
- pathEdges.reverse();
6043
- return {
6044
- status: "found",
6045
- selection,
6046
- source,
6047
- target,
6048
- missingNodeIds: [],
6049
- pathNodes,
6050
- pathEdges,
6051
- highlightNodeIds: pathNodes.map((node) => node.id),
6052
- highlightEdgeIds: pathEdges.map((edge) => edge.id),
6053
- distance: pathEdges.length,
6054
- message: `Path found from "${source.label}" to "${target.label}" across ${pathEdges.length} edge${pathEdges.length === 1 ? "" : "s"}.`
6055
- };
6056
- }
6057
-
6058
- // src/features/operations/organization-graph/expand-around/expandAroundGraph.ts
6059
- var DEFAULT_MAX_DEPTH = 1;
6060
- var DEFAULT_MAX_RESULTS = 25;
6061
- var ORG_MODEL_ROOT_KINDS = /* @__PURE__ */ new Set([
6062
- "feature",
6063
- "surface",
6064
- "entity",
6065
- "capability"
6066
- ]);
6067
- var PRESET_EDGE_KINDS = {
6068
- coverage: ["contains", "exposes", "operates-on", "maps_to", "references"],
6069
- "operational-dependencies": ["references"],
6070
- "org-context": ["contains", "exposes", "operates-on", "maps_to"],
6071
- "impact-path": ["references"]
6072
- };
6073
- var PRESET_RELATIONSHIP_TYPES = {
6074
- "operational-dependencies": ["triggers", "uses", "approval"],
6075
- "impact-path": ["triggers", "uses", "approval"]
6076
- };
6077
- var PRESET_DIRECTIONS = {
6078
- coverage: "both",
6079
- "operational-dependencies": "both",
6080
- "org-context": "both",
6081
- "impact-path": "both"
6082
- };
6083
- function toSet(values) {
6084
- if (!values || values.length === 0) {
6085
- return null;
6086
- }
6087
- return new Set(values);
6088
- }
6089
- function clampMaxDepth(maxDepth) {
6090
- if (maxDepth === 2 || maxDepth === 3) {
6091
- return maxDepth;
6092
- }
6093
- return 1;
6094
- }
6095
- function resolvePreset(rootNode, preset) {
6096
- if (preset) {
6097
- return preset;
6098
- }
6099
- if (!rootNode) {
6100
- return null;
6101
- }
6102
- if (ORG_MODEL_ROOT_KINDS.has(rootNode.kind)) {
6103
- return "coverage";
6104
- }
6105
- if (rootNode.kind === "resource") {
6106
- return "operational-dependencies";
6107
- }
6108
- return null;
6109
- }
6110
- function resolveRequest(rootNode, request) {
6111
- const preset = resolvePreset(rootNode, request.preset);
6112
- const maxResults = request.maxResults === void 0 || !Number.isFinite(request.maxResults) ? DEFAULT_MAX_RESULTS : Math.max(0, request.maxResults);
6113
- return {
6114
- rootNodeId: request.rootNodeId,
6115
- direction: request.direction ?? (preset ? PRESET_DIRECTIONS[preset] : "both"),
6116
- maxDepth: clampMaxDepth(request.maxDepth ?? DEFAULT_MAX_DEPTH),
6117
- maxResults,
6118
- edgeKinds: toSet(request.edgeKinds ?? (preset ? PRESET_EDGE_KINDS[preset] : void 0)),
6119
- relationshipTypes: toSet(
6120
- request.relationshipTypes ?? (preset ? PRESET_RELATIONSHIP_TYPES[preset] : void 0)
6121
- ),
6122
- preset,
6123
- nodeKinds: toSet(request.nodeKinds),
6124
- resourceTypes: toSet(request.resourceTypes),
6125
- includeHiddenResources: request.includeHiddenResources ?? false
6126
- };
6127
- }
6128
- function getOppositeNodeId(edge, currentNodeId) {
6129
- if (edge.sourceId === currentNodeId) {
6130
- return edge.targetId;
6131
- }
6132
- if (edge.targetId === currentNodeId) {
6133
- return edge.sourceId;
6134
- }
6135
- return null;
6136
- }
6137
- function getCandidateEdges(index, nodeId2, direction) {
6138
- if (direction === "outgoing") {
6139
- return index.outgoingEdgesByNodeId.get(nodeId2) ?? [];
6140
- }
6141
- if (direction === "incoming") {
6142
- return index.incomingEdgesByNodeId.get(nodeId2) ?? [];
6143
- }
6144
- const seenEdgeIds = /* @__PURE__ */ new Set();
6145
- const edges = [];
6146
- for (const edge of [
6147
- ...index.outgoingEdgesByNodeId.get(nodeId2) ?? [],
6148
- ...index.incomingEdgesByNodeId.get(nodeId2) ?? []
6149
- ]) {
6150
- if (seenEdgeIds.has(edge.id)) {
6151
- continue;
6152
- }
6153
- seenEdgeIds.add(edge.id);
6154
- edges.push(edge);
6155
- }
6156
- return edges;
6157
- }
6158
- function matchesPresetTraversalDirection(edge, currentNodeId, request) {
6159
- if (request.preset === "coverage" && (edge.kind === "contains" || edge.kind === "exposes")) {
6160
- return edge.sourceId === currentNodeId;
6161
- }
6162
- return true;
6163
- }
6164
- function matchesEdgeFilters(edge, currentNodeId, request) {
6165
- if (request.edgeKinds && !request.edgeKinds.has(edge.kind)) {
6166
- return false;
6167
- }
6168
- if (request.relationshipTypes && (!edge.relationshipType || !request.relationshipTypes.has(edge.relationshipType))) {
6169
- return false;
6170
- }
6171
- return matchesPresetTraversalDirection(edge, currentNodeId, request);
6172
- }
6173
- function matchesNodeFilters(node, request) {
6174
- if (request.nodeKinds && !request.nodeKinds.has(node.kind)) {
6175
- return false;
6176
- }
6177
- if (request.resourceTypes) {
6178
- if (node.kind !== "resource") {
6179
- return false;
6180
- }
6181
- if (!node.resourceType || !request.resourceTypes.has(node.resourceType)) {
6182
- return false;
6183
- }
6184
- }
6185
- return true;
6186
- }
6187
- function pluralize(count, singular, plural = `${singular}s`) {
6188
- return `${count} ${count === 1 ? singular : plural}`;
6189
- }
6190
- function getNodeDisplayName(node) {
6191
- return node.label || node.sourceId || node.id;
6192
- }
6193
- function buildSummaryMessages(input) {
6194
- const { rootNode, preset, expandedNodes, counts, truncated } = input;
6195
- if (!rootNode) {
6196
- return ["Select an available node to expand around."];
6197
- }
6198
- if (!preset && rootNode.kind === "organization") {
6199
- return ["Choose a feature, surface, capability, entity, or resource before expanding."];
6200
- }
6201
- if (expandedNodes.length === 0) {
6202
- return [`No matching graph context found around "${getNodeDisplayName(rootNode)}".`];
6203
- }
6204
- const resourceCount = expandedNodes.filter((node) => node.kind === "resource").length;
6205
- const semanticContextCount = expandedNodes.length - resourceCount;
6206
- const rootLabel = getNodeDisplayName(rootNode);
6207
- const messages = [];
6208
- if (preset === "coverage" && ORG_MODEL_ROOT_KINDS.has(rootNode.kind)) {
6209
- if (resourceCount > 0 && semanticContextCount > 0) {
6210
- messages.push(
6211
- `${pluralize(resourceCount, "resource")} and ${pluralize(
6212
- semanticContextCount,
6213
- "semantic context node"
6214
- )} support "${rootLabel}".`
6215
- );
6216
- } else if (resourceCount > 0) {
6217
- messages.push(`${pluralize(resourceCount, "resource")} support "${rootLabel}".`);
6218
- } else {
6219
- messages.push(
6220
- `${pluralize(semanticContextCount, "semantic context node")} found around "${rootLabel}"; no mapped resources matched this coverage preset.`
6221
- );
6222
- }
6223
- } else if (preset === "operational-dependencies") {
6224
- messages.push(`${pluralize(resourceCount, "operational dependency resource")} found around "${rootLabel}".`);
6225
- } else if (preset === "org-context") {
6226
- messages.push(`${pluralize(expandedNodes.length, "semantic context node")} found around "${rootLabel}".`);
6227
- } else if (preset === "impact-path") {
6228
- messages.push(`${pluralize(resourceCount, "resource")} can call or be affected by "${rootLabel}".`);
6229
- } else {
6230
- messages.push(`${pluralize(expandedNodes.length, "node")} found around "${rootLabel}".`);
6231
- }
6232
- if (counts.hiddenResourceNodes > 0) {
6233
- messages.push(`${pluralize(counts.hiddenResourceNodes, "hidden resource")} matched current visibility settings.`);
6234
- }
6235
- if (counts.alreadyVisibleNodes > 0) {
6236
- messages.push(`${pluralize(counts.alreadyVisibleNodes, "node")} already visible in the graph.`);
6237
- }
6238
- if (truncated) {
6239
- messages.push(`Results were limited to ${pluralize(expandedNodes.length, "node")}.`);
6240
- }
6241
- return messages;
6242
- }
6243
- function expandAroundGraph(graph, request, options = {}) {
6244
- const index = buildOrganizationGraphTraceIndex(graph);
6245
- const rootNode = index.nodesById.get(request.rootNodeId) ?? null;
6246
- const resolved = resolveRequest(rootNode, request);
6247
- const alreadyVisibleNodeIds = new Set(options.alreadyVisibleNodeIds ?? []);
6248
- const hiddenResourceNodeIds = new Set(options.hiddenResourceNodeIds ?? []);
6249
- const expandedNodeIds = /* @__PURE__ */ new Set();
6250
- const expandedEdgeIds = /* @__PURE__ */ new Set();
6251
- const frontierNodeIds = /* @__PURE__ */ new Set();
6252
- const visitedDepthByNodeId = /* @__PURE__ */ new Map([[resolved.rootNodeId, 0]]);
6253
- const hasExplicitTraversalFilter = Boolean(
6254
- request.preset || request.edgeKinds?.length || request.relationshipTypes?.length || request.nodeKinds?.length || request.resourceTypes?.length
6255
- );
6256
- const queue = rootNode && (resolved.preset || hasExplicitTraversalFilter) ? [{ nodeId: rootNode.id, depth: 0 }] : [];
6257
- let truncated = false;
6258
- for (let queueIndex = 0; queueIndex < queue.length; queueIndex += 1) {
6259
- const current = queue[queueIndex];
6260
- if (current.depth >= resolved.maxDepth) {
6261
- if (current.nodeId !== resolved.rootNodeId) {
6262
- frontierNodeIds.add(current.nodeId);
6263
- }
6264
- continue;
6265
- }
6266
- for (const edge of getCandidateEdges(index, current.nodeId, resolved.direction)) {
6267
- if (!matchesEdgeFilters(edge, current.nodeId, resolved)) {
6268
- continue;
6269
- }
6270
- const nextNodeId = getOppositeNodeId(edge, current.nodeId);
6271
- if (!nextNodeId) {
6272
- continue;
6273
- }
6274
- const nextNode = index.nodesById.get(nextNodeId);
6275
- if (!nextNode || !matchesNodeFilters(nextNode, resolved)) {
6276
- continue;
6277
- }
6278
- if (!resolved.includeHiddenResources && hiddenResourceNodeIds.has(nextNode.id)) {
6279
- continue;
6280
- }
6281
- const nextDepth = current.depth + 1;
6282
- const previousDepth = visitedDepthByNodeId.get(nextNode.id);
6283
- if (previousDepth !== void 0) {
6284
- if (nextNode.id === resolved.rootNodeId || expandedNodeIds.has(nextNode.id)) {
6285
- expandedEdgeIds.add(edge.id);
6286
- }
6287
- continue;
6288
- }
6289
- if (expandedNodeIds.size >= resolved.maxResults) {
6290
- truncated = true;
6291
- frontierNodeIds.add(nextNode.id);
6292
- continue;
6293
- }
6294
- visitedDepthByNodeId.set(nextNode.id, nextDepth);
6295
- expandedNodeIds.add(nextNode.id);
6296
- expandedEdgeIds.add(edge.id);
6297
- if (nextDepth >= resolved.maxDepth) {
6298
- frontierNodeIds.add(nextNode.id);
6299
- continue;
6300
- }
6301
- queue.push({ nodeId: nextNode.id, depth: nextDepth });
6302
- }
6303
- }
6304
- const expandedNodes = [...expandedNodeIds].map((nodeId2) => index.nodesById.get(nodeId2)).filter((node) => Boolean(node));
6305
- const hiddenResourceNodes = expandedNodes.filter((node) => hiddenResourceNodeIds.has(node.id)).length;
6306
- const alreadyVisibleNodes = expandedNodes.filter((node) => alreadyVisibleNodeIds.has(node.id)).length;
6307
- const newNodes = expandedNodes.filter(
6308
- (node) => !hiddenResourceNodeIds.has(node.id) && !alreadyVisibleNodeIds.has(node.id)
6309
- ).length;
6310
- const counts = {
6311
- newNodes,
6312
- newEdges: expandedEdgeIds.size,
6313
- alreadyVisibleNodes,
6314
- hiddenResourceNodes
6315
- };
6316
- const summaryMessages = buildSummaryMessages({
6317
- rootNode,
6318
- preset: resolved.preset,
6319
- expandedNodes,
6320
- counts,
6321
- truncated
6322
- });
6323
- return {
6324
- rootNodeId: request.rootNodeId,
6325
- rootNode,
6326
- preset: resolved.preset,
6327
- direction: resolved.direction,
6328
- maxDepth: resolved.maxDepth,
6329
- maxResults: resolved.maxResults,
6330
- expandedNodeIds: [...expandedNodeIds],
6331
- expandedEdgeIds: [...expandedEdgeIds],
6332
- frontierNodeIds: [...frontierNodeIds].filter((nodeId2) => nodeId2 !== resolved.rootNodeId),
6333
- truncated,
6334
- counts,
6335
- summaryMessages,
6336
- message: summaryMessages[0] ?? ""
6337
- };
6338
- }
6339
- var PRESET_OPTIONS = [
6340
- { value: "coverage", label: "Coverage" },
6341
- { value: "operational-dependencies", label: "Operational dependencies" },
6342
- { value: "org-context", label: "Org context" },
6343
- { value: "impact-path", label: "Impact path" }
6344
- ];
6345
- var DIRECTION_OPTIONS = [
6346
- { value: "both", label: "Both" },
6347
- { value: "outgoing", label: "Outgoing" },
6348
- { value: "incoming", label: "Incoming" }
6349
- ];
6350
- var EDGE_KIND_OPTIONS = [
6351
- { value: "contains", label: "Containment" },
6352
- { value: "references", label: "References" },
6353
- { value: "exposes", label: "Exposes" },
6354
- { value: "maps_to", label: "Maps to" },
6355
- { value: "operates-on", label: "Operates on" },
6356
- { value: "uses", label: "Uses" }
6357
- ];
6358
- var RELATIONSHIP_OPTIONS = [
6359
- { value: "triggers", label: "Triggers" },
6360
- { value: "uses", label: "Uses" },
6361
- { value: "approval", label: "Approval" }
6362
- ];
6363
- var RESOURCE_TYPE_OPTIONS = [
6364
- { value: "workflow", label: "Workflow" },
6365
- { value: "agent", label: "Agent" },
6366
- { value: "trigger", label: "Trigger" },
6367
- { value: "integration", label: "Integration" },
6368
- { value: "external", label: "External" },
6369
- { value: "human_checkpoint", label: "Human checkpoint" }
6370
- ];
6371
- function updateValue(value, key, nextValue, onChange) {
6372
- onChange({
6373
- ...value,
6374
- [key]: nextValue
6375
- });
6376
- }
6377
- function toOptionalArray(values) {
6378
- return values.length > 0 ? values : void 0;
6379
- }
6380
- function toMaxDepth(value) {
6381
- const numeric = typeof value === "number" ? value : Number.parseInt(value, 10);
6382
- if (numeric === 3) return 3;
6383
- if (numeric === 2) return 2;
6384
- return 1;
6385
- }
6386
- function ExpandAroundPanel({
6387
- selectedNode,
6388
- value,
6389
- result,
6390
- appliedNodeCount,
6391
- appliedEdgeCount,
6392
- onChange,
6393
- onPreview,
6394
- onApply,
6395
- onClear
6396
- }) {
6397
- const disabled = !selectedNode;
6398
- const canApply = Boolean(result && result.expandedNodeIds.length > 0);
6399
- const rootIsTooBroad = selectedNode?.kind === "organization" && !value.preset;
6400
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
6401
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "flex-start", wrap: "wrap", children: [
6402
- /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
6403
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 800, children: "Expand Around" }),
6404
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: selectedNode ? `Preview typed graph context around ${selectedNode.label}.` : "Select a graph node to preview nearby operational context." })
6405
- ] }),
6406
- appliedNodeCount > 0 || appliedEdgeCount > 0 ? /* @__PURE__ */ jsxs(Badge, { variant: "light", color: "blue", children: [
6407
- appliedNodeCount,
6408
- " nodes / ",
6409
- appliedEdgeCount,
6410
- " edges applied"
6411
- ] }) : null
6412
- ] }),
6413
- /* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, sm: 2 }, spacing: "sm", children: [
6414
- /* @__PURE__ */ jsx(
6415
- Select,
6416
- {
6417
- label: "Preset",
6418
- placeholder: "Auto",
6419
- data: PRESET_OPTIONS,
6420
- value: value.preset ?? null,
6421
- onChange: (preset) => updateValue(value, "preset", preset ?? void 0, onChange),
6422
- disabled,
6423
- clearable: true
6424
- }
6425
- ),
6426
- /* @__PURE__ */ jsx(
6427
- Select,
6428
- {
6429
- label: "Direction",
6430
- data: DIRECTION_OPTIONS,
6431
- value: value.direction ?? "both",
6432
- onChange: (direction) => updateValue(value, "direction", direction ?? "both", onChange),
6433
- disabled
6434
- }
6435
- ),
6436
- /* @__PURE__ */ jsx(
6437
- NumberInput,
6438
- {
6439
- label: "Depth",
6440
- min: 1,
6441
- max: 3,
6442
- value: value.maxDepth ?? 1,
6443
- onChange: (maxDepth) => updateValue(value, "maxDepth", toMaxDepth(maxDepth), onChange),
6444
- disabled
6445
- }
6446
- ),
6447
- /* @__PURE__ */ jsx(
6448
- NumberInput,
6449
- {
6450
- label: "Max results",
6451
- min: 1,
6452
- max: 100,
6453
- value: value.maxResults ?? 25,
6454
- onChange: (maxResults) => updateValue(
6455
- value,
6456
- "maxResults",
6457
- Math.max(1, typeof maxResults === "number" ? maxResults : Number.parseInt(maxResults, 10) || 25),
6458
- onChange
6459
- ),
6460
- disabled
6461
- }
6462
- )
6463
- ] }),
6464
- /* @__PURE__ */ jsx(
6465
- MultiSelect,
6466
- {
6467
- label: "Relationship filters",
6468
- placeholder: "Preset defaults",
6469
- data: RELATIONSHIP_OPTIONS,
6470
- value: value.relationshipTypes ?? [],
6471
- onChange: (relationshipTypes) => updateValue(value, "relationshipTypes", toOptionalArray(relationshipTypes), onChange),
6472
- disabled,
6473
- clearable: true
6474
- }
6475
- ),
6476
- /* @__PURE__ */ jsx(
6477
- MultiSelect,
6478
- {
6479
- label: "Edge kind filters",
6480
- placeholder: "Preset defaults",
6481
- data: EDGE_KIND_OPTIONS,
6482
- value: value.edgeKinds ?? [],
6483
- onChange: (edgeKinds) => updateValue(value, "edgeKinds", toOptionalArray(edgeKinds), onChange),
6484
- disabled,
6485
- clearable: true
6486
- }
6487
- ),
6488
- /* @__PURE__ */ jsx(
6489
- MultiSelect,
6490
- {
6491
- label: "Resource type filters",
6492
- placeholder: "All resource types",
6493
- data: RESOURCE_TYPE_OPTIONS,
6494
- value: value.resourceTypes ?? [],
6495
- onChange: (resourceTypes) => updateValue(value, "resourceTypes", toOptionalArray(resourceTypes), onChange),
6496
- disabled,
6497
- clearable: true
6498
- }
6499
- ),
6500
- /* @__PURE__ */ jsx(
6501
- Switch,
6502
- {
6503
- label: "Include hidden resources",
6504
- checked: value.includeHiddenResources ?? true,
6505
- onChange: (event) => updateValue(value, "includeHiddenResources", event.currentTarget.checked, onChange),
6506
- disabled
6507
- }
6508
- ),
6509
- rootIsTooBroad ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "orange", children: "The organization root is broad. Choose a narrower node or a semantic preset before previewing." }) : null,
6510
- result ? /* @__PURE__ */ jsx(Card, { withBorder: true, radius: "md", p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
6511
- /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "wrap", children: [
6512
- /* @__PURE__ */ jsxs(Badge, { variant: "light", children: [
6513
- result.counts.newNodes,
6514
- " new"
6515
- ] }),
6516
- /* @__PURE__ */ jsxs(Badge, { variant: "light", children: [
6517
- result.counts.alreadyVisibleNodes,
6518
- " visible"
6519
- ] }),
6520
- /* @__PURE__ */ jsxs(Badge, { variant: "light", color: result.counts.hiddenResourceNodes > 0 ? "orange" : "gray", children: [
6521
- result.counts.hiddenResourceNodes,
6522
- " hidden"
6523
- ] }),
6524
- result.truncated ? /* @__PURE__ */ jsx(Badge, { variant: "light", color: "yellow", children: "Truncated" }) : null
6525
- ] }),
6526
- result.summaryMessages.map((message) => /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: message }, message))
6527
- ] }) }) : null,
6528
- /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", wrap: "wrap", children: [
6529
- /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
6530
- /* @__PURE__ */ jsx(Button, { size: "xs", variant: "light", onClick: onPreview, disabled: disabled || rootIsTooBroad, children: "Preview" }),
6531
- /* @__PURE__ */ jsx(Button, { size: "xs", onClick: onApply, disabled: !canApply, children: "Apply" })
6532
- ] }),
6533
- /* @__PURE__ */ jsx(Button, { size: "xs", variant: "subtle", onClick: onClear, disabled: !result && appliedNodeCount === 0, children: "Clear expansion" })
6534
- ] })
6535
- ] }) });
6536
- }
6537
- var cellStyle = {
6538
- padding: "var(--mantine-spacing-sm) var(--mantine-spacing-md)",
6539
- display: "flex",
6540
- alignItems: "center",
6541
- gap: "var(--mantine-spacing-sm)",
6542
- minWidth: 0
6543
- };
6544
- function CommandViewHealthStrip({
6545
- overview,
6546
- hotspots,
6547
- visibleResources,
6548
- hiddenResources = 0,
6549
- resourcesHidden,
6550
- selectedLabel,
6551
- onFocusHotspot,
6552
- onResourcesHiddenChange,
6553
- onResetFocus
6554
- }) {
6555
- return /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between" }, children: [
6556
- /* @__PURE__ */ jsxs("div", { style: cellStyle, children: [
6557
- /* @__PURE__ */ jsx(IconActivityHeartbeat, { size: 16, style: { flexShrink: 0, color: "var(--color-text-dimmed)" } }),
6558
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, style: { flexShrink: 0 }, children: overview?.successRate == null ? "N/A" : `${Math.round(overview.successRate)}%` }),
6559
- /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", children: [
6560
- /* @__PURE__ */ jsx(Badge, { variant: "light", color: "green", size: "xs", children: overview?.successCount ?? 0 }),
6561
- /* @__PURE__ */ jsx(Badge, { variant: "light", color: "red", size: "xs", children: overview?.failureCount ?? 0 }),
6562
- /* @__PURE__ */ jsx(Badge, { variant: "light", color: "yellow", size: "xs", children: overview?.warningCount ?? 0 })
6563
- ] }),
6564
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", truncate: true, style: { flexShrink: 1, minWidth: 0 }, children: overview ? `${overview.totalRuns} runs / ${overview.trackedResources} resources` : "" })
6565
- ] }),
6566
- /* @__PURE__ */ jsxs("div", { style: cellStyle, children: [
6567
- /* @__PURE__ */ jsx(IconAlertTriangle, { size: 16, style: { flexShrink: 0, color: "var(--color-text-dimmed)" } }),
6568
- hotspots.length > 0 ? /* @__PURE__ */ jsx(Group, { gap: "xs", wrap: "nowrap", style: { minWidth: 0, overflow: "hidden" }, children: hotspots.map((hotspot) => /* @__PURE__ */ jsx(Group, { gap: 4, wrap: "nowrap", children: /* @__PURE__ */ jsx(
6569
- Badge,
6570
- {
6571
- variant: "light",
6572
- color: "red",
6573
- size: "xs",
6574
- style: { cursor: "pointer", flexShrink: 0 },
6575
- onClick: () => onFocusHotspot(hotspot.resourceId),
6576
- children: hotspot.label
6577
- }
6578
- ) }, hotspot.nodeId)) }) : /* @__PURE__ */ jsx(Badge, { variant: "light", color: "green", size: "xs", leftSection: /* @__PURE__ */ jsx(IconCircleCheck, { size: 10 }), children: "No hotspots" })
6579
- ] }),
6580
- /* @__PURE__ */ jsxs("div", { style: cellStyle, children: [
6581
- /* @__PURE__ */ jsx(IconClockPause, { size: 16, style: { flexShrink: 0, color: "var(--color-text-dimmed)" } }),
6582
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, style: { flexShrink: 0 }, children: overview?.pendingApprovals ?? 0 }),
6583
- /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", truncate: true, children: [
6584
- "pending / ",
6585
- overview?.activeHumanCheckpoints ?? 0,
6586
- " queues"
6587
- ] })
6588
- ] }),
6589
- /* @__PURE__ */ jsxs("div", { style: cellStyle, children: [
6590
- /* @__PURE__ */ jsx(IconTopologyStar3, { size: 16, style: { flexShrink: 0, color: "var(--color-text-dimmed)" } }),
6591
- /* @__PURE__ */ jsx(Text, { size: "xs", fw: 600, truncate: true, style: { minWidth: 0 }, children: selectedLabel ?? `${visibleResources} visible / ${hiddenResources} hidden` }),
6592
- /* @__PURE__ */ jsx(
6593
- Button,
6594
- {
6595
- size: "compact-xs",
6596
- variant: resourcesHidden ? "light" : "subtle",
6597
- onClick: () => onResourcesHiddenChange(!resourcesHidden),
6598
- style: { flexShrink: 0 },
6599
- children: resourcesHidden ? "Show resources" : "Hide resources"
6600
- }
6601
- ),
6602
- /* @__PURE__ */ jsx(Button, { size: "compact-xs", variant: "subtle", onClick: onResetFocus, style: { flexShrink: 0 }, children: "Reset" })
6603
- ] })
6604
- ] });
6605
- }
6606
- var FILTER_STATE_ICONS2 = {
6607
- neutral: IconCircleDashed,
6608
- include: IconCircleCheck,
6609
- exclude: IconCircleX
6610
- };
6611
- var FILTER_STATE_COLORS2 = {
6612
- neutral: "var(--color-text-dimmed)",
6613
- include: "var(--mantine-color-green-6)",
6614
- exclude: "var(--mantine-color-red-6)"
6615
- };
6616
- var FILTER_STATE_LABELS2 = {
6617
- neutral: "Not filtered",
6618
- include: "Include only",
6619
- exclude: "Exclude"
6620
- };
6621
- function getCommandViewResources(commandViewData) {
6622
- if (!commandViewData) {
6623
- return [];
6624
- }
6625
- return [
6626
- ...commandViewData.agents,
6627
- ...commandViewData.workflows,
6628
- ...commandViewData.triggers,
6629
- ...commandViewData.integrations,
6630
- ...commandViewData.externalResources,
6631
- ...commandViewData.humanCheckpoints
6632
- ];
6633
- }
6634
- function nextDomainFilterState(current) {
6635
- if (current === "neutral") return "include";
6636
- if (current === "include") return "exclude";
6637
- return "neutral";
6638
- }
6639
- function FilterPanel({
6640
- filters,
6641
- onChangeFilters,
6642
- resetValue,
6643
- disabled = false,
6644
- commandViewData,
6645
- lens,
6646
- resourcesHidden,
6647
- diagnosticsHidden,
6648
- onResourcesHiddenChange,
6649
- onDiagnosticsHiddenChange,
6650
- onRevealResources,
6651
- onResetFilters,
6652
- visibilityCounts,
6653
- graph,
6654
- baseGraph,
6655
- layout = "grid"
6656
- }) {
6657
- const resourceFacets = collectResourceFilterFacets(getCommandViewResources(commandViewData));
6658
- const Section = ({ children }) => layout === "stack" ? /* @__PURE__ */ jsx(
6659
- Stack,
6660
- {
6661
- gap: "sm",
6662
- pb: "sm",
6663
- style: {
6664
- borderBottom: "1px solid var(--color-border)"
6665
- },
6666
- children
6667
- }
6668
- ) : /* @__PURE__ */ jsx(Paper, { withBorder: true, p: "md", radius: "md", style: { background: "var(--color-surface)" }, children });
6669
- const updateDomainFilter = (domainId) => {
6670
- const current = filters.domainFilters[domainId] ?? "neutral";
6671
- onChangeFilters({
6672
- ...filters,
6673
- domainFilters: {
6674
- ...filters.domainFilters,
6675
- [domainId]: nextDomainFilterState(current)
6676
- }
6677
- });
6678
- };
6679
- const handleResourceVisibilityAction = () => {
6680
- if (resourcesHidden) {
6681
- onRevealResources();
6682
- return;
6683
- }
6684
- onResourcesHiddenChange(true);
6685
- };
6686
- const content = /* @__PURE__ */ jsxs(Fragment, { children: [
6687
- /* @__PURE__ */ jsx(Section, { children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
6688
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, children: "Filters" }),
6689
- /* @__PURE__ */ jsx(
6690
- OrganizationGraphFilterToolbar,
6691
- {
6692
- value: filters,
6693
- onChange: onChangeFilters,
6694
- disabled,
6695
- resetValue
6696
- }
6697
- )
6698
- ] }) }),
6699
- /* @__PURE__ */ jsx(Section, { children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
6700
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", children: [
6701
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, children: "Visibility" }),
6702
- /* @__PURE__ */ jsxs(Badge, { variant: "light", children: [
6703
- visibilityCounts.visibleResourceCount,
6704
- "/",
6705
- visibilityCounts.totalResourceCount,
6706
- " resources"
6707
- ] })
6708
- ] }),
6709
- lens === "command-view" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6710
- /* @__PURE__ */ jsx(
6711
- Checkbox,
6712
- {
6713
- label: "Hide resource nodes",
6714
- description: "Keep the organization structure readable and reveal resource nodes as needed.",
6715
- checked: resourcesHidden,
6716
- onChange: (event) => onResourcesHiddenChange(event.currentTarget.checked),
6717
- disabled
6718
- }
6719
- ),
6720
- /* @__PURE__ */ jsx(
6721
- Checkbox,
6722
- {
6723
- label: "Hide diagnostic and testing resources",
6724
- description: "Diagnostics stay available through filters, trace, impact, and contextual reveal.",
6725
- checked: diagnosticsHidden,
6726
- onChange: (event) => onDiagnosticsHiddenChange(event.currentTarget.checked),
6727
- disabled
6728
- }
6729
- ),
6730
- /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "wrap", children: [
6731
- /* @__PURE__ */ jsxs(Badge, { variant: "light", color: visibilityCounts.hiddenResourceCount > 0 ? "yellow" : "green", children: [
6732
- visibilityCounts.hiddenResourceCount,
6733
- " hidden"
6734
- ] }),
6735
- /* @__PURE__ */ jsxs(Badge, { variant: "light", color: visibilityCounts.hiddenDiagnosticResourceCount > 0 ? "yellow" : "gray", children: [
6736
- visibilityCounts.hiddenDiagnosticResourceCount,
6737
- " diagnostic/testing"
6738
- ] })
6739
- ] }),
6740
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
6741
- /* @__PURE__ */ jsx(Button, { size: "xs", variant: "light", onClick: handleResourceVisibilityAction, disabled, children: resourcesHidden ? "Reveal resources" : "Hide resources" }),
6742
- /* @__PURE__ */ jsx(
6743
- Button,
6744
- {
6745
- size: "xs",
6746
- variant: "subtle",
6747
- leftSection: /* @__PURE__ */ jsx(IconRefresh, { size: 14 }),
6748
- onClick: onResetFilters,
6749
- disabled,
6750
- children: "Reset filters"
6751
- }
6752
- )
6753
- ] })
6754
- ] }) : /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Visibility controls are available in the Command View lens." })
6755
- ] }) }),
6756
- /* @__PURE__ */ jsx(Section, { children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
6757
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, children: "Resource Facets" }),
6758
- resourceFacets.length > 0 ? /* @__PURE__ */ jsx(Stack, { gap: 4, children: resourceFacets.map((facet) => {
6759
- const filterState = filters.domainFilters[facet.id] ?? "neutral";
6760
- const StateIcon = FILTER_STATE_ICONS2[filterState];
6761
- return /* @__PURE__ */ jsx(
6762
- UnstyledButton,
6763
- {
6764
- title: FILTER_STATE_LABELS2[filterState],
6765
- onClick: () => updateDomainFilter(facet.id),
6766
- disabled,
6767
- style: {
6768
- border: "1px solid var(--color-border)",
6769
- borderRadius: "var(--mantine-radius-sm)",
6770
- padding: "6px 8px"
6771
- },
6772
- children: /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", children: [
6773
- /* @__PURE__ */ jsx(StateIcon, { size: 16, style: { color: FILTER_STATE_COLORS2[filterState], flexShrink: 0 } }),
6774
- /* @__PURE__ */ jsx(Text, { size: "sm", truncate: true, c: filterState === "neutral" ? "dimmed" : void 0, children: facet.label })
6775
- ] })
6776
- },
6777
- facet.id
6778
- );
6779
- }) }) : /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No resource facets are available for the current topology." }),
6780
- /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
6781
- "Showing ",
6782
- graph?.nodes.length ?? 0,
6783
- " nodes and ",
6784
- graph?.edges.length ?? 0,
6785
- " edges from",
6786
- " ",
6787
- baseGraph?.nodes.length ?? 0,
6788
- " total nodes."
3409
+ variant: "light",
3410
+ color: "red",
3411
+ size: "xs",
3412
+ style: { cursor: "pointer", flexShrink: 0 },
3413
+ onClick: () => onFocusHotspot(hotspot.resourceId),
3414
+ children: hotspot.label
3415
+ }
3416
+ ) }, hotspot.nodeId)) }) : /* @__PURE__ */ jsx(Badge, { variant: "light", color: "green", size: "xs", leftSection: /* @__PURE__ */ jsx(IconCircleCheck, { size: 10 }), children: "No hotspots" })
3417
+ ] }),
3418
+ /* @__PURE__ */ jsxs("div", { style: cellStyle, children: [
3419
+ /* @__PURE__ */ jsx(IconClockPause, { size: 16, style: { flexShrink: 0, color: "var(--color-text-dimmed)" } }),
3420
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, style: { flexShrink: 0 }, children: overview?.pendingApprovals ?? 0 }),
3421
+ /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", truncate: true, children: [
3422
+ "pending / ",
3423
+ overview?.activeHumanCheckpoints ?? 0,
3424
+ " queues"
6789
3425
  ] })
6790
- ] }) })
3426
+ ] }),
3427
+ /* @__PURE__ */ jsxs("div", { style: cellStyle, children: [
3428
+ /* @__PURE__ */ jsx(IconTopologyStar3, { size: 16, style: { flexShrink: 0, color: "var(--color-text-dimmed)" } }),
3429
+ /* @__PURE__ */ jsx(Text, { size: "xs", fw: 600, truncate: true, style: { minWidth: 0 }, children: selectedLabel ?? `${visibleResources} visible / ${hiddenResources} hidden` }),
3430
+ /* @__PURE__ */ jsx(
3431
+ Button,
3432
+ {
3433
+ size: "compact-xs",
3434
+ variant: resourcesHidden ? "light" : "subtle",
3435
+ onClick: () => onResourcesHiddenChange(!resourcesHidden),
3436
+ style: { flexShrink: 0 },
3437
+ children: resourcesHidden ? "Show resources" : "Hide resources"
3438
+ }
3439
+ ),
3440
+ /* @__PURE__ */ jsx(Button, { size: "compact-xs", variant: "subtle", onClick: onResetFocus, style: { flexShrink: 0 }, children: "Reset" })
3441
+ ] })
6791
3442
  ] });
6792
- if (layout === "stack") {
6793
- return /* @__PURE__ */ jsx(Stack, { gap: "sm", children: content });
6794
- }
6795
- return /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, lg: 3 }, spacing: "md", children: content });
6796
3443
  }
6797
3444
 
6798
3445
  // src/features/operations/organization-graph/commandViewGraphHealth.ts
@@ -7499,14 +4146,14 @@ function syncGraphClasses(cy, selectedElement, traceResult, hiddenIds, hiddenEdg
7499
4146
  cy.elements().removeClass(
7500
4147
  "is-hidden is-faded is-context is-selected is-connected is-trace-node is-trace-edge is-trace-endpoint is-expanded-node is-expanded-edge"
7501
4148
  );
7502
- for (const nodeId2 of hiddenIds) {
7503
- const node = cy.getElementById(nodeId2);
4149
+ for (const nodeId of hiddenIds) {
4150
+ const node = cy.getElementById(nodeId);
7504
4151
  if (!node.empty()) {
7505
4152
  node.addClass("is-hidden");
7506
4153
  }
7507
4154
  }
7508
- for (const edgeId2 of hiddenEdgeIds) {
7509
- const edge2 = cy.getElementById(edgeId2);
4155
+ for (const edgeId of hiddenEdgeIds) {
4156
+ const edge2 = cy.getElementById(edgeId);
7510
4157
  if (!edge2.empty()) {
7511
4158
  edge2.addClass("is-hidden");
7512
4159
  }
@@ -7515,14 +4162,14 @@ function syncGraphClasses(cy, selectedElement, traceResult, hiddenIds, hiddenEdg
7515
4162
  traceResult && (traceResult.highlightNodeIds.length > 0 || traceResult.highlightEdgeIds.length > 0)
7516
4163
  );
7517
4164
  if (!selectedElement && !hasTrace) {
7518
- for (const nodeId2 of expandedNodeIds) {
7519
- const node = cy.getElementById(nodeId2);
4165
+ for (const nodeId of expandedNodeIds) {
4166
+ const node = cy.getElementById(nodeId);
7520
4167
  if (!node.empty()) {
7521
4168
  node.addClass("is-expanded-node");
7522
4169
  }
7523
4170
  }
7524
- for (const edgeId2 of expandedEdgeIds) {
7525
- const edge2 = cy.getElementById(edgeId2);
4171
+ for (const edgeId of expandedEdgeIds) {
4172
+ const edge2 = cy.getElementById(edgeId);
7526
4173
  if (!edge2.empty()) {
7527
4174
  edge2.addClass("is-expanded-edge");
7528
4175
  }
@@ -7530,27 +4177,27 @@ function syncGraphClasses(cy, selectedElement, traceResult, hiddenIds, hiddenEdg
7530
4177
  return;
7531
4178
  }
7532
4179
  cy.elements().addClass("is-faded");
7533
- for (const nodeId2 of expandedNodeIds) {
7534
- const node = cy.getElementById(nodeId2);
4180
+ for (const nodeId of expandedNodeIds) {
4181
+ const node = cy.getElementById(nodeId);
7535
4182
  if (!node.empty()) {
7536
4183
  node.removeClass("is-faded").addClass("is-context is-expanded-node");
7537
4184
  }
7538
4185
  }
7539
- for (const edgeId2 of expandedEdgeIds) {
7540
- const edge2 = cy.getElementById(edgeId2);
4186
+ for (const edgeId of expandedEdgeIds) {
4187
+ const edge2 = cy.getElementById(edgeId);
7541
4188
  if (!edge2.empty()) {
7542
4189
  edge2.removeClass("is-faded").addClass("is-connected is-expanded-edge");
7543
4190
  }
7544
4191
  }
7545
4192
  if (traceResult) {
7546
- for (const nodeId2 of traceResult.highlightNodeIds) {
7547
- const node = cy.getElementById(nodeId2);
4193
+ for (const nodeId of traceResult.highlightNodeIds) {
4194
+ const node = cy.getElementById(nodeId);
7548
4195
  if (!node.empty()) {
7549
4196
  node.removeClass("is-faded").addClass("is-context is-trace-node");
7550
4197
  }
7551
4198
  }
7552
- for (const edgeId2 of traceResult.highlightEdgeIds) {
7553
- const edge2 = cy.getElementById(edgeId2);
4199
+ for (const edgeId of traceResult.highlightEdgeIds) {
4200
+ const edge2 = cy.getElementById(edgeId);
7554
4201
  if (!edge2.empty()) {
7555
4202
  edge2.removeClass("is-faded").addClass("is-connected is-trace-edge");
7556
4203
  }
@@ -8031,9 +4678,9 @@ function OrganizationGraphPage({ lens = "default", timeRange = "30d" }) {
8031
4678
  })).sort((left, right) => left.label.localeCompare(right.label)),
8032
4679
  [visibleGraph]
8033
4680
  );
8034
- const focusGraphNode = useEffectEvent((nodeId2) => {
4681
+ const focusGraphNode = useEffectEvent((nodeId) => {
8035
4682
  setFocusRequest({
8036
- nodeId: nodeId2,
4683
+ nodeId,
8037
4684
  nonce: Date.now()
8038
4685
  });
8039
4686
  });
@@ -8154,7 +4801,7 @@ function OrganizationGraphPage({ lens = "default", timeRange = "30d" }) {
8154
4801
  return;
8155
4802
  }
8156
4803
  const graphNodeIds = new Set(graph.nodes.map((node) => node.id));
8157
- const expansionStillExists = [...appliedExpandAroundNodeIds].some((nodeId2) => graphNodeIds.has(nodeId2));
4804
+ const expansionStillExists = [...appliedExpandAroundNodeIds].some((nodeId) => graphNodeIds.has(nodeId));
8158
4805
  if (!expansionStillExists) {
8159
4806
  clearExpandAroundState();
8160
4807
  }
@@ -8581,362 +5228,6 @@ function OrganizationGraphPage({ lens = "default", timeRange = "30d" }) {
8581
5228
  function CommandViewPage({ timeRange }) {
8582
5229
  return /* @__PURE__ */ jsx(OrganizationGraphPage, { lens: "command-view", timeRange });
8583
5230
  }
8584
- var EXECUTION_SECTIONS = [
8585
- { status: "failed", title: "Failed Executions", badgeColor: "red" },
8586
- { status: "warning", title: "Warning Executions", badgeColor: "yellow" },
8587
- { status: "completed", title: "Successful Executions", badgeColor: null }
8588
- ];
8589
- var HOVER_CARD_STYLE = {
8590
- cursor: "pointer",
8591
- transition: "box-shadow var(--duration-fast) var(--easing)",
8592
- textDecoration: "none",
8593
- color: "inherit"
8594
- };
8595
- function handleHoverEnter(e) {
8596
- e.currentTarget.style.boxShadow = "var(--standard-box-shadow)";
8597
- }
8598
- function handleHoverLeave(e) {
8599
- e.currentTarget.style.boxShadow = "";
8600
- }
8601
- function ExecutionStatusSection({ executions, status, title, badgeColor, resourceUrl }) {
8602
- const filtered = executions.filter((e) => e.status === status);
8603
- if (filtered.length === 0) return null;
8604
- return /* @__PURE__ */ jsxs("div", { children: [
8605
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: 8, children: [
8606
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", children: title }),
8607
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: filtered.length })
8608
- ] }),
8609
- /* @__PURE__ */ jsx(Stack, { gap: "xs", children: filtered.map((execution) => /* @__PURE__ */ jsxs(
8610
- Card,
8611
- {
8612
- padding: "xs",
8613
- withBorder: true,
8614
- component: "a",
8615
- href: `${resourceUrl}?exec=${execution.executionId}`,
8616
- target: "_blank",
8617
- rel: "noopener noreferrer",
8618
- style: HOVER_CARD_STYLE,
8619
- onMouseEnter: handleHoverEnter,
8620
- onMouseLeave: handleHoverLeave,
8621
- children: [
8622
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: status === "failed" && execution.errorMessage ? 4 : 0, children: [
8623
- badgeColor ? /* @__PURE__ */ jsx(Badge, { size: "xs", color: badgeColor, variant: "light", children: status }) : /* @__PURE__ */ jsx(Text, { size: "xs", c: "green", children: "\u2713 Completed" }),
8624
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatRelativeTime3(execution.startedAt) })
8625
- ] }),
8626
- status === "failed" && execution.errorMessage && /* @__PURE__ */ jsx(Text, { size: "xs", c: "red", lineClamp: 2, children: execution.errorMessage })
8627
- ]
8628
- },
8629
- execution.executionId
8630
- )) }),
8631
- /* @__PURE__ */ jsx(Space, { h: "sm" })
8632
- ] });
8633
- }
8634
- function CommandViewSidebarContent({ timeRange }) {
8635
- const theme = useMantineTheme();
8636
- const colors = useCyberColors();
8637
- const { organizationModel } = useElevasisFeatures();
8638
- const lensConfig = useMemo(() => getOrganizationGraphLensConfig("command-view"), []);
8639
- const { filters, resetFilters, updateFilters } = useOrganizationGraphFilters(lensConfig.initialFilters);
8640
- const toolbarResetValue = useMemo(
8641
- () => createOrganizationGraphFilters(lensConfig.initialFilters),
8642
- [lensConfig.initialFilters]
8643
- );
8644
- const selectedNodeId = useCommandViewStore((s) => s.selectedNodeId);
8645
- const resourcesHidden = useCommandViewStore((s) => s.resourcesHidden);
8646
- const setResourcesHidden = useCommandViewStore((s) => s.setResourcesHidden);
8647
- const diagnosticsHidden = useCommandViewStore((s) => s.diagnosticsHidden);
8648
- const setDiagnosticsHidden = useCommandViewStore((s) => s.setDiagnosticsHidden);
8649
- const diagnosticCategories = useCommandViewStore((s) => s.diagnosticCategories);
8650
- const revealedIds = useCommandViewStore((s) => s.revealedIds);
8651
- const clearRevealedIds = useCommandViewStore((s) => s.clearRevealedIds);
8652
- const { data, isLoading } = useCommandViewData();
8653
- const { data: statsData } = useCommandViewStats(timeRange);
8654
- const cleanData = data ?? null;
8655
- const dataWithStats = useMemo(() => {
8656
- if (!cleanData) return null;
8657
- if (!statsData) return cleanData;
8658
- return mergeStatsWithTopology(cleanData, statsData);
8659
- }, [cleanData, statsData]);
8660
- const baseGraph = useMemo(() => {
8661
- if (!organizationModel) {
8662
- return null;
8663
- }
8664
- return buildOrganizationGraph({
8665
- organizationModel,
8666
- commandViewData: cleanData ?? void 0
8667
- });
8668
- }, [cleanData, organizationModel]);
8669
- const graph = useMemo(() => {
8670
- if (!baseGraph) {
8671
- return null;
8672
- }
8673
- return filterOrganizationGraph(baseGraph, filters, {
8674
- commandViewData: cleanData
8675
- });
8676
- }, [baseGraph, cleanData, filters]);
8677
- const visibilityProjection = useMemo(() => {
8678
- if (!graph) {
8679
- return {
8680
- hiddenIds: /* @__PURE__ */ new Set(),
8681
- hiddenEdgeIds: /* @__PURE__ */ new Set(),
8682
- totalResourceCount: 0,
8683
- visibleResourceCount: 0,
8684
- hiddenResourceCount: 0,
8685
- hiddenDiagnosticResourceCount: 0
8686
- };
8687
- }
8688
- return getCommandViewVisibilityProjection({
8689
- graph,
8690
- commandViewData: cleanData,
8691
- resourcesHidden,
8692
- diagnosticsHidden,
8693
- diagnosticCategories,
8694
- revealedIds,
8695
- mode: "map"
8696
- });
8697
- }, [cleanData, diagnosticCategories, diagnosticsHidden, graph, resourcesHidden, revealedIds]);
8698
- const visibleGraph = useMemo(() => {
8699
- if (!graph || visibilityProjection.hiddenIds.size === 0) {
8700
- return graph;
8701
- }
8702
- return {
8703
- ...graph,
8704
- nodes: graph.nodes.filter((node) => !visibilityProjection.hiddenIds.has(node.id)),
8705
- edges: graph.edges.filter((edge) => !visibilityProjection.hiddenEdgeIds.has(edge.id))
8706
- };
8707
- }, [graph, visibilityProjection]);
8708
- const handleResetFilters = () => {
8709
- resetFilters();
8710
- clearRevealedIds();
8711
- };
8712
- const handleResourcesHiddenChange = (value) => {
8713
- setResourcesHidden(value);
8714
- if (value) {
8715
- clearRevealedIds();
8716
- }
8717
- };
8718
- const handleDiagnosticsHiddenChange = (value) => {
8719
- setDiagnosticsHidden(value);
8720
- if (value) {
8721
- clearRevealedIds();
8722
- }
8723
- };
8724
- const revealAllResources = () => {
8725
- setResourcesHidden(false);
8726
- setDiagnosticsHidden(false);
8727
- clearRevealedIds();
8728
- };
8729
- const { donutSuccessCount, donutFailedCount } = useMemo(() => {
8730
- if (!cleanData || !statsData) return { donutSuccessCount: 0, donutFailedCount: 0 };
8731
- const allResources = [
8732
- ...cleanData.agents,
8733
- ...cleanData.workflows,
8734
- ...cleanData.triggers,
8735
- ...cleanData.integrations,
8736
- ...cleanData.externalResources ?? [],
8737
- ...cleanData.humanCheckpoints ?? []
8738
- ];
8739
- const filteredIds = new Set(allResources.map((resource) => resource.resourceId));
8740
- let success = 0;
8741
- let failed = 0;
8742
- for (const [id, stats] of Object.entries(statsData.resources)) {
8743
- if (filteredIds.has(id)) {
8744
- success += stats.successCount;
8745
- failed += stats.failureCount;
8746
- }
8747
- }
8748
- return { donutSuccessCount: success, donutFailedCount: failed };
8749
- }, [cleanData, statsData]);
8750
- const selectedNode = useMemo(() => {
8751
- if (!selectedNodeId || !dataWithStats) return null;
8752
- const allNodes = [
8753
- ...dataWithStats.agents || [],
8754
- ...dataWithStats.workflows || [],
8755
- ...dataWithStats.triggers || [],
8756
- ...dataWithStats.integrations || [],
8757
- ...dataWithStats.externalResources || [],
8758
- ...dataWithStats.humanCheckpoints || []
8759
- ];
8760
- return allNodes.find((node) => {
8761
- const nodeId2 = getNodeId(node);
8762
- return nodeId2 === selectedNodeId || node.name === selectedNodeId;
8763
- }) || null;
8764
- }, [selectedNodeId, dataWithStats]);
8765
- const isNavigable = selectedNode?.type === "agent" || selectedNode?.type === "workflow";
8766
- const isHumanCheckpoint = selectedNode?.type === "human";
8767
- const selectedResourceId = useMemo(() => {
8768
- if (!selectedNode) return null;
8769
- return getNodeId(selectedNode);
8770
- }, [selectedNode]);
8771
- const {
8772
- page: executionPage,
8773
- setPage: setExecutionPage,
8774
- totalPages: totalExecutionPages
8775
- } = usePaginationState(10, [selectedResourceId, timeRange]);
8776
- const getNavigationUrl = () => {
8777
- if (!selectedNode || !selectedResourceId) return null;
8778
- if (selectedNode.type === "agent") return `/operations/resources/agent/${selectedResourceId}`;
8779
- if (selectedNode.type === "workflow") return `/operations/resources/workflow/${selectedResourceId}`;
8780
- if (selectedNode.type === "human") return `/operations/command-queue?checkpoint=${selectedResourceId}`;
8781
- return null;
8782
- };
8783
- const resourceUrl = selectedNode?.type === "agent" ? `/operations/resources/agent/${selectedResourceId}` : `/operations/resources/workflow/${selectedResourceId}`;
8784
- const {
8785
- data: executionsData,
8786
- isLoading: executionsLoading,
8787
- error: executionsError
8788
- } = useResourceExecutions({
8789
- resourceId: selectedResourceId,
8790
- timeRange,
8791
- page: executionPage,
8792
- limit: 10,
8793
- enabled: isNavigable
8794
- });
8795
- const {
8796
- data: checkpointTasksData,
8797
- isLoading: checkpointTasksLoading,
8798
- error: checkpointTasksError
8799
- } = useCheckpointTasks({
8800
- checkpointId: selectedResourceId,
8801
- enabled: isHumanCheckpoint
8802
- });
8803
- const totalExecutions = donutSuccessCount + donutFailedCount;
8804
- const successRate = totalExecutions > 0 ? donutSuccessCount / totalExecutions * 100 : 0;
8805
- const healthSegments = [
8806
- { name: "Completed", value: donutSuccessCount, color: colors.green },
8807
- { name: "Failed", value: donutFailedCount, color: colors.red }
8808
- ];
8809
- const centerValueColor = totalExecutions === 0 ? "var(--mantine-color-dimmed)" : successRate >= 95 ? colors.green : successRate >= 80 ? colors.yellow : colors.red;
8810
- if (isLoading && !data) {
8811
- return /* @__PURE__ */ jsx(SubshellSidebarLoader, {});
8812
- }
8813
- return /* @__PURE__ */ jsx(
8814
- Box,
8815
- {
8816
- style: {
8817
- flex: 1,
8818
- height: "100%",
8819
- minHeight: 0,
8820
- display: "flex",
8821
- flexDirection: "column",
8822
- overflow: "hidden"
8823
- },
8824
- children: /* @__PURE__ */ jsxs("div", { style: { flex: 1, minHeight: 0, overflowY: "auto", overflowX: "hidden" }, children: [
8825
- /* @__PURE__ */ jsx(SubshellSidebarSection, { icon: IconSitemap, label: "Command View" }),
8826
- /* @__PURE__ */ jsx(Box, { style: { padding: theme.spacing.sm, paddingBottom: 0 }, children: /* @__PURE__ */ jsx(Box, { pb: "xs", mb: 4, children: /* @__PURE__ */ jsx(
8827
- CyberDonut,
8828
- {
8829
- title: `Execution Health (${timeRange})`,
8830
- segments: healthSegments,
8831
- centerValue: totalExecutions === 0 ? "\u2014" : `${Math.round(successRate)}%`,
8832
- centerLabel: `${totalExecutions} runs`,
8833
- centerValueColor,
8834
- glowId: "cvHealthGlow",
8835
- colors
8836
- }
8837
- ) }) }),
8838
- /* @__PURE__ */ jsx(Box, { p: "sm", children: /* @__PURE__ */ jsx(
8839
- FilterPanel,
8840
- {
8841
- filters,
8842
- onChangeFilters: updateFilters,
8843
- resetValue: toolbarResetValue,
8844
- disabled: !baseGraph,
8845
- commandViewData: cleanData,
8846
- lens: "command-view",
8847
- resourcesHidden,
8848
- diagnosticsHidden,
8849
- onResourcesHiddenChange: handleResourcesHiddenChange,
8850
- onDiagnosticsHiddenChange: handleDiagnosticsHiddenChange,
8851
- onRevealResources: revealAllResources,
8852
- onResetFilters: handleResetFilters,
8853
- visibilityCounts: visibilityProjection,
8854
- graph: visibleGraph,
8855
- baseGraph,
8856
- layout: "stack"
8857
- }
8858
- ) }),
8859
- selectedNode && /* @__PURE__ */ jsxs(Fragment, { children: [
8860
- /* @__PURE__ */ jsx(Divider, {}),
8861
- /* @__PURE__ */ jsxs(Stack, { gap: "xs", p: "sm", mt: 8, children: [
8862
- /* @__PURE__ */ jsx(Title, { order: 4, children: selectedNode.name }),
8863
- selectedNode.description && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: selectedNode.description }),
8864
- (isNavigable || isHumanCheckpoint) && /* @__PURE__ */ jsxs(
8865
- Button,
8866
- {
8867
- component: "a",
8868
- href: getNavigationUrl() || "#",
8869
- target: "_blank",
8870
- rel: "noopener noreferrer",
8871
- variant: "light",
8872
- size: "xs",
8873
- leftSection: /* @__PURE__ */ jsx(IconExternalLink, { size: 14 }),
8874
- mt: 4,
8875
- children: [
8876
- "Go to",
8877
- " ",
8878
- selectedNode.type === "agent" ? "Agent" : selectedNode.type === "workflow" ? "Workflow" : "Queue"
8879
- ]
8880
- }
8881
- ),
8882
- /* @__PURE__ */ jsx(Space, { h: "sm" })
8883
- ] })
8884
- ] }),
8885
- selectedNode && isNavigable && /* @__PURE__ */ jsx(Stack, { p: "sm", children: executionsLoading ? /* @__PURE__ */ jsx(Center, { py: "md", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) }) : executionsError ? /* @__PURE__ */ jsx(APIErrorAlert, { error: executionsError, title: "Failed to load executions" }) : executionsData && executionsData.executions.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
8886
- EXECUTION_SECTIONS.map((section) => /* @__PURE__ */ jsx(
8887
- ExecutionStatusSection,
8888
- {
8889
- executions: executionsData.executions,
8890
- status: section.status,
8891
- title: section.title,
8892
- badgeColor: section.badgeColor,
8893
- resourceUrl
8894
- },
8895
- section.status
8896
- )),
8897
- totalExecutionPages(executionsData.totalExecutions) > 1 && /* @__PURE__ */ jsx(Group, { justify: "center", children: /* @__PURE__ */ jsx(
8898
- Pagination,
8899
- {
8900
- size: "sm",
8901
- total: totalExecutionPages(executionsData.totalExecutions),
8902
- value: executionPage,
8903
- onChange: setExecutionPage,
8904
- boundaries: 1
8905
- }
8906
- ) })
8907
- ] }) : executionsData ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No executions in the selected time range" }) : null }),
8908
- selectedNode && isHumanCheckpoint && /* @__PURE__ */ jsx(Stack, { p: "sm", children: checkpointTasksLoading ? /* @__PURE__ */ jsx(Center, { py: "md", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) }) : checkpointTasksError ? /* @__PURE__ */ jsx(APIErrorAlert, { error: checkpointTasksError, title: "Failed to load pending tasks" }) : checkpointTasksData && checkpointTasksData.tasks.length > 0 ? /* @__PURE__ */ jsxs("div", { children: [
8909
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: 8, children: [
8910
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 600, tt: "uppercase", children: "Pending Tasks" }),
8911
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: checkpointTasksData.tasks.length })
8912
- ] }),
8913
- /* @__PURE__ */ jsx(Stack, { gap: "xs", children: checkpointTasksData.tasks.map((task) => /* @__PURE__ */ jsxs(
8914
- Card,
8915
- {
8916
- padding: "xs",
8917
- withBorder: true,
8918
- component: "a",
8919
- href: `/operations/command-queue?task=${task.id}`,
8920
- target: "_blank",
8921
- rel: "noopener noreferrer",
8922
- style: HOVER_CARD_STYLE,
8923
- onMouseEnter: handleHoverEnter,
8924
- onMouseLeave: handleHoverLeave,
8925
- children: [
8926
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: task.description ? 4 : 0, children: [
8927
- /* @__PURE__ */ jsx(Badge, { size: "xs", color: "orange", variant: "light", children: "pending" }),
8928
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatRelativeTime3(task.createdAt) })
8929
- ] }),
8930
- task.description && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", lineClamp: 2, children: task.description })
8931
- ]
8932
- },
8933
- task.id
8934
- )) })
8935
- ] }) : checkpointTasksData ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No pending tasks" }) : null })
8936
- ] })
8937
- }
8938
- );
8939
- }
8940
5231
  function WorkflowExecutionPanel({
8941
5232
  resourceId,
8942
5233
  resourceDefinition,
@@ -9121,6 +5412,81 @@ function ExecutionPanel({
9121
5412
  return isWorkflowDefinition2(resourceDefinition) ? /* @__PURE__ */ jsx(WorkflowExecutionPanel, { ...diProps, resourceDefinition }) : /* @__PURE__ */ jsx(ResourceDefinitionError, { resourceId, resourceType, resourceName });
9122
5413
  }
9123
5414
  }
5415
+ function ExecuteWorkflowModal({
5416
+ opened,
5417
+ onClose,
5418
+ resource,
5419
+ isPending = false,
5420
+ error,
5421
+ result,
5422
+ onViewExecution,
5423
+ onReset,
5424
+ children
5425
+ }) {
5426
+ const canClose = !isPending;
5427
+ const title = resource.name ?? resource.resourceId;
5428
+ return /* @__PURE__ */ jsx(
5429
+ Modal,
5430
+ {
5431
+ opened,
5432
+ onClose: canClose ? onClose : () => void 0,
5433
+ centered: true,
5434
+ size: "lg",
5435
+ closeOnClickOutside: canClose,
5436
+ closeOnEscape: canClose,
5437
+ withCloseButton: canClose,
5438
+ title: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
5439
+ /* @__PURE__ */ jsxs(Text, { fw: 600, children: [
5440
+ "Run ",
5441
+ resource.resourceType
5442
+ ] }),
5443
+ /* @__PURE__ */ jsx(Badge, { color: "blue", variant: "light", size: "sm", children: resource.resourceType })
5444
+ ] }),
5445
+ children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
5446
+ /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", children: [
5447
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Target:" }),
5448
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, children: title }),
5449
+ /* @__PURE__ */ jsx(Code, { children: resource.resourceId })
5450
+ ] }),
5451
+ /* @__PURE__ */ jsx(Divider, {}),
5452
+ result ? /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
5453
+ /* @__PURE__ */ jsx(Alert, { variant: "light", color: "teal", title: "Execution started", icon: /* @__PURE__ */ jsx(IconCheck, { size: 16 }), children: /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
5454
+ /* @__PURE__ */ jsxs(Text, { size: "sm", children: [
5455
+ "The ",
5456
+ resource.resourceType,
5457
+ " is now running."
5458
+ ] }),
5459
+ /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
5460
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Execution ID:" }),
5461
+ /* @__PURE__ */ jsx(Code, { children: result.executionId })
5462
+ ] })
5463
+ ] }) }),
5464
+ /* @__PURE__ */ jsxs(Group, { justify: "flex-end", gap: "xs", children: [
5465
+ onReset && /* @__PURE__ */ jsx(Button, { variant: "default", onClick: onReset, children: "Run again" }),
5466
+ onViewExecution && /* @__PURE__ */ jsx(
5467
+ Button,
5468
+ {
5469
+ leftSection: /* @__PURE__ */ jsx(IconExternalLink, { size: 16 }),
5470
+ onClick: () => onViewExecution(result.executionId),
5471
+ children: "View execution"
5472
+ }
5473
+ ),
5474
+ /* @__PURE__ */ jsx(Button, { variant: "light", onClick: onClose, children: "Close" })
5475
+ ] })
5476
+ ] }) : error ? /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
5477
+ /* @__PURE__ */ jsx(Alert, { variant: "light", color: "red", title: "Execution failed to start", icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), children: /* @__PURE__ */ jsx(Text, { size: "sm", children: error.message || "An unknown error occurred." }) }),
5478
+ /* @__PURE__ */ jsxs(Group, { justify: "flex-end", gap: "xs", children: [
5479
+ onReset && /* @__PURE__ */ jsx(Button, { variant: "default", onClick: onReset, children: "Try again" }),
5480
+ /* @__PURE__ */ jsx(Button, { variant: "light", onClick: onClose, children: "Close" })
5481
+ ] })
5482
+ ] }) : /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
5483
+ /* @__PURE__ */ jsx(LoadingOverlay, { visible: isPending, zIndex: 1e3, overlayProps: { blur: 2 } }),
5484
+ children ?? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No input form provided." })
5485
+ ] })
5486
+ ] })
5487
+ }
5488
+ );
5489
+ }
9124
5490
  function SessionListItem({ session, onClick, isSelected = false, onDeleted }) {
9125
5491
  const deleteSession = useDeleteSession();
9126
5492
  const [isDeleting, setIsDeleting] = useState(false);
@@ -10248,10 +6614,10 @@ var defaultOperationsSidebarWidth = 250;
10248
6614
  var operationsManifest = {
10249
6615
  key: "operations",
10250
6616
  featureId: "operations",
10251
- capabilityIds: ["operations.command-view"],
6617
+ capabilityIds: ["knowledge.command-view"],
10252
6618
  icon: IconCode,
10253
6619
  sidebar: OperationsSidebar,
10254
- sidebarWidth: ({ currentPath }) => currentPath.startsWith("/operations/command-view") ? commandViewSidebarWidth : defaultOperationsSidebarWidth
6620
+ sidebarWidth: ({ currentPath }) => currentPath.startsWith("/knowledge/command-view") ? commandViewSidebarWidth : defaultOperationsSidebarWidth
10255
6621
  };
10256
6622
 
10257
- export { ActionModal, AgentDefinitionDisplay, AgentExecutionLogs, AgentExecutionPanel, AgentSessionGroup, BaseExecutionLogs, BaseExecutionLogsHeader, BaseExecutionLogsStates, CheckpointGroup, CollapsibleJsonSection, CommandQueueDetailPage, CommandQueuePage, CommandQueueShell, CommandQueueSidebar, CommandQueueSidebarMiddle, CommandQueueSidebarTop, CommandQueueTaskRow, CommandViewPage, CommandViewSidebarContent, ConfigCard, ContentSections, ContextUsageBadge, ContractDisplay, ExecuteWorkflowModal, ExecutionErrorSection, ExecutionPanel, LogEntry, LogGroup, NewKnowledgeMapEdge, NewKnowledgeMapGraph, NewKnowledgeMapNode, OperationsSidebar, OperationsSidebarMiddle, OperationsSidebarTop, OrganizationGraphPage, ResourceDefinitionSection, ResourceDetailPage, ResourceErrorState, ResourceExecuteDialog, ResourceExecuteForm, ResourceFilter, ResourceHeader, ResourceNotFoundState, ResourcesPage, ResourcesSidebar, SessionChatArea, SessionChatInterface, SessionChatPage, SessionDetailsSidebar, SessionExecutionLogs, SessionHeader, SessionListItem, SessionMemory, SessionsPage, SessionsSidebar, ToolsListDisplay, WorkflowDefinitionDisplay, WorkflowExecutionLogs, WorkflowExecutionPanel, getExecutionStatusConfig, getIcon, getLogLevelConfig, iconMap, operationsManifest, useNewKnowledgeMapLayout };
6623
+ export { ActionModal, AgentDefinitionDisplay, AgentExecutionLogs, AgentExecutionPanel, AgentSessionGroup, BaseExecutionLogs, BaseExecutionLogsHeader, BaseExecutionLogsStates, CheckpointGroup, CollapsibleJsonSection, CommandQueueDetailPage, CommandQueuePage, CommandQueueShell, CommandQueueSidebar, CommandQueueSidebarMiddle, CommandQueueSidebarTop, CommandQueueTaskRow, CommandViewPage, ConfigCard, ContentSections, ContextUsageBadge, ContractDisplay, ExecuteWorkflowModal, ExecutionErrorSection, ExecutionPanel, LogEntry, LogGroup, NewKnowledgeMapEdge, NewKnowledgeMapGraph, NewKnowledgeMapNode, OperationsSidebar, OperationsSidebarMiddle, OperationsSidebarTop, OrganizationGraphPage, ResourceDefinitionSection, ResourceDetailPage, ResourceErrorState, ResourceFilter, ResourceHeader, ResourceNotFoundState, ResourcesPage, ResourcesSidebar, SessionChatArea, SessionChatInterface, SessionChatPage, SessionDetailsSidebar, SessionExecutionLogs, SessionHeader, SessionListItem, SessionMemory, SessionsPage, SessionsSidebar, ToolsListDisplay, WorkflowDefinitionDisplay, WorkflowExecutionLogs, WorkflowExecutionPanel, getExecutionStatusConfig, getIcon, getLogLevelConfig, iconMap, operationsManifest, useNewKnowledgeMapLayout };