@elevasis/ui 2.21.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/app/index.js +2 -2
  2. package/dist/{chunk-DMYELNGA.js → chunk-3HEUGBOT.js} +1 -1
  3. package/dist/{chunk-KVW56ERD.js → chunk-AXXTN44Z.js} +5 -3
  4. package/dist/{chunk-7GG6OSD7.js → chunk-B4FHWKEF.js} +3354 -2918
  5. package/dist/{chunk-XLZZOFGM.js → chunk-BSZRKBAW.js} +275 -76
  6. package/dist/{chunk-CZK67OHH.js → chunk-COG4ABRI.js} +3 -3
  7. package/dist/{chunk-S7RL77QS.js → chunk-DDZOHLHB.js} +1 -1
  8. package/dist/{chunk-I5WRKH25.js → chunk-GJ7EIABJ.js} +1 -1
  9. package/dist/{chunk-LQU62KHD.js → chunk-IBUYJXA3.js} +1209 -705
  10. package/dist/{chunk-EDX6WIN3.js → chunk-IOTLB6ND.js} +3 -3
  11. package/dist/{chunk-GBMNCNHX.js → chunk-KVJ3LFH2.js} +3 -1
  12. package/dist/{chunk-VQESMHQV.js → chunk-LJWV4TWV.js} +1 -2
  13. package/dist/{chunk-EGKNRM6P.js → chunk-LKVBEE63.js} +2 -2
  14. package/dist/{chunk-BJWIKEQG.js → chunk-LVJGPE6H.js} +6 -14
  15. package/dist/{chunk-TIIPYB2Z.js → chunk-QZJM3RYI.js} +1 -1
  16. package/dist/{chunk-7YQKVWSD.js → chunk-SQ5JGELM.js} +25 -5
  17. package/dist/{chunk-RX4UWZZR.js → chunk-TKAYX2SP.js} +8 -3
  18. package/dist/{chunk-ATEHYDL3.js → chunk-WWJ6S2HQ.js} +6 -2
  19. package/dist/{chunk-Q5HC6ENG.js → chunk-XOTJNW4Q.js} +1 -1
  20. package/dist/{chunk-ULZ2B3NC.js → chunk-ZBCTB5CA.js} +1 -1
  21. package/dist/components/index.css +85 -85
  22. package/dist/components/index.d.ts +1646 -1381
  23. package/dist/components/index.js +236 -30
  24. package/dist/components/navigation/index.css +589 -0
  25. package/dist/components/navigation/index.js +3 -3
  26. package/dist/features/auth/index.css +2 -2
  27. package/dist/features/auth/index.d.ts +184 -3
  28. package/dist/features/crm/index.css +2 -2
  29. package/dist/features/crm/index.d.ts +189 -3
  30. package/dist/features/crm/index.js +10 -10
  31. package/dist/features/dashboard/index.css +2 -2
  32. package/dist/features/dashboard/index.js +9 -9
  33. package/dist/features/delivery/index.css +85 -85
  34. package/dist/features/delivery/index.d.ts +189 -3
  35. package/dist/features/delivery/index.js +10 -10
  36. package/dist/features/lead-gen/index.css +2 -2
  37. package/dist/features/lead-gen/index.d.ts +5 -0
  38. package/dist/features/lead-gen/index.js +10 -10
  39. package/dist/features/monitoring/index.css +85 -85
  40. package/dist/features/monitoring/index.d.ts +6 -1
  41. package/dist/features/monitoring/index.js +11 -11
  42. package/dist/features/monitoring/requests/index.css +2 -2
  43. package/dist/features/monitoring/requests/index.d.ts +5 -0
  44. package/dist/features/monitoring/requests/index.js +9 -9
  45. package/dist/features/operations/index.css +2 -2
  46. package/dist/features/operations/index.d.ts +7 -4
  47. package/dist/features/operations/index.js +12 -12
  48. package/dist/features/seo/index.d.ts +5 -0
  49. package/dist/features/settings/index.css +2 -2
  50. package/dist/features/settings/index.d.ts +210 -9
  51. package/dist/features/settings/index.js +11 -11
  52. package/dist/graph/index.css +2 -2
  53. package/dist/hooks/delivery/index.css +2 -2
  54. package/dist/hooks/delivery/index.d.ts +184 -3
  55. package/dist/hooks/index.css +85 -85
  56. package/dist/hooks/index.d.ts +1815 -1515
  57. package/dist/hooks/index.js +8 -8
  58. package/dist/hooks/published.css +85 -85
  59. package/dist/hooks/published.d.ts +1815 -1515
  60. package/dist/hooks/published.js +8 -8
  61. package/dist/index.css +12 -12
  62. package/dist/index.d.ts +322 -16
  63. package/dist/index.js +9 -9
  64. package/dist/initialization/index.d.ts +184 -3
  65. package/dist/layout/index.js +2 -2
  66. package/dist/organization/index.css +589 -0
  67. package/dist/organization/index.js +1 -1
  68. package/dist/profile/index.d.ts +184 -3
  69. package/dist/provider/index.css +384 -0
  70. package/dist/provider/index.d.ts +6 -0
  71. package/dist/provider/index.js +7 -7
  72. package/dist/provider/published.css +463 -0
  73. package/dist/provider/published.d.ts +6 -0
  74. package/dist/provider/published.js +4 -4
  75. package/dist/supabase/index.d.ts +359 -6
  76. package/dist/test-utils/index.d.ts +46 -2
  77. package/dist/test-utils/index.js +102 -1
  78. package/dist/theme/index.js +2 -2
  79. package/dist/types/index.d.ts +195 -6
  80. package/package.json +2 -2
  81. /package/dist/{chunk-6GUW5GGF.js → chunk-6Z3G4U2R.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { MantineSpacing, MantineColor, MantineLoaderComponent, BadgeProps } from '@mantine/core';
3
2
  import * as React$1 from 'react';
4
- import React__default, { ComponentType, ReactNode, CSSProperties, ReactElement } from 'react';
3
+ import React__default, { ReactNode, ComponentType, CSSProperties, ReactElement } from 'react';
4
+ import { MantineSpacing, MantineColor, MantineLoaderComponent, BadgeProps } from '@mantine/core';
5
5
  import { Icon, IconCheck } from '@tabler/icons-react';
6
6
  import { Components } from 'react-markdown';
7
7
  import { z } from 'zod';
@@ -10,771 +10,383 @@ import { NodeProps, Node, EdgeProps, Edge } from '@xyflow/react';
10
10
  export { default as graphStyles } from '../graph/Graph.module.css';
11
11
  import * as _tanstack_react_query from '@tanstack/react-query';
12
12
 
13
- interface EmptyStateProps {
14
- /** Icon component to display (e.g., IconKey from @tabler/icons-react) */
15
- icon: ComponentType<{
16
- size: number;
17
- style?: React.CSSProperties;
18
- }>;
19
- /** Main title text */
20
- title: string;
21
- /** Description text shown below title */
22
- description?: string;
23
- /** Optional action button */
24
- action?: {
25
- label: string;
26
- onClick: () => void;
27
- icon?: ReactNode;
28
- };
29
- /** Vertical padding - defaults to 'xl' */
30
- py?: MantineSpacing;
31
- }
32
13
  /**
33
- * EmptyState - Reusable empty state component for lists and tables
34
- *
35
- * Consolidates the Center + Stack + Icon + Text pattern used across:
36
- * - ApiKeyList.tsx
37
- * - CredentialList.tsx
38
- * - Various other list components
39
- *
40
- * @example
41
- * ```tsx
42
- * <EmptyState
43
- * icon={IconKey}
44
- * title="No API keys yet"
45
- * description="Create your first API key to enable external integrations"
46
- * action={{ label: "Create API Key", onClick: handleCreate }}
47
- * />
48
- * ```
14
+ * Workflow-specific logging types and utilities
49
15
  */
50
- declare function EmptyState({ icon: Icon, title, description, action, py }: EmptyStateProps): react_jsx_runtime.JSX.Element;
51
16
 
52
- interface TabCountBadgeProps {
53
- count: number;
54
- isLoading?: boolean;
17
+ interface WorkflowExecutionContext {
18
+ type: 'workflow';
19
+ contextType: 'workflow-execution';
20
+ executionId: string;
21
+ workflowId: string;
22
+ workflowName?: string;
23
+ organizationId: string;
24
+ executionPath?: string[];
25
+ }
26
+ interface WorkflowFailureContext {
27
+ type: 'workflow';
28
+ contextType: 'workflow-failure';
29
+ executionId: string;
30
+ workflowId: string;
31
+ error: string;
32
+ }
33
+ interface StepStartedContext {
34
+ type: 'workflow';
35
+ contextType: 'step-started';
36
+ stepId: string;
37
+ stepStatus: 'started';
38
+ input: unknown;
39
+ startTime: number;
40
+ }
41
+ interface StepCompletedContext {
42
+ type: 'workflow';
43
+ contextType: 'step-completed';
44
+ stepId: string;
45
+ stepStatus: 'completed';
46
+ output: unknown;
47
+ duration: number;
48
+ isTerminal: boolean;
49
+ startTime: number;
50
+ endTime: number;
51
+ }
52
+ interface StepFailedContext {
53
+ type: 'workflow';
54
+ contextType: 'step-failed';
55
+ stepId: string;
56
+ stepStatus: 'failed';
57
+ error: string;
58
+ duration: number;
59
+ startTime: number;
60
+ endTime: number;
61
+ }
62
+ interface ConditionalRouteContext {
63
+ type: 'workflow';
64
+ contextType: 'conditional-route';
65
+ stepId: string;
66
+ target: string;
67
+ error?: string;
68
+ }
69
+ interface ExecutionPathContext {
70
+ type: 'workflow';
71
+ contextType: 'execution-path';
72
+ executionPath: string[];
73
+ }
74
+ type WorkflowLogContext = WorkflowExecutionContext | WorkflowFailureContext | StepStartedContext | StepCompletedContext | StepFailedContext | ConditionalRouteContext | ExecutionPathContext;
75
+ interface WorkflowLogMessage {
76
+ level: ExecutionLogLevel;
77
+ message: string;
78
+ timestamp: number;
79
+ context?: WorkflowLogContext;
55
80
  }
81
+
56
82
  /**
57
- * A badge that displays a count in tabs with consistent sizing.
58
- * Uses a fixed-width container to prevent layout shift when switching
59
- * between the loading spinner and the count badge.
83
+ * Agent-specific logging types
84
+ * Simplified 2-event model: lifecycle, iteration
85
+ *
86
+ * Design Philosophy:
87
+ * - LIFECYCLE EVENTS: Structural checkpoints (initialization, iteration, completion)
88
+ * - ITERATION EVENTS: Execution activities (reasoning, actions during iterations)
60
89
  */
61
- declare function TabCountBadge({ count, isLoading }: TabCountBadgeProps): react_jsx_runtime.JSX.Element;
62
90
 
63
91
  /**
64
- * TrendIndicator - Reusable component for showing percentage change trends
65
- * Displays up/down/flat arrow with colored badge
92
+ * Agent lifecycle stages
93
+ * Universal checkpoints that apply to all agent executions
66
94
  */
67
- interface TrendIndicatorProps {
68
- /** Current value */
69
- current: number;
70
- /** Previous value to compare against */
71
- previous: number;
72
- /** Optional formatter for the value (not used in display but kept for API compatibility) */
73
- formatter?: (value: number) => string;
74
- /** If true, negative change is considered positive (e.g., for costs) */
75
- inverse?: boolean;
76
- }
95
+ type AgentLifecycle = 'initialization' | 'iteration' | 'completion';
77
96
  /**
78
- * Shows a trend indicator with arrow icon and percentage change badge
79
- *
80
- * @example
81
- * // Positive trend (green when going up)
82
- * <TrendIndicator current={100} previous={80} />
83
- *
84
- * @example
85
- * // Inverse trend (green when going down, useful for costs)
86
- * <TrendIndicator current={100} previous={120} inverse />
97
+ * Iteration event types
98
+ * Activities that occur during agent iterations
87
99
  */
88
- declare function TrendIndicator({ current, previous, inverse }: TrendIndicatorProps): react_jsx_runtime.JSX.Element;
89
-
90
- interface CollapsibleSectionProps {
91
- title: string | ReactNode;
92
- count?: number;
93
- countLabel?: string;
94
- children: ReactNode;
95
- emptyMessage?: string;
96
- defaultExpanded?: boolean;
97
- maxHeight?: number;
100
+ type IterationEventType = 'reasoning' | 'action' | 'tool-call';
101
+ /**
102
+ * Base fields shared by all lifecycle events
103
+ */
104
+ interface AgentLifecycleEventBase {
105
+ type: 'agent';
106
+ agentId: string;
107
+ lifecycle: AgentLifecycle;
108
+ sessionId?: string;
98
109
  }
99
110
  /**
100
- * Reusable collapsible section with header, badge, and scroll area
101
- * Used for expandable content like memory sections, logs, etc.
111
+ * Lifecycle started event - emitted when a phase begins
112
+ * REQUIRED: startTime (phase has started, no end yet)
102
113
  */
103
- declare function CollapsibleSection({ title, count, countLabel, children, emptyMessage, defaultExpanded, maxHeight }: CollapsibleSectionProps): react_jsx_runtime.JSX.Element;
104
-
105
- interface PageTitleCaptionProps {
106
- title: string;
107
- caption?: string;
108
- rightSection?: ReactNode;
114
+ interface AgentLifecycleStartedEvent extends AgentLifecycleEventBase {
115
+ stage: 'started';
116
+ startTime: number;
117
+ iteration?: number;
109
118
  }
110
- declare const PageTitleCaption: ({ title, caption, rightSection }: PageTitleCaptionProps) => react_jsx_runtime.JSX.Element;
111
-
112
- interface StatsCardSkeletonProps {
113
- /** Height of the loader area - defaults to 200 */
114
- chartHeight?: number;
115
- /** Kept for API compat, unused */
116
- withChart?: boolean;
117
- /** Kept for API compat, unused */
118
- statCount?: 2 | 3;
119
+ /**
120
+ * Lifecycle completed event - emitted when a phase succeeds
121
+ * REQUIRED: startTime, endTime, duration (phase has finished successfully)
122
+ */
123
+ interface AgentLifecycleCompletedEvent extends AgentLifecycleEventBase {
124
+ stage: 'completed';
125
+ startTime: number;
126
+ endTime: number;
127
+ duration: number;
128
+ iteration?: number;
129
+ attempts?: number;
130
+ memorySize?: {
131
+ sessionMemoryKeys: number;
132
+ historyEntries: number;
133
+ };
119
134
  }
120
135
  /**
121
- * StatsCardSkeleton - Loading state for dashboard metric cards
122
- *
123
- * Used across:
124
- * - ExecutionHealthCard.tsx
125
- * - CostMetricsCard.tsx
126
- * - ThroughputCard.tsx
127
- * - BusinessImpactCard.tsx
136
+ * Lifecycle failed event - emitted when a phase fails
137
+ * REQUIRED: startTime, endTime, duration, error (phase has finished with error)
128
138
  */
129
- declare function StatsCardSkeleton({ chartHeight }: StatsCardSkeletonProps): react_jsx_runtime.JSX.Element;
130
- interface ListSkeletonProps {
131
- /** Number of rows (used to calculate height) - defaults to 3 */
132
- rows?: number;
133
- /** Height of each row - defaults to 50 */
134
- rowHeight?: number;
139
+ interface AgentLifecycleFailedEvent extends AgentLifecycleEventBase {
140
+ stage: 'failed';
141
+ startTime: number;
142
+ endTime: number;
143
+ duration: number;
144
+ error: string;
145
+ iteration?: number;
135
146
  }
136
147
  /**
137
- * ListSkeleton - Loading state for table/list content
138
- *
139
- * Used across:
140
- * - ApiKeyList.tsx
141
- * - CredentialList.tsx
142
- * - DeploymentList.tsx
143
- * - WebhookEndpointList.tsx
148
+ * Union type for all lifecycle events
149
+ * Discriminated by 'stage' field for type narrowing
144
150
  */
145
- declare function ListSkeleton({ rows, rowHeight }: ListSkeletonProps): react_jsx_runtime.JSX.Element;
146
- interface DetailCardSkeletonProps {
147
- /** Number of detail rows (used to calculate height) - defaults to 3 */
148
- rows?: number;
151
+ type AgentLifecycleEvent = AgentLifecycleStartedEvent | AgentLifecycleCompletedEvent | AgentLifecycleFailedEvent;
152
+ /**
153
+ * Placeholder data for MVP
154
+ * Will be typed per actionType in future
155
+ */
156
+ interface ActionPlaceholderData {
157
+ message: string;
149
158
  }
150
159
  /**
151
- * DetailCardSkeleton - Loading state for cards with list of detail items
152
- *
153
- * Used for cards like CostBreakdownCard
160
+ * Iteration event - captures activities during agent iterations
161
+ * Consolidates reasoning (LLM thought process) and actions (tool use, memory ops, etc.)
154
162
  */
155
- declare function DetailCardSkeleton({ rows }: DetailCardSkeletonProps): react_jsx_runtime.JSX.Element;
156
-
157
- interface NavigationButtonProps {
158
- /** Icon component to display */
159
- icon: React__default.ComponentType<{
160
- size?: number;
161
- stroke?: number;
162
- }>;
163
- /** Button label text */
164
- label: string;
165
- /** Whether the button is in collapsed state (hides text) */
166
- isCollapsed?: boolean;
167
- /** Whether this button has sub-items/links */
168
- hasSubItems?: boolean;
169
- /** Whether sub-items are expanded (controls chevron rotation) */
170
- isExpanded?: boolean;
171
- /** Whether the icon and text should be styled as active */
172
- isActive?: boolean;
173
- /** Whether the background should be styled as active */
174
- hasActiveBackground?: boolean;
175
- /** Click handler */
176
- onClick?: () => void;
177
- /** Additional styles for the button container */
178
- style?: React__default.CSSProperties;
179
- /** Custom transition duration in ms */
180
- transitionDuration?: number;
163
+ interface AgentIterationEvent {
164
+ type: 'agent';
165
+ agentId: string;
166
+ lifecycle: 'iteration';
167
+ eventType: IterationEventType;
168
+ iteration: number;
169
+ sessionId?: string;
170
+ startTime: number;
171
+ endTime: number;
172
+ duration: number;
173
+ output?: string;
174
+ actionType?: string;
175
+ data?: ActionPlaceholderData;
181
176
  }
182
- declare const NavigationButton: React__default.FC<NavigationButtonProps>;
183
-
184
- interface CustomSelectorProps {
185
- value: string | null;
186
- onChange: (value: string | null) => void;
187
- data: {
188
- value: string;
189
- label: string;
190
- }[] | readonly {
191
- value: string;
192
- label: string;
193
- }[];
194
- leftSection?: ReactNode;
195
- placeholder?: string;
196
- w?: number | string;
197
- withCheckIcon?: boolean;
198
- disabled?: boolean;
177
+ /**
178
+ * Tool call event - captures individual tool executions during iterations
179
+ * Provides granular timing for each tool invocation
180
+ */
181
+ interface AgentToolCallEvent {
182
+ type: 'agent';
183
+ agentId: string;
184
+ lifecycle: 'iteration';
185
+ eventType: 'tool-call';
186
+ iteration: number;
187
+ sessionId?: string;
188
+ toolName: string;
189
+ startTime: number;
190
+ endTime: number;
191
+ duration: number;
192
+ success: boolean;
193
+ error?: string;
194
+ input?: Record<string, unknown>;
195
+ output?: unknown;
199
196
  }
200
- declare function CustomSelector({ value, onChange, data, leftSection, placeholder, w, withCheckIcon, disabled }: CustomSelectorProps): react_jsx_runtime.JSX.Element;
197
+ /**
198
+ * Union type for all agent log contexts
199
+ * 3 event types total (lifecycle, iteration, tool-call)
200
+ */
201
+ type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent;
201
202
 
202
- interface APIErrorAlertProps {
203
- /**
204
- * The error to display. Can be an APIClientError, generic Error, or any unknown value.
205
- */
206
- error: unknown;
207
- /**
208
- * Optional title override. If not provided, uses getErrorTitle() based on error code.
209
- */
210
- title?: string;
211
- /**
212
- * Whether to show the request ID (if available). Defaults to true.
213
- */
214
- showRequestId?: boolean;
215
- /**
216
- * Optional custom icon. Defaults to IconAlertCircle.
217
- */
218
- icon?: React.ReactNode;
219
- /**
220
- * Alert color. Defaults to 'red'.
221
- */
222
- color?: string;
223
- }
224
203
  /**
225
- * Alert component for displaying API errors with type-safe error handling.
226
- *
227
- * Automatically extracts error message, code, and request ID from APIClientError
228
- * or falls back to generic Error handling.
229
- *
230
- * @example
231
- * ```tsx
232
- * const { data, error } = useQuery(...)
233
- *
234
- * if (error) {
235
- * return <APIErrorAlert error={error} />
236
- * }
237
- * ```
238
- *
239
- * @example With custom title
240
- * ```tsx
241
- * <APIErrorAlert
242
- * error={error}
243
- * title="Failed to load resources"
244
- * />
245
- * ```
246
- *
247
- * @example Without request ID
248
- * ```tsx
249
- * <APIErrorAlert
250
- * error={error}
251
- * showRequestId={false}
252
- * />
253
- * ```
204
+ * Base execution logger for Execution Engine
254
205
  */
255
- declare function APIErrorAlert({ error, title, showRequestId, icon, color }: APIErrorAlertProps): react_jsx_runtime.JSX.Element;
206
+ type ExecutionLogLevel = 'debug' | 'info' | 'warn' | 'error';
256
207
 
257
- interface CenteredErrorStateProps {
258
- error: unknown;
259
- title?: string;
260
- /** Minimum height of the centering container. Defaults to 300. */
261
- h?: number | string;
262
- /** Vertical padding (used when h is not set). */
263
- py?: MantineSpacing;
208
+ type LogContext = WorkflowLogContext | AgentLogContext;
209
+ interface ExecutionLogMessage {
210
+ level: ExecutionLogLevel;
211
+ message: string;
212
+ timestamp: number;
213
+ context?: LogContext;
264
214
  }
215
+
265
216
  /**
266
- * CenteredErrorState - Displays an error centered inside its container.
267
- *
268
- * The caller is responsible for providing the container (e.g. `<Paper withBorder>`).
269
- * This component only handles centering + rendering the error alert.
270
- *
271
- * @example
272
- * ```tsx
273
- * if (error) {
274
- * return (
275
- * <Paper withBorder>
276
- * <CenteredErrorState error={error} title="Failed to load trends" />
277
- * </Paper>
278
- * )
279
- * }
280
- * ```
217
+ * Shared form field types for dynamic form generation
218
+ * Used by: Command Queue, Execution Runner UI, future form-based features
281
219
  */
282
- declare function CenteredErrorState({ error, title, h, py }: CenteredErrorStateProps): react_jsx_runtime.JSX.Element;
283
-
284
- interface StatCardBaseProps {
285
- /** The label/description text */
220
+ /**
221
+ * Supported form field types for action payloads
222
+ * Maps to Mantine form components
223
+ */
224
+ type FormFieldType = 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | 'richtext';
225
+ /**
226
+ * Form field definition
227
+ */
228
+ interface FormField {
229
+ /** Field key in payload object */
230
+ name: string;
231
+ /** Field label for UI */
286
232
  label: string;
287
- /** The value to display (number or formatted string) */
288
- value: string | number;
289
- /** Tabler icon component */
290
- icon: Icon;
291
- /** Optional extra content rendered below the label */
292
- children?: ReactNode;
293
- }
294
- interface StatCardDefaultProps extends StatCardBaseProps {
295
- variant?: 'default';
296
- /** Theme color for the icon (defaults to theme primary) */
297
- color?: MantineColor;
298
- isLoading?: never;
299
- valueColor?: never;
233
+ /** Field type (determines UI component) */
234
+ type: FormFieldType;
235
+ /** Default value */
236
+ defaultValue?: unknown;
237
+ /** Required field */
238
+ required?: boolean;
239
+ /** Placeholder text */
240
+ placeholder?: string;
241
+ /** Help text */
242
+ description?: string;
243
+ /** Options for select/radio */
244
+ options?: Array<{
245
+ label: string;
246
+ value: string | number;
247
+ }>;
248
+ /** Min/max for number */
249
+ min?: number;
250
+ max?: number;
251
+ /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
252
+ defaultValueFromContext?: string;
300
253
  }
301
- interface StatCardHeroProps extends StatCardBaseProps {
302
- variant: 'hero';
303
- /** Whether data is loading */
304
- isLoading?: boolean;
305
- /** Custom color for the value text */
306
- valueColor?: string;
307
- /** Card sizing — 'sm' (default) for compact layouts, 'md' for spacious layouts */
308
- size?: 'sm' | 'md';
309
- color?: never;
254
+ /**
255
+ * Form schema for action payload collection
256
+ */
257
+ interface FormSchema {
258
+ /** Form title */
259
+ title?: string;
260
+ /** Form description */
261
+ description?: string;
262
+ /** Form fields */
263
+ fields: FormField[];
310
264
  }
311
- type StatCardProps = StatCardDefaultProps | StatCardHeroProps;
265
+
312
266
  /**
313
- * StatCard - Stat display card with icon, label, and value.
314
- *
315
- * Supports two variants:
316
- * - `default`: Compact card with ThemeIcon (used in admin overviews)
317
- * - `hero`: Glass card with glowing icon ring (used on dashboards)
318
- *
319
- * @example
320
- * ```tsx
321
- * // Default variant
322
- * <StatCard label="Total Executions" value={150} icon={IconPlayerPlay} color="blue" />
267
+ * Serialized Registry Types
323
268
  *
324
- * // Hero variant
325
- * <StatCard variant="hero" label="Executions" value={43} icon={IconPlayerPlay} isLoading={false} />
326
- * ```
269
+ * Pre-computed JSON-safe types for API responses and Command View.
270
+ * Serialization happens once at API startup, enabling instant response times.
327
271
  */
328
- declare function StatCard(props: StatCardProps): react_jsx_runtime.JSX.Element;
272
+
329
273
  /**
330
- * StatCardSkeleton - Loading skeleton for StatCard (default variant)
274
+ * Serialized form field for API responses
331
275
  */
332
- declare function StatCardSkeleton(): react_jsx_runtime.JSX.Element;
333
-
334
- interface StyledMarkdownProps {
335
- /** Markdown content to render */
336
- children: string;
337
- /** Custom component overrides */
338
- components?: Partial<Components>;
339
- /** Additional class name */
340
- className?: string;
341
- /** Inline styles for the wrapper div */
342
- style?: React.CSSProperties;
276
+ interface SerializedFormField {
277
+ name: string;
278
+ label: string;
279
+ type: FormFieldType;
280
+ defaultValue?: unknown;
281
+ required?: boolean;
282
+ placeholder?: string;
283
+ description?: string;
284
+ options?: Array<{
285
+ label: string;
286
+ value: string | number;
287
+ }>;
288
+ min?: number;
289
+ max?: number;
343
290
  }
344
291
  /**
345
- * Styled markdown renderer with Mantine components and syntax highlighting
346
- *
347
- * Features:
348
- * - Colored headings using theme primary color
349
- * - Syntax-highlighted code blocks (oneDark theme, no token backgrounds)
350
- * - Styled inline code with Mantine Code component
351
- * - Styled blockquotes with left border
352
- * - Proper list styling
353
- *
354
- * @example
355
- * ```tsx
356
- * import { StyledMarkdown } from '@repo/ui'
357
- *
358
- * <StyledMarkdown>{markdownContent}</StyledMarkdown>
359
- * ```
292
+ * Serialized form schema for API responses
360
293
  */
361
- declare function StyledMarkdown({ children, components, className, style }: StyledMarkdownProps): react_jsx_runtime.JSX.Element;
362
-
363
- interface JsonViewerProps {
364
- /** JSON data to display (will be stringified) or pre-formatted JSON string */
365
- data: unknown;
366
- /** Maximum height with scroll (e.g., '300px'). If not set, expands to content */
367
- maxHeight?: string | number;
368
- /** Font size override */
369
- fontSize?: string | number;
294
+ interface SerializedFormSchema {
295
+ title?: string;
296
+ description?: string;
297
+ fields: SerializedFormField[];
298
+ layout?: 'vertical' | 'horizontal' | 'grid';
370
299
  }
371
300
  /**
372
- * Syntax-highlighted JSON viewer component
373
- *
374
- * @example
375
- * ```tsx
376
- * import { JsonViewer } from '@repo/ui'
377
- *
378
- * <JsonViewer data={{ foo: 'bar', count: 42 }} />
379
- * <JsonViewer data={apiResponse} maxHeight={300} />
380
- * ```
301
+ * Serialized execution form schema for API responses
381
302
  */
382
- declare function JsonViewer({ data, maxHeight, fontSize }: JsonViewerProps): react_jsx_runtime.JSX.Element;
383
-
384
- interface ContextViewerProps {
385
- /** Any JSON-serializable data to display in a human-readable format */
386
- data: unknown;
303
+ interface SerializedExecutionFormSchema extends SerializedFormSchema {
304
+ fieldMappings?: Record<string, string>;
305
+ submitButton?: {
306
+ label?: string;
307
+ loadingLabel?: string;
308
+ confirmMessage?: string;
309
+ };
387
310
  }
388
311
  /**
389
- * Auto-formats any JSON context into a human-readable layout.
390
- *
391
- * - Strings → rendered as markdown (supports formatting, lists, tables)
392
- * - Flat key-value objects → labeled field list
393
- * - Nested objects → indented subsections with left border
394
- * - Arrays → bulleted lists or bordered cards
395
- * - null/undefined/boolean/number → inline text
396
- *
397
- * No display configuration needed — the component infers layout from data shape.
398
- */
399
- declare function ContextViewer({ data }: ContextViewerProps): react_jsx_runtime.JSX.Element;
400
-
401
- /**
402
- * Workflow-specific logging types and utilities
312
+ * Serialized schedule config for API responses
403
313
  */
404
-
405
- interface WorkflowExecutionContext {
406
- type: 'workflow';
407
- contextType: 'workflow-execution';
408
- executionId: string;
409
- workflowId: string;
410
- workflowName?: string;
411
- organizationId: string;
412
- executionPath?: string[];
413
- }
414
- interface WorkflowFailureContext {
415
- type: 'workflow';
416
- contextType: 'workflow-failure';
417
- executionId: string;
418
- workflowId: string;
419
- error: string;
420
- }
421
- interface StepStartedContext {
422
- type: 'workflow';
423
- contextType: 'step-started';
424
- stepId: string;
425
- stepStatus: 'started';
426
- input: unknown;
427
- startTime: number;
428
- }
429
- interface StepCompletedContext {
430
- type: 'workflow';
431
- contextType: 'step-completed';
432
- stepId: string;
433
- stepStatus: 'completed';
434
- output: unknown;
435
- duration: number;
436
- isTerminal: boolean;
437
- startTime: number;
438
- endTime: number;
439
- }
440
- interface StepFailedContext {
441
- type: 'workflow';
442
- contextType: 'step-failed';
443
- stepId: string;
444
- stepStatus: 'failed';
445
- error: string;
446
- duration: number;
447
- startTime: number;
448
- endTime: number;
449
- }
450
- interface ConditionalRouteContext {
451
- type: 'workflow';
452
- contextType: 'conditional-route';
453
- stepId: string;
454
- target: string;
455
- error?: string;
456
- }
457
- interface ExecutionPathContext {
458
- type: 'workflow';
459
- contextType: 'execution-path';
460
- executionPath: string[];
461
- }
462
- type WorkflowLogContext = WorkflowExecutionContext | WorkflowFailureContext | StepStartedContext | StepCompletedContext | StepFailedContext | ConditionalRouteContext | ExecutionPathContext;
463
- interface WorkflowLogMessage {
464
- level: ExecutionLogLevel;
465
- message: string;
466
- timestamp: number;
467
- context?: WorkflowLogContext;
314
+ interface SerializedScheduleConfig {
315
+ enabled: boolean;
316
+ defaultSchedule?: string;
317
+ allowedPatterns?: string[];
468
318
  }
469
-
470
- /**
471
- * Agent-specific logging types
472
- * Simplified 2-event model: lifecycle, iteration
473
- *
474
- * Design Philosophy:
475
- * - LIFECYCLE EVENTS: Structural checkpoints (initialization, iteration, completion)
476
- * - ITERATION EVENTS: Execution activities (reasoning, actions during iterations)
477
- */
478
-
479
319
  /**
480
- * Agent lifecycle stages
481
- * Universal checkpoints that apply to all agent executions
482
- */
483
- type AgentLifecycle = 'initialization' | 'iteration' | 'completion';
484
- /**
485
- * Iteration event types
486
- * Activities that occur during agent iterations
487
- */
488
- type IterationEventType = 'reasoning' | 'action' | 'tool-call';
489
- /**
490
- * Base fields shared by all lifecycle events
320
+ * Serialized webhook config for API responses
491
321
  */
492
- interface AgentLifecycleEventBase {
493
- type: 'agent';
494
- agentId: string;
495
- lifecycle: AgentLifecycle;
496
- sessionId?: string;
322
+ interface SerializedWebhookConfig {
323
+ enabled: boolean;
324
+ payloadSchema?: unknown;
497
325
  }
498
326
  /**
499
- * Lifecycle started event - emitted when a phase begins
500
- * REQUIRED: startTime (phase has started, no end yet)
327
+ * Serialized execution interface for API responses
501
328
  */
502
- interface AgentLifecycleStartedEvent extends AgentLifecycleEventBase {
503
- stage: 'started';
504
- startTime: number;
505
- iteration?: number;
329
+ interface SerializedExecutionInterface {
330
+ form: SerializedExecutionFormSchema;
331
+ schedule?: SerializedScheduleConfig;
332
+ webhook?: SerializedWebhookConfig;
506
333
  }
507
334
  /**
508
- * Lifecycle completed event - emitted when a phase succeeds
509
- * REQUIRED: startTime, endTime, duration (phase has finished successfully)
335
+ * Serialized agent definition (JSON-safe)
336
+ * Result of serializeDefinition(AgentDefinition)
510
337
  */
511
- interface AgentLifecycleCompletedEvent extends AgentLifecycleEventBase {
512
- stage: 'completed';
513
- startTime: number;
514
- endTime: number;
515
- duration: number;
516
- iteration?: number;
517
- attempts?: number;
518
- memorySize?: {
519
- sessionMemoryKeys: number;
520
- historyEntries: number;
338
+ interface SerializedAgentDefinition {
339
+ config: {
340
+ resourceId: string;
341
+ name: string;
342
+ description: string;
343
+ version: string;
344
+ type: 'agent';
345
+ status: 'dev' | 'prod';
346
+ links?: ResourceLink[];
347
+ category?: ResourceCategory;
348
+ /** Whether this resource is archived and should be excluded from registration and deployment */
349
+ archived?: boolean;
350
+ systemPrompt: string;
351
+ constraints?: {
352
+ maxIterations?: number;
353
+ timeout?: number;
354
+ maxSessionMemoryKeys?: number;
355
+ maxMemoryTokens?: number;
356
+ };
357
+ sessionCapable?: boolean;
358
+ memoryPreferences?: string;
359
+ };
360
+ modelConfig: {
361
+ provider: string;
362
+ model: string;
363
+ apiKey: string;
364
+ temperature: number;
365
+ maxOutputTokens: number;
366
+ topP?: number;
367
+ modelOptions?: Record<string, unknown>;
368
+ };
369
+ contract: {
370
+ inputSchema: object;
371
+ outputSchema?: object;
372
+ };
373
+ tools: Array<{
374
+ name: string;
375
+ description: string;
376
+ inputSchema?: object;
377
+ outputSchema?: object;
378
+ }>;
379
+ knowledgeMap?: {
380
+ nodeCount: number;
381
+ nodes: Array<{
382
+ id: string;
383
+ description: string;
384
+ loaded: boolean;
385
+ hasPrompt: boolean;
386
+ }>;
521
387
  };
522
- }
523
- /**
524
- * Lifecycle failed event - emitted when a phase fails
525
- * REQUIRED: startTime, endTime, duration, error (phase has finished with error)
526
- */
527
- interface AgentLifecycleFailedEvent extends AgentLifecycleEventBase {
528
- stage: 'failed';
529
- startTime: number;
530
- endTime: number;
531
- duration: number;
532
- error: string;
533
- iteration?: number;
534
- }
535
- /**
536
- * Union type for all lifecycle events
537
- * Discriminated by 'stage' field for type narrowing
538
- */
539
- type AgentLifecycleEvent = AgentLifecycleStartedEvent | AgentLifecycleCompletedEvent | AgentLifecycleFailedEvent;
540
- /**
541
- * Placeholder data for MVP
542
- * Will be typed per actionType in future
543
- */
544
- interface ActionPlaceholderData {
545
- message: string;
546
- }
547
- /**
548
- * Iteration event - captures activities during agent iterations
549
- * Consolidates reasoning (LLM thought process) and actions (tool use, memory ops, etc.)
550
- */
551
- interface AgentIterationEvent {
552
- type: 'agent';
553
- agentId: string;
554
- lifecycle: 'iteration';
555
- eventType: IterationEventType;
556
- iteration: number;
557
- sessionId?: string;
558
- startTime: number;
559
- endTime: number;
560
- duration: number;
561
- output?: string;
562
- actionType?: string;
563
- data?: ActionPlaceholderData;
564
- }
565
- /**
566
- * Tool call event - captures individual tool executions during iterations
567
- * Provides granular timing for each tool invocation
568
- */
569
- interface AgentToolCallEvent {
570
- type: 'agent';
571
- agentId: string;
572
- lifecycle: 'iteration';
573
- eventType: 'tool-call';
574
- iteration: number;
575
- sessionId?: string;
576
- toolName: string;
577
- startTime: number;
578
- endTime: number;
579
- duration: number;
580
- success: boolean;
581
- error?: string;
582
- input?: Record<string, unknown>;
583
- output?: unknown;
584
- }
585
- /**
586
- * Union type for all agent log contexts
587
- * 3 event types total (lifecycle, iteration, tool-call)
588
- */
589
- type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent;
590
-
591
- /**
592
- * Base execution logger for Execution Engine
593
- */
594
- type ExecutionLogLevel = 'debug' | 'info' | 'warn' | 'error';
595
-
596
- type LogContext = WorkflowLogContext | AgentLogContext;
597
- interface ExecutionLogMessage {
598
- level: ExecutionLogLevel;
599
- message: string;
600
- timestamp: number;
601
- context?: LogContext;
602
- }
603
-
604
- /**
605
- * Shared form field types for dynamic form generation
606
- * Used by: Command Queue, Execution Runner UI, future form-based features
607
- */
608
- /**
609
- * Supported form field types for action payloads
610
- * Maps to Mantine form components
611
- */
612
- type FormFieldType = 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | 'richtext';
613
- /**
614
- * Form field definition
615
- */
616
- interface FormField {
617
- /** Field key in payload object */
618
- name: string;
619
- /** Field label for UI */
620
- label: string;
621
- /** Field type (determines UI component) */
622
- type: FormFieldType;
623
- /** Default value */
624
- defaultValue?: unknown;
625
- /** Required field */
626
- required?: boolean;
627
- /** Placeholder text */
628
- placeholder?: string;
629
- /** Help text */
630
- description?: string;
631
- /** Options for select/radio */
632
- options?: Array<{
633
- label: string;
634
- value: string | number;
635
- }>;
636
- /** Min/max for number */
637
- min?: number;
638
- max?: number;
639
- /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
640
- defaultValueFromContext?: string;
641
- }
642
- /**
643
- * Form schema for action payload collection
644
- */
645
- interface FormSchema {
646
- /** Form title */
647
- title?: string;
648
- /** Form description */
649
- description?: string;
650
- /** Form fields */
651
- fields: FormField[];
652
- }
653
-
654
- /**
655
- * Serialized Registry Types
656
- *
657
- * Pre-computed JSON-safe types for API responses and Command View.
658
- * Serialization happens once at API startup, enabling instant response times.
659
- */
660
-
661
- /**
662
- * Serialized form field for API responses
663
- */
664
- interface SerializedFormField {
665
- name: string;
666
- label: string;
667
- type: FormFieldType;
668
- defaultValue?: unknown;
669
- required?: boolean;
670
- placeholder?: string;
671
- description?: string;
672
- options?: Array<{
673
- label: string;
674
- value: string | number;
675
- }>;
676
- min?: number;
677
- max?: number;
678
- }
679
- /**
680
- * Serialized form schema for API responses
681
- */
682
- interface SerializedFormSchema {
683
- title?: string;
684
- description?: string;
685
- fields: SerializedFormField[];
686
- layout?: 'vertical' | 'horizontal' | 'grid';
687
- }
688
- /**
689
- * Serialized execution form schema for API responses
690
- */
691
- interface SerializedExecutionFormSchema extends SerializedFormSchema {
692
- fieldMappings?: Record<string, string>;
693
- submitButton?: {
694
- label?: string;
695
- loadingLabel?: string;
696
- confirmMessage?: string;
697
- };
698
- }
699
- /**
700
- * Serialized schedule config for API responses
701
- */
702
- interface SerializedScheduleConfig {
703
- enabled: boolean;
704
- defaultSchedule?: string;
705
- allowedPatterns?: string[];
706
- }
707
- /**
708
- * Serialized webhook config for API responses
709
- */
710
- interface SerializedWebhookConfig {
711
- enabled: boolean;
712
- payloadSchema?: unknown;
713
- }
714
- /**
715
- * Serialized execution interface for API responses
716
- */
717
- interface SerializedExecutionInterface {
718
- form: SerializedExecutionFormSchema;
719
- schedule?: SerializedScheduleConfig;
720
- webhook?: SerializedWebhookConfig;
721
- }
722
- /**
723
- * Serialized agent definition (JSON-safe)
724
- * Result of serializeDefinition(AgentDefinition)
725
- */
726
- interface SerializedAgentDefinition {
727
- config: {
728
- resourceId: string;
729
- name: string;
730
- description: string;
731
- version: string;
732
- type: 'agent';
733
- status: 'dev' | 'prod';
734
- links?: ResourceLink[];
735
- category?: ResourceCategory;
736
- /** Whether this resource is archived and should be excluded from registration and deployment */
737
- archived?: boolean;
738
- systemPrompt: string;
739
- constraints?: {
740
- maxIterations?: number;
741
- timeout?: number;
742
- maxSessionMemoryKeys?: number;
743
- maxMemoryTokens?: number;
744
- };
745
- sessionCapable?: boolean;
746
- memoryPreferences?: string;
747
- };
748
- modelConfig: {
749
- provider: string;
750
- model: string;
751
- apiKey: string;
752
- temperature: number;
753
- maxOutputTokens: number;
754
- topP?: number;
755
- modelOptions?: Record<string, unknown>;
756
- };
757
- contract: {
758
- inputSchema: object;
759
- outputSchema?: object;
760
- };
761
- tools: Array<{
762
- name: string;
763
- description: string;
764
- inputSchema?: object;
765
- outputSchema?: object;
766
- }>;
767
- knowledgeMap?: {
768
- nodeCount: number;
769
- nodes: Array<{
770
- id: string;
771
- description: string;
772
- loaded: boolean;
773
- hasPrompt: boolean;
774
- }>;
775
- };
776
- metricsConfig?: object;
777
- interface?: SerializedExecutionInterface;
388
+ metricsConfig?: object;
389
+ interface?: SerializedExecutionInterface;
778
390
  }
779
391
  /**
780
392
  * Serialized workflow definition (JSON-safe)
@@ -2555,6 +2167,7 @@ type Database = {
2555
2167
  Row: {
2556
2168
  config: Json;
2557
2169
  created_at: string | null;
2170
+ effective_permissions: string[];
2558
2171
  id: string;
2559
2172
  membership_status: string | null;
2560
2173
  organization_id: string;
@@ -2566,6 +2179,7 @@ type Database = {
2566
2179
  Insert: {
2567
2180
  config?: Json;
2568
2181
  created_at?: string | null;
2182
+ effective_permissions?: string[];
2569
2183
  id?: string;
2570
2184
  membership_status?: string | null;
2571
2185
  organization_id: string;
@@ -2577,6 +2191,7 @@ type Database = {
2577
2191
  Update: {
2578
2192
  config?: Json;
2579
2193
  created_at?: string | null;
2194
+ effective_permissions?: string[];
2580
2195
  id?: string;
2581
2196
  membership_status?: string | null;
2582
2197
  organization_id?: string;
@@ -2602,6 +2217,147 @@ type Database = {
2602
2217
  }
2603
2218
  ];
2604
2219
  };
2220
+ org_rol_assignments: {
2221
+ Row: {
2222
+ granted_at: string;
2223
+ granted_by: string | null;
2224
+ membership_id: string;
2225
+ role_id: string;
2226
+ };
2227
+ Insert: {
2228
+ granted_at?: string;
2229
+ granted_by?: string | null;
2230
+ membership_id: string;
2231
+ role_id: string;
2232
+ };
2233
+ Update: {
2234
+ granted_at?: string;
2235
+ granted_by?: string | null;
2236
+ membership_id?: string;
2237
+ role_id?: string;
2238
+ };
2239
+ Relationships: [
2240
+ {
2241
+ foreignKeyName: "org_rol_assignments_granted_by_fkey";
2242
+ columns: ["granted_by"];
2243
+ isOneToOne: false;
2244
+ referencedRelation: "users";
2245
+ referencedColumns: ["id"];
2246
+ },
2247
+ {
2248
+ foreignKeyName: "org_rol_assignments_membership_id_fkey";
2249
+ columns: ["membership_id"];
2250
+ isOneToOne: false;
2251
+ referencedRelation: "org_memberships";
2252
+ referencedColumns: ["id"];
2253
+ },
2254
+ {
2255
+ foreignKeyName: "org_rol_assignments_role_id_fkey";
2256
+ columns: ["role_id"];
2257
+ isOneToOne: false;
2258
+ referencedRelation: "org_rol_definitions";
2259
+ referencedColumns: ["id"];
2260
+ }
2261
+ ];
2262
+ };
2263
+ org_rol_definitions: {
2264
+ Row: {
2265
+ created_at: string;
2266
+ description: string | null;
2267
+ id: string;
2268
+ is_system: boolean;
2269
+ name: string;
2270
+ organization_id: string | null;
2271
+ slug: string;
2272
+ updated_at: string;
2273
+ };
2274
+ Insert: {
2275
+ created_at?: string;
2276
+ description?: string | null;
2277
+ id?: string;
2278
+ is_system?: boolean;
2279
+ name: string;
2280
+ organization_id?: string | null;
2281
+ slug: string;
2282
+ updated_at?: string;
2283
+ };
2284
+ Update: {
2285
+ created_at?: string;
2286
+ description?: string | null;
2287
+ id?: string;
2288
+ is_system?: boolean;
2289
+ name?: string;
2290
+ organization_id?: string | null;
2291
+ slug?: string;
2292
+ updated_at?: string;
2293
+ };
2294
+ Relationships: [
2295
+ {
2296
+ foreignKeyName: "org_rol_definitions_organization_id_fkey";
2297
+ columns: ["organization_id"];
2298
+ isOneToOne: false;
2299
+ referencedRelation: "organizations";
2300
+ referencedColumns: ["id"];
2301
+ }
2302
+ ];
2303
+ };
2304
+ org_rol_grants: {
2305
+ Row: {
2306
+ granted_at: string;
2307
+ permission_key: string;
2308
+ role_id: string;
2309
+ };
2310
+ Insert: {
2311
+ granted_at?: string;
2312
+ permission_key: string;
2313
+ role_id: string;
2314
+ };
2315
+ Update: {
2316
+ granted_at?: string;
2317
+ permission_key?: string;
2318
+ role_id?: string;
2319
+ };
2320
+ Relationships: [
2321
+ {
2322
+ foreignKeyName: "org_rol_grants_permission_key_fkey";
2323
+ columns: ["permission_key"];
2324
+ isOneToOne: false;
2325
+ referencedRelation: "org_rol_permissions";
2326
+ referencedColumns: ["key"];
2327
+ },
2328
+ {
2329
+ foreignKeyName: "org_rol_grants_role_id_fkey";
2330
+ columns: ["role_id"];
2331
+ isOneToOne: false;
2332
+ referencedRelation: "org_rol_definitions";
2333
+ referencedColumns: ["id"];
2334
+ }
2335
+ ];
2336
+ };
2337
+ org_rol_permissions: {
2338
+ Row: {
2339
+ created_at: string;
2340
+ description: string;
2341
+ is_org_grantable: boolean;
2342
+ key: string;
2343
+ updated_at: string;
2344
+ };
2345
+ Insert: {
2346
+ created_at?: string;
2347
+ description: string;
2348
+ is_org_grantable?: boolean;
2349
+ key: string;
2350
+ updated_at?: string;
2351
+ };
2352
+ Update: {
2353
+ created_at?: string;
2354
+ description?: string;
2355
+ is_org_grantable?: boolean;
2356
+ key?: string;
2357
+ updated_at?: string;
2358
+ };
2359
+ Relationships: [];
2360
+ };
2605
2361
  organizations: {
2606
2362
  Row: {
2607
2363
  config: Json;
@@ -3359,7 +3115,8 @@ type Database = {
3359
3115
  created_at: string;
3360
3116
  description: string | null;
3361
3117
  id: string;
3362
- key: string;
3118
+ key_hash: string;
3119
+ key_prefix: string | null;
3363
3120
  last_triggered_at: string | null;
3364
3121
  name: string;
3365
3122
  organization_id: string;
@@ -3372,7 +3129,8 @@ type Database = {
3372
3129
  created_at?: string;
3373
3130
  description?: string | null;
3374
3131
  id?: string;
3375
- key: string;
3132
+ key_hash: string;
3133
+ key_prefix?: string | null;
3376
3134
  last_triggered_at?: string | null;
3377
3135
  name: string;
3378
3136
  organization_id: string;
@@ -3385,7 +3143,8 @@ type Database = {
3385
3143
  created_at?: string;
3386
3144
  description?: string | null;
3387
3145
  id?: string;
3388
- key?: string;
3146
+ key_hash?: string;
3147
+ key_prefix?: string | null;
3389
3148
  last_triggered_at?: string | null;
3390
3149
  name?: string;
3391
3150
  organization_id?: string;
@@ -3431,6 +3190,13 @@ type Database = {
3431
3190
  Args: never;
3432
3191
  Returns: string;
3433
3192
  };
3193
+ can_assign_role_in_org: {
3194
+ Args: {
3195
+ p_role_id: string;
3196
+ p_target_membership_id: string;
3197
+ };
3198
+ Returns: boolean;
3199
+ };
3434
3200
  current_user_is_platform_admin: {
3435
3201
  Args: never;
3436
3202
  Returns: boolean;
@@ -3460,6 +3226,10 @@ type Database = {
3460
3226
  user_id: string;
3461
3227
  }[];
3462
3228
  };
3229
+ get_platform_credential_kek: {
3230
+ Args: never;
3231
+ Returns: string;
3232
+ };
3463
3233
  get_storage_org_id: {
3464
3234
  Args: {
3465
3235
  file_path: string;
@@ -3470,6 +3240,13 @@ type Database = {
3470
3240
  Args: never;
3471
3241
  Returns: string;
3472
3242
  };
3243
+ has_org_permission: {
3244
+ Args: {
3245
+ org_id: string;
3246
+ perm_key: string;
3247
+ };
3248
+ Returns: boolean;
3249
+ };
3473
3250
  is_org_admin: {
3474
3251
  Args: {
3475
3252
  org_id: string;
@@ -3502,6 +3279,22 @@ type Database = {
3502
3279
  Args: never;
3503
3280
  Returns: Json;
3504
3281
  };
3282
+ recompute_all_memberships: {
3283
+ Args: never;
3284
+ Returns: undefined;
3285
+ };
3286
+ sync_all_memberships_with_role: {
3287
+ Args: {
3288
+ p_role_id: string;
3289
+ };
3290
+ Returns: undefined;
3291
+ };
3292
+ sync_one_membership: {
3293
+ Args: {
3294
+ p_membership_id: string;
3295
+ };
3296
+ Returns: undefined;
3297
+ };
3505
3298
  upsert_user_profile: {
3506
3299
  Args: never;
3507
3300
  Returns: {
@@ -3555,787 +3348,1253 @@ interface SubActivity {
3555
3348
  details: AgentIterationEvent | AgentToolCallEvent;
3556
3349
  }
3557
3350
  /**
3558
- * Agent iteration state
3559
- * Aggregates lifecycle events and sub-activities for a single iteration
3351
+ * Agent iteration state
3352
+ * Aggregates lifecycle events and sub-activities for a single iteration
3353
+ */
3354
+ interface AgentIteration {
3355
+ iterationNumber: number;
3356
+ status: 'running' | 'completed' | 'failed' | 'pending';
3357
+ iterationEvents: AgentIterationEvent[];
3358
+ duration?: number;
3359
+ timestamp: number;
3360
+ subActivities: SubActivity[];
3361
+ startTime?: number;
3362
+ endTime?: number;
3363
+ }
3364
+ /**
3365
+ * Agent lifecycle node state
3366
+ * Represents initialization or completion phase
3367
+ */
3368
+ interface AgentLifecycleNode {
3369
+ type: 'initialization' | 'completion';
3370
+ status: 'running' | 'completed' | 'failed' | 'pending';
3371
+ duration?: number;
3372
+ timestamp?: number;
3373
+ startTime?: number;
3374
+ endTime?: number;
3375
+ }
3376
+ /**
3377
+ * Complete agent execution data for timeline visualization
3378
+ * Parsed from execution logs
3379
+ */
3380
+ interface AgentIterationData {
3381
+ initialization: AgentLifecycleNode;
3382
+ iterations: AgentIteration[];
3383
+ completion: AgentLifecycleNode;
3384
+ currentIteration: number | null;
3385
+ totalIterations: number;
3386
+ totalDuration?: number;
3387
+ status: 'running' | 'completed' | 'failed' | 'warning';
3388
+ }
3389
+
3390
+ /** Raw database row type for acq_deals table */
3391
+ type AcqDealRow = Database['public']['Tables']['acq_deals']['Row'];
3392
+ type DealStage = 'interested' | 'proposal' | 'closing' | 'closed_won' | 'closed_lost' | 'nurturing';
3393
+ interface KanbanStageConfig {
3394
+ color: string;
3395
+ label?: string;
3396
+ }
3397
+ type KanbanBoardConfig = Partial<Record<DealStage, KanbanStageConfig>>;
3398
+ interface DealContact {
3399
+ id: string;
3400
+ first_name: string | null;
3401
+ last_name: string | null;
3402
+ email: string;
3403
+ title: string | null;
3404
+ headline: string | null;
3405
+ linkedin_url: string | null;
3406
+ pipeline_status: Record<string, unknown> | null;
3407
+ enrichment_data: Record<string, unknown> | null;
3408
+ company: {
3409
+ id: string;
3410
+ name: string;
3411
+ domain: string | null;
3412
+ website: string | null;
3413
+ linkedin_url: string | null;
3414
+ segment: string | null;
3415
+ category: string | null;
3416
+ num_employees: number | null;
3417
+ } | null;
3418
+ }
3419
+ interface DealFilters {
3420
+ stage?: DealStage;
3421
+ search?: string;
3422
+ limit?: number;
3423
+ offset?: number;
3424
+ }
3425
+ /** Deal list item with joined contact and company data */
3426
+ interface DealListItem extends AcqDealRow {
3427
+ contact: DealContact | null;
3428
+ }
3429
+ type DealDetail = DealListItem;
3430
+
3431
+ /**
3432
+ * Action configuration for HITL tasks
3433
+ * Defines available user actions and their behavior
3434
+ */
3435
+ interface ActionConfig {
3436
+ /** Unique action identifier (e.g., 'approve', 'retry', 'escalate') */
3437
+ id: string;
3438
+ /** Display label for UI button */
3439
+ label: string;
3440
+ /** Button variant/style */
3441
+ type: 'primary' | 'secondary' | 'danger' | 'outline';
3442
+ /** Tabler icon name (e.g., 'IconCheck', 'IconRefresh') */
3443
+ icon?: string;
3444
+ /** Button color (Mantine theme colors) */
3445
+ color?: string;
3446
+ /** Button variant (Mantine button variant, e.g., 'light', 'filled', 'outline') */
3447
+ variant?: string;
3448
+ /** Execution target (agent/workflow to invoke) */
3449
+ target?: {
3450
+ resourceType: 'agent' | 'workflow';
3451
+ resourceId: string;
3452
+ /**
3453
+ * Optional session ID for agent continuation.
3454
+ * If provided, invokes a new turn on the existing session instead of standalone execution.
3455
+ * Only valid when resourceType is 'agent'.
3456
+ */
3457
+ sessionId?: string;
3458
+ };
3459
+ /** Form schema for collecting action-specific data */
3460
+ form?: FormSchema;
3461
+ /** Payload template for pre-filling forms */
3462
+ payloadTemplate?: unknown;
3463
+ /** Requires confirmation dialog */
3464
+ requiresConfirmation?: boolean;
3465
+ /** Confirmation message */
3466
+ confirmationMessage?: string;
3467
+ /** Help text / tooltip */
3468
+ description?: string;
3469
+ }
3470
+
3471
+ /**
3472
+ * Origin resource type - where an execution/task originated from.
3473
+ * Used for audit trails and tracking execution lineage.
3474
+ */
3475
+ type OriginResourceType = 'agent' | 'workflow' | 'scheduler' | 'api';
3476
+ /**
3477
+ * Origin tracking metadata - who/what created this execution/task.
3478
+ * Used by both TaskScheduler and CommandQueue for complete audit trails.
3479
+ */
3480
+ interface OriginTracking {
3481
+ originExecutionId: string;
3482
+ originResourceType: OriginResourceType;
3483
+ originResourceId: string;
3484
+ }
3485
+
3486
+ /**
3487
+ * Command queue task with flexible action system
3488
+ */
3489
+ interface Task extends OriginTracking {
3490
+ id: string;
3491
+ organizationId: string;
3492
+ actions: ActionConfig[];
3493
+ context: unknown;
3494
+ selectedAction?: string;
3495
+ actionPayload?: unknown;
3496
+ description?: string;
3497
+ priority: number;
3498
+ /** Optional checkpoint identifier for grouping related human approval tasks */
3499
+ humanCheckpoint?: string;
3500
+ status: QueueTaskStatus;
3501
+ /**
3502
+ * Target resource tracking — mirrors origin columns.
3503
+ * Set when task is created; patchable to redirect execution to a different resource.
3504
+ */
3505
+ targetResourceId?: string;
3506
+ targetResourceType?: 'agent' | 'workflow';
3507
+ /**
3508
+ * Execution ID for the action that runs AFTER user approval.
3509
+ * NULL until execution starts.
3510
+ *
3511
+ * Naming distinction:
3512
+ * - originExecutionId = Parent execution that CREATED the HITL task
3513
+ * - targetExecutionId = Child execution that RUNS AFTER user approval
3514
+ */
3515
+ targetExecutionId?: string;
3516
+ createdAt: Date;
3517
+ completedAt?: Date;
3518
+ completedBy?: string;
3519
+ expiresAt?: Date;
3520
+ idempotencyKey?: string | null;
3521
+ }
3522
+ /**
3523
+ * Task status values
3524
+ * - pending: awaiting action
3525
+ * - processing: execution in progress after user approval
3526
+ * - completed: action was taken and execution succeeded
3527
+ * - failed: execution failed, task can be retried
3528
+ * - expired: timed out before action
3529
+ */
3530
+ type QueueTaskStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
3531
+
3532
+ /**
3533
+ * Target for schedule execution - identifies what resource to execute.
3534
+ * Unlike ExecutionTarget, payload is NOT included here because schedules
3535
+ * store payload in the scheduleConfig (varies per step/item).
3536
+ */
3537
+ interface ScheduleTarget {
3538
+ resourceType: 'agent' | 'workflow';
3539
+ resourceId: string;
3540
+ }
3541
+ /**
3542
+ * Optional origin tracking for schedules.
3543
+ * Unlike OriginTracking (which is required), these fields are all optional
3544
+ * for schedules created directly via API (not triggered by another resource).
3545
+ */
3546
+ interface ScheduleOriginTracking {
3547
+ originExecutionId?: string;
3548
+ originResourceType?: OriginResourceType;
3549
+ originResourceId?: string;
3550
+ }
3551
+ type TaskScheduleConfig = RecurringScheduleConfig | RelativeScheduleConfig | AbsoluteScheduleConfig;
3552
+ interface RecurringScheduleConfig {
3553
+ type: 'recurring';
3554
+ cron?: string;
3555
+ interval?: 'daily' | 'weekly' | 'monthly';
3556
+ time?: string;
3557
+ timezone: string;
3558
+ payload: Record<string, unknown>;
3559
+ endAt?: string | null;
3560
+ overduePolicy?: 'skip' | 'execute';
3561
+ }
3562
+ interface RelativeScheduleConfig {
3563
+ type: 'relative';
3564
+ anchorAt: string;
3565
+ anchorLabel?: string;
3566
+ items: RelativeScheduleItem[];
3567
+ overduePolicy?: 'skip' | 'execute';
3568
+ }
3569
+ interface RelativeScheduleItem {
3570
+ offset: string;
3571
+ payload: Record<string, unknown>;
3572
+ label?: string;
3573
+ }
3574
+ interface AbsoluteScheduleConfig {
3575
+ type: 'absolute';
3576
+ items: AbsoluteScheduleItem[];
3577
+ overduePolicy?: 'skip' | 'execute';
3578
+ }
3579
+ interface AbsoluteScheduleItem {
3580
+ runAt: string;
3581
+ payload: Record<string, unknown>;
3582
+ label?: string;
3583
+ }
3584
+ interface TaskSchedule extends ScheduleOriginTracking {
3585
+ id: string;
3586
+ organizationId: string;
3587
+ name: string;
3588
+ description?: string;
3589
+ target: ScheduleTarget;
3590
+ scheduleConfig: TaskScheduleConfig;
3591
+ nextRunAt?: Date;
3592
+ currentStep: number;
3593
+ status: 'active' | 'paused' | 'completed' | 'cancelled';
3594
+ lastRunAt?: Date;
3595
+ lastExecutionId?: string;
3596
+ maxRetries: number;
3597
+ idempotencyKey?: string;
3598
+ createdAt: Date;
3599
+ updatedAt: Date;
3600
+ }
3601
+
3602
+ /**
3603
+ * Wire-format DTO for notification API responses.
3604
+ * Dates are ISO 8601 strings (not Date objects like the domain Notification type).
3605
+ * Used by frontend hooks that consume /api/notifications.
3606
+ */
3607
+ interface NotificationDTO {
3608
+ id: string;
3609
+ userId: string;
3610
+ organizationId: string;
3611
+ category: string;
3612
+ title: string;
3613
+ message: string;
3614
+ actionUrl: string | null;
3615
+ read: boolean;
3616
+ readAt: string | null;
3617
+ createdAt: string;
3618
+ }
3619
+
3620
+ type MilestoneRow = Database['public']['Tables']['prj_milestones']['Row'];
3621
+ type TaskRow = Database['public']['Tables']['prj_tasks']['Row'];
3622
+
3623
+ /**
3624
+ * Full ListConfig shape. `qualification` is required; everything else optional.
3625
+ * Matches `acq_lists.config` jsonb and ListConfig type in types.ts.
3626
+ */
3627
+ declare const ListConfigSchema: z.ZodObject<{
3628
+ qualification: z.ZodObject<{
3629
+ targetDescription: z.ZodString;
3630
+ minReviewCount: z.ZodNumber;
3631
+ minRating: z.ZodNumber;
3632
+ excludeFranchises: z.ZodBoolean;
3633
+ customRules: z.ZodString;
3634
+ }, z.core.$strip>;
3635
+ enrichment: z.ZodOptional<z.ZodObject<{
3636
+ emailDiscovery: z.ZodOptional<z.ZodObject<{
3637
+ primary: z.ZodEnum<{
3638
+ tomba: "tomba";
3639
+ anymailfinder: "anymailfinder";
3640
+ }>;
3641
+ credentialName: z.ZodOptional<z.ZodString>;
3642
+ }, z.core.$strip>>;
3643
+ emailVerification: z.ZodOptional<z.ZodObject<{
3644
+ provider: z.ZodLiteral<"millionverifier">;
3645
+ threshold: z.ZodOptional<z.ZodEnum<{
3646
+ ok: "ok";
3647
+ "ok+catch_all": "ok+catch_all";
3648
+ }>>;
3649
+ }, z.core.$strip>>;
3650
+ }, z.core.$strip>>;
3651
+ personalization: z.ZodOptional<z.ZodObject<{
3652
+ industryContext: z.ZodOptional<z.ZodString>;
3653
+ emailBody: z.ZodOptional<z.ZodString>;
3654
+ creativeDirection: z.ZodOptional<z.ZodString>;
3655
+ exclusionRules: z.ZodOptional<z.ZodArray<z.ZodString>>;
3656
+ }, z.core.$strip>>;
3657
+ pipeline: z.ZodOptional<z.ZodObject<{
3658
+ steps: z.ZodArray<z.ZodObject<{
3659
+ key: z.ZodString;
3660
+ label: z.ZodString;
3661
+ resourceId: z.ZodString;
3662
+ inputTemplate: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3663
+ enabled: z.ZodBoolean;
3664
+ order: z.ZodNumber;
3665
+ }, z.core.$strip>>;
3666
+ }, z.core.$strip>>;
3667
+ }, z.core.$strip>;
3668
+ type ListConfigInput = z.infer<typeof ListConfigSchema>;
3669
+
3670
+ declare const GetRecentActivityResponseSchema: z.ZodObject<{
3671
+ entries: z.ZodArray<z.ZodObject<{
3672
+ id: z.ZodString;
3673
+ kind: z.ZodEnum<{
3674
+ note: "note";
3675
+ stage_change: "stage_change";
3676
+ deal_created: "deal_created";
3677
+ }>;
3678
+ dealId: z.ZodString;
3679
+ occurredAt: z.ZodString;
3680
+ description: z.ZodString;
3681
+ contactName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3682
+ companyName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3683
+ stage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3684
+ }, z.core.$strip>>;
3685
+ }, z.core.$strip>;
3686
+ type GetRecentActivityResponse = z.infer<typeof GetRecentActivityResponseSchema>;
3687
+
3688
+ /**
3689
+ * Multi-tenancy configuration types
3690
+ *
3691
+ * Config is stored in dedicated `config` columns (NOT nested in metadata):
3692
+ * - organizations.config: Org-level config (no feature toggles -- all features available by default)
3693
+ * - org_memberships.config: Per-user-per-org feature overrides
3694
+ * - users.config: User-global config
3695
+ */
3696
+ /**
3697
+ * Per-user-per-org config (stored in org_memberships.config)
3698
+ * Controls which features a specific member can access within their org.
3699
+ * Keys are feature IDs from the organization model (e.g. crm, lead-gen, projects, seo).
3700
+ */
3701
+ interface MembershipFeatureConfig {
3702
+ features?: Record<string, boolean>;
3703
+ }
3704
+
3705
+ /**
3706
+ * Memberships Domain - Zod Validation Schemas
3707
+ *
3708
+ * Validation schemas for membership management endpoints.
3709
+ * Includes request bodies, query params, and path params.
3710
+ *
3711
+ * Security:
3712
+ * - All schemas use .strict() to prevent mass assignment attacks
3713
+ * - UUID validation prevents invalid references
3714
+ * - Role enum validation prevents privilege escalation
3715
+ * - organizationId never accepted in body (from JWT when needed)
3716
+ */
3717
+
3718
+ /**
3719
+ * Membership status validation
3720
+ * Note: Database constraint only allows 'active' | 'inactive'
3721
+ */
3722
+ declare const MembershipStatusSchema: z.ZodEnum<{
3723
+ active: "active";
3724
+ inactive: "inactive";
3725
+ }>;
3726
+ type MembershipStatus = z.infer<typeof MembershipStatusSchema>;
3727
+
3728
+ /**
3729
+ * Organization Membership types based on WorkOS API
3730
+ */
3731
+ interface OrganizationMembership {
3732
+ object: 'organization_membership';
3733
+ id: string;
3734
+ userId: string;
3735
+ organizationId: string;
3736
+ role: {
3737
+ slug: string;
3738
+ };
3739
+ status: 'active' | 'inactive';
3740
+ createdAt: string;
3741
+ updatedAt: string;
3742
+ }
3743
+ /**
3744
+ * Extended membership with user and organization details for UI
3745
+ */
3746
+ interface MembershipWithDetails extends OrganizationMembership {
3747
+ user?: {
3748
+ id: string;
3749
+ email: string;
3750
+ firstName?: string;
3751
+ lastName?: string;
3752
+ profilePictureUrl?: string;
3753
+ };
3754
+ organization?: {
3755
+ id: string;
3756
+ name: string;
3757
+ workos_org_id: string;
3758
+ primaryDomain?: string;
3759
+ is_test?: boolean;
3760
+ status?: string;
3761
+ metadata?: Record<string, unknown>;
3762
+ config?: Record<string, unknown>;
3763
+ };
3764
+ config?: MembershipFeatureConfig;
3765
+ }
3766
+
3767
+ interface OAuthToken extends Record<string, unknown> {
3768
+ provider: string;
3769
+ accessToken: string;
3770
+ refreshToken: string;
3771
+ expiresAt: string;
3772
+ tokenType: 'Bearer';
3773
+ scope?: string;
3774
+ }
3775
+ interface OAuthProviderConfig {
3776
+ id: string;
3777
+ name: string;
3778
+ authUrl: string;
3779
+ tokenUrl: string;
3780
+ scopes?: string[];
3781
+ authParams?: Record<string, string>;
3782
+ tokenExchange: 'basic-auth' | 'form-encoded' | 'json-body';
3783
+ usePKCE?: boolean;
3784
+ customAuthFlow?: (config: OAuthProviderConfig, state: OAuthState) => URL;
3785
+ customTokenExchange?: (code: string, config: OAuthProviderConfig) => Promise<OAuthToken>;
3786
+ }
3787
+ interface OAuthState {
3788
+ organizationId: string;
3789
+ nonce: string;
3790
+ timestamp: number;
3791
+ credentialName: string;
3792
+ provider: string;
3793
+ }
3794
+
3795
+ /**
3796
+ * Time range selector for dashboard metrics
3797
+ */
3798
+ type TimeRange = '1h' | '24h' | '7d' | '30d';
3799
+ /**
3800
+ * Execution health metrics response
3801
+ * Success rate, P95 duration, execution counts, and trend data
3802
+ * trendData includes executionCount for throughput visualization (eliminates separate API call)
3803
+ */
3804
+ interface ExecutionHealthMetrics {
3805
+ successRate: number;
3806
+ p95Duration: number;
3807
+ totalExecutions: number;
3808
+ trendData: Array<{
3809
+ time: string;
3810
+ rate: number;
3811
+ successCount: number;
3812
+ errorCount: number;
3813
+ warningCount: number;
3814
+ executionCount: number;
3815
+ }>;
3816
+ statusCounts: {
3817
+ success: number;
3818
+ failed: number;
3819
+ pending: number;
3820
+ warning: number;
3821
+ };
3822
+ peakPeriod: string;
3823
+ granularity: 'hour' | 'day';
3824
+ }
3825
+ /**
3826
+ * Error analysis metrics response
3827
+ * Error categories and top failing resources
3560
3828
  */
3561
- interface AgentIteration {
3562
- iterationNumber: number;
3563
- status: 'running' | 'completed' | 'failed' | 'pending';
3564
- iterationEvents: AgentIterationEvent[];
3565
- duration?: number;
3566
- timestamp: number;
3567
- subActivities: SubActivity[];
3568
- startTime?: number;
3569
- endTime?: number;
3829
+ interface ErrorAnalysisMetrics {
3830
+ totalErrors: number;
3831
+ errorsByCategory: Array<{
3832
+ category: string;
3833
+ count: number;
3834
+ percentage: number;
3835
+ }>;
3836
+ topFailingResources: Array<{
3837
+ resourceId: string;
3838
+ name: string;
3839
+ errorCount: number;
3840
+ failureRate: number;
3841
+ }>;
3570
3842
  }
3571
3843
  /**
3572
- * Agent lifecycle node state
3573
- * Represents initialization or completion phase
3844
+ * Business impact metrics response
3845
+ * ROI, labor savings, and cost analysis
3574
3846
  */
3575
- interface AgentLifecycleNode {
3576
- type: 'initialization' | 'completion';
3577
- status: 'running' | 'completed' | 'failed' | 'pending';
3578
- duration?: number;
3579
- timestamp?: number;
3580
- startTime?: number;
3581
- endTime?: number;
3847
+ interface BusinessImpactMetrics {
3848
+ totalSavingsUsd: number;
3849
+ totalCostUsd: number;
3850
+ netSavingsUsd: number;
3851
+ roi: number;
3582
3852
  }
3583
3853
  /**
3584
- * Complete agent execution data for timeline visualization
3585
- * Parsed from execution logs
3854
+ * Cost breakdown metrics response
3855
+ * Per-resource cost analysis
3586
3856
  */
3587
- interface AgentIterationData {
3588
- initialization: AgentLifecycleNode;
3589
- iterations: AgentIteration[];
3590
- completion: AgentLifecycleNode;
3591
- currentIteration: number | null;
3592
- totalIterations: number;
3593
- totalDuration?: number;
3594
- status: 'running' | 'completed' | 'failed' | 'warning';
3595
- }
3596
-
3597
- /** Raw database row type for acq_deals table */
3598
- type AcqDealRow = Database['public']['Tables']['acq_deals']['Row'];
3599
- type DealStage = 'interested' | 'proposal' | 'closing' | 'closed_won' | 'closed_lost' | 'nurturing';
3600
- interface KanbanStageConfig {
3601
- color: string;
3602
- label?: string;
3857
+ interface CostBreakdownMetrics {
3858
+ resources: Array<{
3859
+ resourceId: string;
3860
+ totalCostUsd: number;
3861
+ executionCount: number;
3862
+ avgCostUsd: number;
3863
+ }>;
3603
3864
  }
3604
- type KanbanBoardConfig = Partial<Record<DealStage, KanbanStageConfig>>;
3605
- interface DealContact {
3606
- id: string;
3607
- first_name: string | null;
3608
- last_name: string | null;
3609
- email: string;
3610
- title: string | null;
3611
- headline: string | null;
3612
- linkedin_url: string | null;
3613
- pipeline_status: Record<string, unknown> | null;
3614
- enrichment_data: Record<string, unknown> | null;
3615
- company: {
3616
- id: string;
3617
- name: string;
3618
- domain: string | null;
3619
- website: string | null;
3620
- linkedin_url: string | null;
3621
- segment: string | null;
3622
- category: string | null;
3623
- num_employees: number | null;
3624
- } | null;
3865
+ /** Time-bucketed health data point */
3866
+ interface ResourceHealthDataPoint {
3867
+ time: string;
3868
+ success: number;
3869
+ failure: number;
3870
+ warning: number;
3871
+ rate: number;
3625
3872
  }
3626
- interface DealFilters {
3627
- stage?: DealStage;
3628
- search?: string;
3629
- limit?: number;
3630
- offset?: number;
3873
+ /** Health data for a single resource */
3874
+ interface ResourceHealth {
3875
+ entityType: string;
3876
+ entityId: string;
3877
+ entityName: string | null;
3878
+ trendData: ResourceHealthDataPoint[];
3879
+ summary: {
3880
+ total: number;
3881
+ successRate: number;
3882
+ };
3631
3883
  }
3632
- /** Deal list item with joined contact and company data */
3633
- interface DealListItem extends AcqDealRow {
3634
- contact: DealContact | null;
3884
+ /**
3885
+ * Cost trend data point for time-series charts
3886
+ * Represents a single time bucket (hour or day)
3887
+ */
3888
+ interface CostTrendDataPoint {
3889
+ time: string;
3890
+ totalCostUsd: number;
3891
+ executionCount: number;
3892
+ avgCostPerExecution: number;
3635
3893
  }
3636
- type DealDetail = DealListItem;
3637
-
3638
3894
  /**
3639
- * Action configuration for HITL tasks
3640
- * Defines available user actions and their behavior
3895
+ * Cost trends response (time-series data)
3641
3896
  */
3642
- interface ActionConfig {
3643
- /** Unique action identifier (e.g., 'approve', 'retry', 'escalate') */
3644
- id: string;
3645
- /** Display label for UI button */
3646
- label: string;
3647
- /** Button variant/style */
3648
- type: 'primary' | 'secondary' | 'danger' | 'outline';
3649
- /** Tabler icon name (e.g., 'IconCheck', 'IconRefresh') */
3650
- icon?: string;
3651
- /** Button color (Mantine theme colors) */
3652
- color?: string;
3653
- /** Button variant (Mantine button variant, e.g., 'light', 'filled', 'outline') */
3654
- variant?: string;
3655
- /** Execution target (agent/workflow to invoke) */
3656
- target?: {
3657
- resourceType: 'agent' | 'workflow';
3658
- resourceId: string;
3659
- /**
3660
- * Optional session ID for agent continuation.
3661
- * If provided, invokes a new turn on the existing session instead of standalone execution.
3662
- * Only valid when resourceType is 'agent'.
3663
- */
3664
- sessionId?: string;
3665
- };
3666
- /** Form schema for collecting action-specific data */
3667
- form?: FormSchema;
3668
- /** Payload template for pre-filling forms */
3669
- payloadTemplate?: unknown;
3670
- /** Requires confirmation dialog */
3671
- requiresConfirmation?: boolean;
3672
- /** Confirmation message */
3673
- confirmationMessage?: string;
3674
- /** Help text / tooltip */
3675
- description?: string;
3897
+ interface CostTrendsResponse {
3898
+ trendData: CostTrendDataPoint[];
3899
+ granularity: 'hour' | 'day';
3900
+ totalCostUsd: number;
3901
+ totalExecutions: number;
3676
3902
  }
3677
-
3678
3903
  /**
3679
- * Origin resource type - where an execution/task originated from.
3680
- * Used for audit trails and tracking execution lineage.
3904
+ * Cost summary response with MTD and projections
3681
3905
  */
3682
- type OriginResourceType = 'agent' | 'workflow' | 'scheduler' | 'api';
3906
+ interface CostSummaryResponse {
3907
+ current: {
3908
+ totalCostUsd: number;
3909
+ executionCount: number;
3910
+ };
3911
+ previous: {
3912
+ totalCostUsd: number;
3913
+ executionCount: number;
3914
+ };
3915
+ mtd: {
3916
+ totalCostUsd: number;
3917
+ daysElapsed: number;
3918
+ };
3919
+ projection: {
3920
+ monthlyCostUsd: number;
3921
+ confidence: 'low' | 'medium' | 'high';
3922
+ };
3923
+ trend: {
3924
+ changePercent: number;
3925
+ direction: 'up' | 'down' | 'flat';
3926
+ };
3927
+ }
3683
3928
  /**
3684
- * Origin tracking metadata - who/what created this execution/task.
3685
- * Used by both TaskScheduler and CommandQueue for complete audit trails.
3929
+ * Cost by model data for model-level breakdown
3686
3930
  */
3687
- interface OriginTracking {
3688
- originExecutionId: string;
3689
- originResourceType: OriginResourceType;
3690
- originResourceId: string;
3931
+ interface CostByModelData {
3932
+ model: string;
3933
+ totalCostUsd: number;
3934
+ callCount: number;
3935
+ totalInputTokens: number;
3936
+ totalOutputTokens: number;
3937
+ avgCostPerCall: number;
3691
3938
  }
3692
-
3693
3939
  /**
3694
- * Command queue task with flexible action system
3940
+ * Cost by model response
3695
3941
  */
3696
- interface Task extends OriginTracking {
3697
- id: string;
3698
- organizationId: string;
3699
- actions: ActionConfig[];
3700
- context: unknown;
3701
- selectedAction?: string;
3702
- actionPayload?: unknown;
3703
- description?: string;
3704
- priority: number;
3705
- /** Optional checkpoint identifier for grouping related human approval tasks */
3706
- humanCheckpoint?: string;
3707
- status: QueueTaskStatus;
3708
- /**
3709
- * Target resource tracking — mirrors origin columns.
3710
- * Set when task is created; patchable to redirect execution to a different resource.
3711
- */
3712
- targetResourceId?: string;
3713
- targetResourceType?: 'agent' | 'workflow';
3714
- /**
3715
- * Execution ID for the action that runs AFTER user approval.
3716
- * NULL until execution starts.
3717
- *
3718
- * Naming distinction:
3719
- * - originExecutionId = Parent execution that CREATED the HITL task
3720
- * - targetExecutionId = Child execution that RUNS AFTER user approval
3721
- */
3722
- targetExecutionId?: string;
3723
- createdAt: Date;
3724
- completedAt?: Date;
3725
- completedBy?: string;
3726
- expiresAt?: Date;
3727
- idempotencyKey?: string | null;
3942
+ interface CostByModelResponse {
3943
+ models: CostByModelData[];
3944
+ totalCostUsd: number;
3945
+ totalCallCount: number;
3728
3946
  }
3947
+
3729
3948
  /**
3730
- * Task status values
3731
- * - pending: awaiting action
3732
- * - processing: execution in progress after user approval
3733
- * - completed: action was taken and execution succeeded
3734
- * - failed: execution failed, task can be retried
3735
- * - expired: timed out before action
3949
+ * Base Execution Engine type definitions
3950
+ * Core types shared across all Execution Engine resources
3736
3951
  */
3737
- type QueueTaskStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
3738
3952
 
3739
3953
  /**
3740
- * Target for schedule execution - identifies what resource to execute.
3741
- * Unlike ExecutionTarget, payload is NOT included here because schedules
3742
- * store payload in the scheduleConfig (varies per step/item).
3954
+ * NOTE: AIResource interface has been removed and replaced with ResourceDefinition
3955
+ * from registry/types.ts. All resources (executable and non-executable) now extend
3956
+ * the unified ResourceDefinition base interface.
3957
+ *
3958
+ * AgentConfig and WorkflowConfig now extend ResourceDefinition directly.
3959
+ * See packages/core/src/registry/types.ts for the base interface definition.
3743
3960
  */
3744
- interface ScheduleTarget {
3745
- resourceType: 'agent' | 'workflow';
3746
- resourceId: string;
3747
- }
3961
+ type AIResourceDefinition = SerializedWorkflowDefinition | SerializedAgentDefinition;
3962
+
3748
3963
  /**
3749
- * Optional origin tracking for schedules.
3750
- * Unlike OriginTracking (which is required), these fields are all optional
3751
- * for schedules created directly via API (not triggered by another resource).
3964
+ * Resource Registry type definitions
3752
3965
  */
3753
- interface ScheduleOriginTracking {
3754
- originExecutionId?: string;
3755
- originResourceType?: OriginResourceType;
3756
- originResourceId?: string;
3757
- }
3758
- type TaskScheduleConfig = RecurringScheduleConfig | RelativeScheduleConfig | AbsoluteScheduleConfig;
3759
- interface RecurringScheduleConfig {
3760
- type: 'recurring';
3761
- cron?: string;
3762
- interval?: 'daily' | 'weekly' | 'monthly';
3763
- time?: string;
3764
- timezone: string;
3765
- payload: Record<string, unknown>;
3766
- endAt?: string | null;
3767
- overduePolicy?: 'skip' | 'execute';
3768
- }
3769
- interface RelativeScheduleConfig {
3770
- type: 'relative';
3771
- anchorAt: string;
3772
- anchorLabel?: string;
3773
- items: RelativeScheduleItem[];
3774
- overduePolicy?: 'skip' | 'execute';
3775
- }
3776
- interface RelativeScheduleItem {
3777
- offset: string;
3778
- payload: Record<string, unknown>;
3779
- label?: string;
3780
- }
3781
- interface AbsoluteScheduleConfig {
3782
- type: 'absolute';
3783
- items: AbsoluteScheduleItem[];
3784
- overduePolicy?: 'skip' | 'execute';
3785
- }
3786
- interface AbsoluteScheduleItem {
3787
- runAt: string;
3788
- payload: Record<string, unknown>;
3789
- label?: string;
3790
- }
3791
- interface TaskSchedule extends ScheduleOriginTracking {
3792
- id: string;
3793
- organizationId: string;
3794
- name: string;
3795
- description?: string;
3796
- target: ScheduleTarget;
3797
- scheduleConfig: TaskScheduleConfig;
3798
- nextRunAt?: Date;
3799
- currentStep: number;
3800
- status: 'active' | 'paused' | 'completed' | 'cancelled';
3801
- lastRunAt?: Date;
3802
- lastExecutionId?: string;
3803
- maxRetries: number;
3804
- idempotencyKey?: string;
3805
- createdAt: Date;
3806
- updatedAt: Date;
3807
- }
3808
3966
 
3809
3967
  /**
3810
- * Wire-format DTO for notification API responses.
3811
- * Dates are ISO 8601 strings (not Date objects like the domain Notification type).
3812
- * Used by frontend hooks that consume /api/notifications.
3968
+ * Environment/deployment status for resources
3813
3969
  */
3814
- interface NotificationDTO {
3970
+ type ResourceStatus = 'dev' | 'prod';
3971
+ /**
3972
+ * All resource types in the platform
3973
+ * Used as the discriminator field in ResourceDefinition
3974
+ */
3975
+ type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human';
3976
+ /**
3977
+ * Base interface for ALL platform resources
3978
+ * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
3979
+ */
3980
+ interface ResourceDefinition {
3981
+ /** Unique resource identifier */
3982
+ resourceId: string;
3983
+ /** Display name */
3984
+ name: string;
3985
+ /** Purpose and functionality description */
3986
+ description: string;
3987
+ /** Version for change tracking and evolution */
3988
+ version: string;
3989
+ /** Resource type discriminator */
3990
+ type: ResourceType;
3991
+ /** Environment/deployment status */
3992
+ status: ResourceStatus;
3993
+ /** Graph links to Organization Model nodes */
3994
+ links?: ResourceLink[];
3995
+ /** Infrastructure category for filtering */
3996
+ category?: ResourceCategory;
3997
+ /** Whether the agent supports multi-turn sessions (agents only) */
3998
+ sessionCapable?: boolean;
3999
+ /** Whether the resource is local (monorepo) or remote (externally deployed) */
4000
+ origin?: 'local' | 'remote';
4001
+ /** Whether this resource is archived and should be excluded from registration and deployment */
4002
+ archived?: boolean;
4003
+ }
4004
+
4005
+ declare const LinkSchema: z.ZodObject<{
4006
+ nodeId: z.ZodString;
4007
+ kind: z.ZodEnum<{
4008
+ contains: "contains";
4009
+ references: "references";
4010
+ exposes: "exposes";
4011
+ maps_to: "maps_to";
4012
+ "operates-on": "operates-on";
4013
+ uses: "uses";
4014
+ }>;
4015
+ }, z.core.$strip>;
4016
+ type Link = z.infer<typeof LinkSchema>;
4017
+
4018
+ declare const ResourceCategorySchema: z.ZodEnum<{
4019
+ production: "production";
4020
+ diagnostic: "diagnostic";
4021
+ internal: "internal";
4022
+ testing: "testing";
4023
+ }>;
4024
+ type ResourceCategory = z.infer<typeof ResourceCategorySchema>;
4025
+ type ResourceLink = Link;
4026
+
4027
+ type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'warning';
4028
+ interface APIExecutionSummary {
3815
4029
  id: string;
3816
- userId: string;
3817
- organizationId: string;
3818
- category: string;
3819
- title: string;
3820
- message: string;
3821
- actionUrl: string | null;
3822
- read: boolean;
3823
- readAt: string | null;
3824
- createdAt: string;
4030
+ status: ExecutionStatus;
4031
+ startTime: number;
4032
+ endTime?: number;
4033
+ resourceStatus?: ResourceStatus;
4034
+ }
4035
+ interface APIExecutionDetail extends APIExecutionSummary {
4036
+ executionLogs: ExecutionLogMessage[];
4037
+ input?: unknown;
4038
+ result?: unknown;
4039
+ error?: string;
4040
+ resourceStatus: ResourceStatus;
4041
+ apiVersion?: string | null;
4042
+ resourceVersion?: string | null;
4043
+ sdkVersion?: string | null;
4044
+ isArchived?: boolean;
4045
+ archivedLogCount?: number;
3825
4046
  }
3826
4047
 
3827
- type MilestoneRow = Database['public']['Tables']['prj_milestones']['Row'];
3828
- type TaskRow = Database['public']['Tables']['prj_tasks']['Row'];
4048
+ /**
4049
+ * Resource Type Metadata
4050
+ *
4051
+ * Centralized metadata for ResourceDefinition types including icon names and colors.
4052
+ * Icon names reference @tabler/icons-react - UI layer maps these to actual components.
4053
+ */
3829
4054
 
3830
4055
  /**
3831
- * Full ListConfig shape. `qualification` is required; everything else optional.
3832
- * Matches `acq_lists.config` jsonb and ListConfig type in types.ts.
4056
+ * Node color types for graph visualization
4057
+ * Used by both @repo/core (metadata) and @repo/ui (components)
3833
4058
  */
3834
- declare const ListConfigSchema: z.ZodObject<{
3835
- qualification: z.ZodObject<{
3836
- targetDescription: z.ZodString;
3837
- minReviewCount: z.ZodNumber;
3838
- minRating: z.ZodNumber;
3839
- excludeFranchises: z.ZodBoolean;
3840
- customRules: z.ZodString;
3841
- }, z.core.$strip>;
3842
- enrichment: z.ZodOptional<z.ZodObject<{
3843
- emailDiscovery: z.ZodOptional<z.ZodObject<{
3844
- primary: z.ZodEnum<{
3845
- tomba: "tomba";
3846
- anymailfinder: "anymailfinder";
3847
- }>;
3848
- credentialName: z.ZodOptional<z.ZodString>;
3849
- }, z.core.$strip>>;
3850
- emailVerification: z.ZodOptional<z.ZodObject<{
3851
- provider: z.ZodLiteral<"millionverifier">;
3852
- threshold: z.ZodOptional<z.ZodEnum<{
3853
- ok: "ok";
3854
- "ok+catch_all": "ok+catch_all";
3855
- }>>;
3856
- }, z.core.$strip>>;
3857
- }, z.core.$strip>>;
3858
- personalization: z.ZodOptional<z.ZodObject<{
3859
- industryContext: z.ZodOptional<z.ZodString>;
3860
- emailBody: z.ZodOptional<z.ZodString>;
3861
- creativeDirection: z.ZodOptional<z.ZodString>;
3862
- exclusionRules: z.ZodOptional<z.ZodArray<z.ZodString>>;
3863
- }, z.core.$strip>>;
3864
- pipeline: z.ZodOptional<z.ZodObject<{
3865
- steps: z.ZodArray<z.ZodObject<{
3866
- key: z.ZodString;
3867
- label: z.ZodString;
3868
- resourceId: z.ZodString;
3869
- inputTemplate: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3870
- enabled: z.ZodBoolean;
3871
- order: z.ZodNumber;
3872
- }, z.core.$strip>>;
3873
- }, z.core.$strip>>;
3874
- }, z.core.$strip>;
3875
- type ListConfigInput = z.infer<typeof ListConfigSchema>;
4059
+ type NodeColorType = 'violet' | 'blue' | 'orange' | 'teal' | 'gray' | 'yellow';
3876
4060
 
3877
- declare const GetRecentActivityResponseSchema: z.ZodObject<{
3878
- entries: z.ZodArray<z.ZodObject<{
3879
- id: z.ZodString;
3880
- kind: z.ZodEnum<{
3881
- note: "note";
3882
- stage_change: "stage_change";
3883
- deal_created: "deal_created";
3884
- }>;
3885
- dealId: z.ZodString;
3886
- occurredAt: z.ZodString;
3887
- description: z.ZodString;
3888
- contactName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3889
- companyName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3890
- stage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3891
- }, z.core.$strip>>;
3892
- }, z.core.$strip>;
3893
- type GetRecentActivityResponse = z.infer<typeof GetRecentActivityResponseSchema>;
4061
+ type ActivityType = 'workflow_execution' | 'agent_run' | 'hitl_action' | 'webhook_received' | 'webhook_executed' | 'webhook_failed' | 'credential_change' | 'credential_read' | 'api_key_change' | 'deployment_change' | 'membership_change';
4062
+ type ActivityStatus = 'success' | 'failure' | 'pending' | 'approved' | 'rejected' | 'completed';
4063
+ interface Activity {
4064
+ id: string;
4065
+ organizationId: string;
4066
+ activityType: ActivityType;
4067
+ status: ActivityStatus;
4068
+ title: string;
4069
+ description: string | null;
4070
+ entityType: string;
4071
+ entityId: string;
4072
+ entityName: string | null;
4073
+ metadata: Record<string, unknown> | null;
4074
+ actorId: string | null;
4075
+ actorType: string | null;
4076
+ occurredAt: Date;
4077
+ createdAt: Date;
4078
+ }
3894
4079
 
3895
4080
  /**
3896
- * Multi-tenancy configuration types
4081
+ * Canonical permission catalog.
3897
4082
  *
3898
- * Config is stored in dedicated `config` columns (NOT nested in metadata):
3899
- * - organizations.config: Org-level config (no feature toggles -- all features available by default)
3900
- * - org_memberships.config: Per-user-per-org feature overrides
3901
- * - users.config: User-global config
3902
- */
4083
+ * Source of truth for the permission keys used by:
4084
+ * - RLS policies in Supabase (via has_org_permission(org_id, key))
4085
+ * - API middleware (via requireOrganizationPermission(key))
4086
+ * - UI hooks (via useOrganizationPermissions().hasPermission(key))
4087
+ *
4088
+ * The DB table `org_rol_permissions` mirrors this constant. Reconciliation
4089
+ * runs at API boot (insert-or-update only — never auto-delete; see the
4090
+ * deletion runbook in the auth-role-system-redesign doc).
4091
+ *
4092
+ * Adding a permission:
4093
+ * 1. Add an entry below.
4094
+ * 2. Add a row to the migration / via reconcilePermissionCatalog at boot.
4095
+ * 3. Reference it in RLS / middleware as needed.
4096
+ * 4. Optionally grant it to one or more system roles in org_rol_grants.
4097
+ *
4098
+ * Removing a permission: follow the deletion runbook — never just delete
4099
+ * the entry. Existing role grants and policy references must be cleared first.
4100
+ */
4101
+ declare const PERMISSIONS: {
4102
+ readonly ORG_READ: "org.read";
4103
+ readonly ORG_MANAGE: "org.manage";
4104
+ readonly ORG_DELETE: "org.delete";
4105
+ readonly MEMBERS_MANAGE: "members.manage";
4106
+ readonly ROLES_MANAGE: "roles.manage";
4107
+ readonly SECRETS_MANAGE: "secrets.manage";
4108
+ readonly OPERATIONS_READ: "operations.read";
4109
+ readonly OPERATIONS_MANAGE: "operations.manage";
4110
+ readonly WORK_MANAGE: "work.manage";
4111
+ };
4112
+ type PermissionKey = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
3903
4113
  /**
3904
- * Per-user-per-org config (stored in org_memberships.config)
3905
- * Controls which features a specific member can access within their org.
3906
- * Keys are feature IDs from the organization model (e.g. crm, lead-gen, projects, seo).
4114
+ * Static metadata for each permission. Mirrored into org_rol_permissions on
4115
+ * boot reconciliation. is_org_grantable=false means the permission is reserved
4116
+ * to system roles only custom roles cannot include it (privilege-escalation guard).
3907
4117
  */
3908
- interface MembershipFeatureConfig {
3909
- features?: Record<string, boolean>;
4118
+ interface PermissionDescriptor {
4119
+ key: PermissionKey;
4120
+ description: string;
4121
+ isOrgGrantable: boolean;
3910
4122
  }
3911
4123
 
3912
4124
  /**
3913
- * Memberships Domain - Zod Validation Schemas
3914
- *
3915
- * Validation schemas for membership management endpoints.
3916
- * Includes request bodies, query params, and path params.
4125
+ * Execution Runner Types
3917
4126
  *
3918
- * Security:
3919
- * - All schemas use .strict() to prevent mass assignment attacks
3920
- * - UUID validation prevents invalid references
3921
- * - Role enum validation prevents privilege escalation
3922
- * - organizationId never accepted in body (from JWT when needed)
4127
+ * Shared types for the Execution Runner UI feature.
4128
+ * Used by both API (apps/api) and frontend (apps/command-center).
3923
4129
  */
3924
4130
 
3925
- /**
3926
- * Membership status validation
3927
- * Note: Database constraint only allows 'active' | 'inactive'
3928
- */
3929
- declare const MembershipStatusSchema: z.ZodEnum<{
3930
- active: "active";
3931
- inactive: "inactive";
3932
- }>;
3933
- type MembershipStatus = z.infer<typeof MembershipStatusSchema>;
4131
+ interface ExecutionRunnerCatalogItem {
4132
+ resourceId: string;
4133
+ resourceName: string;
4134
+ resourceType: 'workflow' | 'agent';
4135
+ description?: string;
4136
+ status: 'dev' | 'prod';
4137
+ version: string;
4138
+ interface: SerializedExecutionInterface;
4139
+ }
3934
4140
 
3935
4141
  /**
3936
- * Organization Membership types based on WorkOS API
4142
+ * Deployment types browser-safe
4143
+ *
4144
+ * Canonical API response types for the deployment resource.
4145
+ * The API's transformRow converts snake_case DB columns to these camelCase fields.
3937
4146
  */
3938
- interface OrganizationMembership {
3939
- object: 'organization_membership';
4147
+ type DeploymentStatus = 'deploying' | 'active' | 'failed' | 'rolled_back' | 'stopped';
4148
+ interface Deployment {
3940
4149
  id: string;
3941
- userId: string;
3942
4150
  organizationId: string;
3943
- role: {
3944
- slug: string;
3945
- };
3946
- status: 'active' | 'inactive';
4151
+ status: DeploymentStatus;
4152
+ sdkVersion: string;
4153
+ deploymentVersion: string | null;
4154
+ port: number | null;
4155
+ pid: number | null;
4156
+ tarballPath: string | null;
4157
+ errorMessage: string | null;
3947
4158
  createdAt: string;
3948
4159
  updatedAt: string;
3949
4160
  }
4161
+
3950
4162
  /**
3951
- * Extended membership with user and organization details for UI
4163
+ * GET /api/credentials - List credentials
3952
4164
  */
3953
- interface MembershipWithDetails extends OrganizationMembership {
3954
- user?: {
3955
- id: string;
3956
- email: string;
3957
- firstName?: string;
3958
- lastName?: string;
3959
- profilePictureUrl?: string;
3960
- };
3961
- organization?: {
3962
- id: string;
3963
- name: string;
3964
- workos_org_id: string;
3965
- primaryDomain?: string;
3966
- is_test?: boolean;
3967
- status?: string;
3968
- metadata?: Record<string, unknown>;
3969
- config?: Record<string, unknown>;
3970
- };
3971
- config?: MembershipFeatureConfig;
3972
- }
4165
+ declare const ListCredentialsResponseSchema: z.ZodObject<{
4166
+ credentials: z.ZodArray<z.ZodObject<{
4167
+ id: z.ZodString;
4168
+ name: z.ZodString;
4169
+ type: z.ZodString;
4170
+ provider: z.ZodNullable<z.ZodString>;
4171
+ createdAt: z.ZodString;
4172
+ }, z.core.$strip>>;
4173
+ }, z.core.$strip>;
4174
+ /** API response type for a single credential list item */
4175
+ type CredentialListItem = z.infer<typeof ListCredentialsResponseSchema>['credentials'][number];
3973
4176
 
3974
- interface OAuthToken extends Record<string, unknown> {
3975
- provider: string;
3976
- accessToken: string;
3977
- refreshToken: string;
3978
- expiresAt: string;
3979
- tokenType: 'Bearer';
3980
- scope?: string;
3981
- }
3982
- interface OAuthProviderConfig {
3983
- id: string;
4177
+ type Props$2 = {
4178
+ permission: PermissionKey | string;
4179
+ fallback?: ReactNode;
4180
+ children: ReactNode;
4181
+ };
4182
+ declare function Can({ permission, fallback, children }: Props$2): react_jsx_runtime.JSX.Element | null;
4183
+
4184
+ type Props$1 = {
4185
+ slug: string;
3984
4186
  name: string;
3985
- authUrl: string;
3986
- tokenUrl: string;
3987
- scopes?: string[];
3988
- authParams?: Record<string, string>;
3989
- tokenExchange: 'basic-auth' | 'form-encoded' | 'json-body';
3990
- usePKCE?: boolean;
3991
- customAuthFlow?: (config: OAuthProviderConfig, state: OAuthState) => URL;
3992
- customTokenExchange?: (code: string, config: OAuthProviderConfig) => Promise<OAuthToken>;
3993
- }
3994
- interface OAuthState {
3995
- organizationId: string;
3996
- nonce: string;
3997
- timestamp: number;
3998
- credentialName: string;
3999
- provider: string;
4000
- }
4187
+ isSystem: boolean;
4188
+ };
4189
+ declare function RoleBadge({ name, isSystem }: Props$1): react_jsx_runtime.JSX.Element;
4190
+
4191
+ type PermissionRow = PermissionDescriptor;
4192
+ type Props = {
4193
+ catalog: PermissionRow[];
4194
+ selectedKeys: string[];
4195
+ onChange?: (keys: string[]) => void;
4196
+ systemLocked?: boolean;
4197
+ };
4198
+ declare function PermissionMatrix({ catalog, selectedKeys, onChange, systemLocked }: Props): react_jsx_runtime.JSX.Element;
4001
4199
 
4002
- /**
4003
- * Time range selector for dashboard metrics
4004
- */
4005
- type TimeRange = '1h' | '24h' | '7d' | '30d';
4006
- /**
4007
- * Execution health metrics response
4008
- * Success rate, P95 duration, execution counts, and trend data
4009
- * trendData includes executionCount for throughput visualization (eliminates separate API call)
4010
- */
4011
- interface ExecutionHealthMetrics {
4012
- successRate: number;
4013
- p95Duration: number;
4014
- totalExecutions: number;
4015
- trendData: Array<{
4016
- time: string;
4017
- rate: number;
4018
- successCount: number;
4019
- errorCount: number;
4020
- warningCount: number;
4021
- executionCount: number;
4022
- }>;
4023
- statusCounts: {
4024
- success: number;
4025
- failed: number;
4026
- pending: number;
4027
- warning: number;
4028
- };
4029
- peakPeriod: string;
4030
- granularity: 'hour' | 'day';
4031
- }
4032
- /**
4033
- * Error analysis metrics response
4034
- * Error categories and top failing resources
4035
- */
4036
- interface ErrorAnalysisMetrics {
4037
- totalErrors: number;
4038
- errorsByCategory: Array<{
4039
- category: string;
4040
- count: number;
4041
- percentage: number;
4042
- }>;
4043
- topFailingResources: Array<{
4044
- resourceId: string;
4045
- name: string;
4046
- errorCount: number;
4047
- failureRate: number;
4048
- }>;
4049
- }
4050
- /**
4051
- * Business impact metrics response
4052
- * ROI, labor savings, and cost analysis
4053
- */
4054
- interface BusinessImpactMetrics {
4055
- totalSavingsUsd: number;
4056
- totalCostUsd: number;
4057
- netSavingsUsd: number;
4058
- roi: number;
4059
- }
4060
- /**
4061
- * Cost breakdown metrics response
4062
- * Per-resource cost analysis
4063
- */
4064
- interface CostBreakdownMetrics {
4065
- resources: Array<{
4066
- resourceId: string;
4067
- totalCostUsd: number;
4068
- executionCount: number;
4069
- avgCostUsd: number;
4200
+ declare function NoAccessState(): react_jsx_runtime.JSX.Element;
4201
+
4202
+ type CreateRoleModalProps = {
4203
+ opened: boolean;
4204
+ onClose: () => void;
4205
+ onCreated?: (roleId: string) => void;
4206
+ };
4207
+ declare function CreateRoleModal({ opened, onClose, onCreated }: CreateRoleModalProps): react_jsx_runtime.JSX.Element;
4208
+
4209
+ declare function showAuthError(error: unknown): void;
4210
+
4211
+ interface EmptyStateProps {
4212
+ /** Icon component to display (e.g., IconKey from @tabler/icons-react) */
4213
+ icon: ComponentType<{
4214
+ size: number;
4215
+ style?: React.CSSProperties;
4070
4216
  }>;
4071
- }
4072
- /** Time-bucketed health data point */
4073
- interface ResourceHealthDataPoint {
4074
- time: string;
4075
- success: number;
4076
- failure: number;
4077
- warning: number;
4078
- rate: number;
4079
- }
4080
- /** Health data for a single resource */
4081
- interface ResourceHealth {
4082
- entityType: string;
4083
- entityId: string;
4084
- entityName: string | null;
4085
- trendData: ResourceHealthDataPoint[];
4086
- summary: {
4087
- total: number;
4088
- successRate: number;
4217
+ /** Main title text */
4218
+ title: string;
4219
+ /** Description text shown below title */
4220
+ description?: string;
4221
+ /** Optional action button */
4222
+ action?: {
4223
+ label: string;
4224
+ onClick: () => void;
4225
+ icon?: ReactNode;
4089
4226
  };
4227
+ /** Vertical padding - defaults to 'xl' */
4228
+ py?: MantineSpacing;
4090
4229
  }
4091
4230
  /**
4092
- * Cost trend data point for time-series charts
4093
- * Represents a single time bucket (hour or day)
4231
+ * EmptyState - Reusable empty state component for lists and tables
4232
+ *
4233
+ * Consolidates the Center + Stack + Icon + Text pattern used across:
4234
+ * - ApiKeyList.tsx
4235
+ * - CredentialList.tsx
4236
+ * - Various other list components
4237
+ *
4238
+ * @example
4239
+ * ```tsx
4240
+ * <EmptyState
4241
+ * icon={IconKey}
4242
+ * title="No API keys yet"
4243
+ * description="Create your first API key to enable external integrations"
4244
+ * action={{ label: "Create API Key", onClick: handleCreate }}
4245
+ * />
4246
+ * ```
4094
4247
  */
4095
- interface CostTrendDataPoint {
4096
- time: string;
4097
- totalCostUsd: number;
4098
- executionCount: number;
4099
- avgCostPerExecution: number;
4248
+ declare function EmptyState({ icon: Icon, title, description, action, py }: EmptyStateProps): react_jsx_runtime.JSX.Element;
4249
+
4250
+ interface TabCountBadgeProps {
4251
+ count: number;
4252
+ isLoading?: boolean;
4100
4253
  }
4101
4254
  /**
4102
- * Cost trends response (time-series data)
4255
+ * A badge that displays a count in tabs with consistent sizing.
4256
+ * Uses a fixed-width container to prevent layout shift when switching
4257
+ * between the loading spinner and the count badge.
4103
4258
  */
4104
- interface CostTrendsResponse {
4105
- trendData: CostTrendDataPoint[];
4106
- granularity: 'hour' | 'day';
4107
- totalCostUsd: number;
4108
- totalExecutions: number;
4109
- }
4259
+ declare function TabCountBadge({ count, isLoading }: TabCountBadgeProps): react_jsx_runtime.JSX.Element;
4260
+
4110
4261
  /**
4111
- * Cost summary response with MTD and projections
4262
+ * TrendIndicator - Reusable component for showing percentage change trends
4263
+ * Displays up/down/flat arrow with colored badge
4112
4264
  */
4113
- interface CostSummaryResponse {
4114
- current: {
4115
- totalCostUsd: number;
4116
- executionCount: number;
4117
- };
4118
- previous: {
4119
- totalCostUsd: number;
4120
- executionCount: number;
4121
- };
4122
- mtd: {
4123
- totalCostUsd: number;
4124
- daysElapsed: number;
4125
- };
4126
- projection: {
4127
- monthlyCostUsd: number;
4128
- confidence: 'low' | 'medium' | 'high';
4129
- };
4130
- trend: {
4131
- changePercent: number;
4132
- direction: 'up' | 'down' | 'flat';
4133
- };
4265
+ interface TrendIndicatorProps {
4266
+ /** Current value */
4267
+ current: number;
4268
+ /** Previous value to compare against */
4269
+ previous: number;
4270
+ /** Optional formatter for the value (not used in display but kept for API compatibility) */
4271
+ formatter?: (value: number) => string;
4272
+ /** If true, negative change is considered positive (e.g., for costs) */
4273
+ inverse?: boolean;
4134
4274
  }
4135
4275
  /**
4136
- * Cost by model data for model-level breakdown
4276
+ * Shows a trend indicator with arrow icon and percentage change badge
4277
+ *
4278
+ * @example
4279
+ * // Positive trend (green when going up)
4280
+ * <TrendIndicator current={100} previous={80} />
4281
+ *
4282
+ * @example
4283
+ * // Inverse trend (green when going down, useful for costs)
4284
+ * <TrendIndicator current={100} previous={120} inverse />
4137
4285
  */
4138
- interface CostByModelData {
4139
- model: string;
4140
- totalCostUsd: number;
4141
- callCount: number;
4142
- totalInputTokens: number;
4143
- totalOutputTokens: number;
4144
- avgCostPerCall: number;
4286
+ declare function TrendIndicator({ current, previous, inverse }: TrendIndicatorProps): react_jsx_runtime.JSX.Element;
4287
+
4288
+ interface CollapsibleSectionProps {
4289
+ title: string | ReactNode;
4290
+ count?: number;
4291
+ countLabel?: string;
4292
+ children: ReactNode;
4293
+ emptyMessage?: string;
4294
+ defaultExpanded?: boolean;
4295
+ maxHeight?: number;
4145
4296
  }
4146
4297
  /**
4147
- * Cost by model response
4298
+ * Reusable collapsible section with header, badge, and scroll area
4299
+ * Used for expandable content like memory sections, logs, etc.
4148
4300
  */
4149
- interface CostByModelResponse {
4150
- models: CostByModelData[];
4151
- totalCostUsd: number;
4152
- totalCallCount: number;
4301
+ declare function CollapsibleSection({ title, count, countLabel, children, emptyMessage, defaultExpanded, maxHeight }: CollapsibleSectionProps): react_jsx_runtime.JSX.Element;
4302
+
4303
+ interface PageTitleCaptionProps {
4304
+ title: string;
4305
+ caption?: string;
4306
+ rightSection?: ReactNode;
4153
4307
  }
4308
+ declare const PageTitleCaption: ({ title, caption, rightSection }: PageTitleCaptionProps) => react_jsx_runtime.JSX.Element;
4154
4309
 
4310
+ interface StatsCardSkeletonProps {
4311
+ /** Height of the loader area - defaults to 200 */
4312
+ chartHeight?: number;
4313
+ /** Kept for API compat, unused */
4314
+ withChart?: boolean;
4315
+ /** Kept for API compat, unused */
4316
+ statCount?: 2 | 3;
4317
+ }
4155
4318
  /**
4156
- * Base Execution Engine type definitions
4157
- * Core types shared across all Execution Engine resources
4319
+ * StatsCardSkeleton - Loading state for dashboard metric cards
4320
+ *
4321
+ * Used across:
4322
+ * - ExecutionHealthCard.tsx
4323
+ * - CostMetricsCard.tsx
4324
+ * - ThroughputCard.tsx
4325
+ * - BusinessImpactCard.tsx
4158
4326
  */
4159
-
4327
+ declare function StatsCardSkeleton({ chartHeight }: StatsCardSkeletonProps): react_jsx_runtime.JSX.Element;
4328
+ interface ListSkeletonProps {
4329
+ /** Number of rows (used to calculate height) - defaults to 3 */
4330
+ rows?: number;
4331
+ /** Height of each row - defaults to 50 */
4332
+ rowHeight?: number;
4333
+ }
4160
4334
  /**
4161
- * NOTE: AIResource interface has been removed and replaced with ResourceDefinition
4162
- * from registry/types.ts. All resources (executable and non-executable) now extend
4163
- * the unified ResourceDefinition base interface.
4335
+ * ListSkeleton - Loading state for table/list content
4164
4336
  *
4165
- * AgentConfig and WorkflowConfig now extend ResourceDefinition directly.
4166
- * See packages/core/src/registry/types.ts for the base interface definition.
4337
+ * Used across:
4338
+ * - ApiKeyList.tsx
4339
+ * - CredentialList.tsx
4340
+ * - DeploymentList.tsx
4341
+ * - WebhookEndpointList.tsx
4167
4342
  */
4168
- type AIResourceDefinition = SerializedWorkflowDefinition | SerializedAgentDefinition;
4169
-
4343
+ declare function ListSkeleton({ rows, rowHeight }: ListSkeletonProps): react_jsx_runtime.JSX.Element;
4344
+ interface DetailCardSkeletonProps {
4345
+ /** Number of detail rows (used to calculate height) - defaults to 3 */
4346
+ rows?: number;
4347
+ }
4170
4348
  /**
4171
- * Resource Registry type definitions
4349
+ * DetailCardSkeleton - Loading state for cards with list of detail items
4350
+ *
4351
+ * Used for cards like CostBreakdownCard
4172
4352
  */
4353
+ declare function DetailCardSkeleton({ rows }: DetailCardSkeletonProps): react_jsx_runtime.JSX.Element;
4173
4354
 
4355
+ interface NavigationButtonProps {
4356
+ /** Icon component to display */
4357
+ icon: React__default.ComponentType<{
4358
+ size?: number;
4359
+ stroke?: number;
4360
+ }>;
4361
+ /** Button label text */
4362
+ label: string;
4363
+ /** Whether the button is in collapsed state (hides text) */
4364
+ isCollapsed?: boolean;
4365
+ /** Whether this button has sub-items/links */
4366
+ hasSubItems?: boolean;
4367
+ /** Whether sub-items are expanded (controls chevron rotation) */
4368
+ isExpanded?: boolean;
4369
+ /** Whether the icon and text should be styled as active */
4370
+ isActive?: boolean;
4371
+ /** Whether the background should be styled as active */
4372
+ hasActiveBackground?: boolean;
4373
+ /** Click handler */
4374
+ onClick?: () => void;
4375
+ /** Additional styles for the button container */
4376
+ style?: React__default.CSSProperties;
4377
+ /** Custom transition duration in ms */
4378
+ transitionDuration?: number;
4379
+ }
4380
+ declare const NavigationButton: React__default.FC<NavigationButtonProps>;
4381
+
4382
+ interface CustomSelectorProps {
4383
+ value: string | null;
4384
+ onChange: (value: string | null) => void;
4385
+ data: {
4386
+ value: string;
4387
+ label: string;
4388
+ }[] | readonly {
4389
+ value: string;
4390
+ label: string;
4391
+ }[];
4392
+ leftSection?: ReactNode;
4393
+ placeholder?: string;
4394
+ w?: number | string;
4395
+ withCheckIcon?: boolean;
4396
+ disabled?: boolean;
4397
+ }
4398
+ declare function CustomSelector({ value, onChange, data, leftSection, placeholder, w, withCheckIcon, disabled }: CustomSelectorProps): react_jsx_runtime.JSX.Element;
4399
+
4400
+ interface APIErrorAlertProps {
4401
+ /**
4402
+ * The error to display. Can be an APIClientError, generic Error, or any unknown value.
4403
+ */
4404
+ error: unknown;
4405
+ /**
4406
+ * Optional title override. If not provided, uses getErrorTitle() based on error code.
4407
+ */
4408
+ title?: string;
4409
+ /**
4410
+ * Whether to show the request ID (if available). Defaults to true.
4411
+ */
4412
+ showRequestId?: boolean;
4413
+ /**
4414
+ * Optional custom icon. Defaults to IconAlertCircle.
4415
+ */
4416
+ icon?: React.ReactNode;
4417
+ /**
4418
+ * Alert color. Defaults to 'red'.
4419
+ */
4420
+ color?: string;
4421
+ }
4174
4422
  /**
4175
- * Environment/deployment status for resources
4176
- */
4177
- type ResourceStatus = 'dev' | 'prod';
4178
- /**
4179
- * All resource types in the platform
4180
- * Used as the discriminator field in ResourceDefinition
4423
+ * Alert component for displaying API errors with type-safe error handling.
4424
+ *
4425
+ * Automatically extracts error message, code, and request ID from APIClientError
4426
+ * or falls back to generic Error handling.
4427
+ *
4428
+ * @example
4429
+ * ```tsx
4430
+ * const { data, error } = useQuery(...)
4431
+ *
4432
+ * if (error) {
4433
+ * return <APIErrorAlert error={error} />
4434
+ * }
4435
+ * ```
4436
+ *
4437
+ * @example With custom title
4438
+ * ```tsx
4439
+ * <APIErrorAlert
4440
+ * error={error}
4441
+ * title="Failed to load resources"
4442
+ * />
4443
+ * ```
4444
+ *
4445
+ * @example Without request ID
4446
+ * ```tsx
4447
+ * <APIErrorAlert
4448
+ * error={error}
4449
+ * showRequestId={false}
4450
+ * />
4451
+ * ```
4181
4452
  */
4182
- type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human';
4453
+ declare function APIErrorAlert({ error, title, showRequestId, icon, color }: APIErrorAlertProps): react_jsx_runtime.JSX.Element;
4454
+
4455
+ interface CenteredErrorStateProps {
4456
+ error: unknown;
4457
+ title?: string;
4458
+ /** Minimum height of the centering container. Defaults to 300. */
4459
+ h?: number | string;
4460
+ /** Vertical padding (used when h is not set). */
4461
+ py?: MantineSpacing;
4462
+ }
4183
4463
  /**
4184
- * Base interface for ALL platform resources
4185
- * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
4464
+ * CenteredErrorState - Displays an error centered inside its container.
4465
+ *
4466
+ * The caller is responsible for providing the container (e.g. `<Paper withBorder>`).
4467
+ * This component only handles centering + rendering the error alert.
4468
+ *
4469
+ * @example
4470
+ * ```tsx
4471
+ * if (error) {
4472
+ * return (
4473
+ * <Paper withBorder>
4474
+ * <CenteredErrorState error={error} title="Failed to load trends" />
4475
+ * </Paper>
4476
+ * )
4477
+ * }
4478
+ * ```
4186
4479
  */
4187
- interface ResourceDefinition {
4188
- /** Unique resource identifier */
4189
- resourceId: string;
4190
- /** Display name */
4191
- name: string;
4192
- /** Purpose and functionality description */
4193
- description: string;
4194
- /** Version for change tracking and evolution */
4195
- version: string;
4196
- /** Resource type discriminator */
4197
- type: ResourceType;
4198
- /** Environment/deployment status */
4199
- status: ResourceStatus;
4200
- /** Graph links to Organization Model nodes */
4201
- links?: ResourceLink[];
4202
- /** Infrastructure category for filtering */
4203
- category?: ResourceCategory;
4204
- /** Whether the agent supports multi-turn sessions (agents only) */
4205
- sessionCapable?: boolean;
4206
- /** Whether the resource is local (monorepo) or remote (externally deployed) */
4207
- origin?: 'local' | 'remote';
4208
- /** Whether this resource is archived and should be excluded from registration and deployment */
4209
- archived?: boolean;
4210
- }
4211
-
4212
- declare const LinkSchema: z.ZodObject<{
4213
- nodeId: z.ZodString;
4214
- kind: z.ZodEnum<{
4215
- contains: "contains";
4216
- references: "references";
4217
- exposes: "exposes";
4218
- maps_to: "maps_to";
4219
- "operates-on": "operates-on";
4220
- uses: "uses";
4221
- }>;
4222
- }, z.core.$strip>;
4223
- type Link = z.infer<typeof LinkSchema>;
4224
-
4225
- declare const ResourceCategorySchema: z.ZodEnum<{
4226
- production: "production";
4227
- diagnostic: "diagnostic";
4228
- internal: "internal";
4229
- testing: "testing";
4230
- }>;
4231
- type ResourceCategory = z.infer<typeof ResourceCategorySchema>;
4232
- type ResourceLink = Link;
4480
+ declare function CenteredErrorState({ error, title, h, py }: CenteredErrorStateProps): react_jsx_runtime.JSX.Element;
4233
4481
 
4234
- type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'warning';
4235
- interface APIExecutionSummary {
4236
- id: string;
4237
- status: ExecutionStatus;
4238
- startTime: number;
4239
- endTime?: number;
4240
- resourceStatus?: ResourceStatus;
4482
+ interface StatCardBaseProps {
4483
+ /** The label/description text */
4484
+ label: string;
4485
+ /** The value to display (number or formatted string) */
4486
+ value: string | number;
4487
+ /** Tabler icon component */
4488
+ icon: Icon;
4489
+ /** Optional extra content rendered below the label */
4490
+ children?: ReactNode;
4241
4491
  }
4242
- interface APIExecutionDetail extends APIExecutionSummary {
4243
- executionLogs: ExecutionLogMessage[];
4244
- input?: unknown;
4245
- result?: unknown;
4246
- error?: string;
4247
- resourceStatus: ResourceStatus;
4248
- apiVersion?: string | null;
4249
- resourceVersion?: string | null;
4250
- sdkVersion?: string | null;
4251
- isArchived?: boolean;
4252
- archivedLogCount?: number;
4492
+ interface StatCardDefaultProps extends StatCardBaseProps {
4493
+ variant?: 'default';
4494
+ /** Theme color for the icon (defaults to theme primary) */
4495
+ color?: MantineColor;
4496
+ isLoading?: never;
4497
+ valueColor?: never;
4253
4498
  }
4254
-
4499
+ interface StatCardHeroProps extends StatCardBaseProps {
4500
+ variant: 'hero';
4501
+ /** Whether data is loading */
4502
+ isLoading?: boolean;
4503
+ /** Custom color for the value text */
4504
+ valueColor?: string;
4505
+ /** Card sizing — 'sm' (default) for compact layouts, 'md' for spacious layouts */
4506
+ size?: 'sm' | 'md';
4507
+ color?: never;
4508
+ }
4509
+ type StatCardProps = StatCardDefaultProps | StatCardHeroProps;
4255
4510
  /**
4256
- * Resource Type Metadata
4511
+ * StatCard - Stat display card with icon, label, and value.
4257
4512
  *
4258
- * Centralized metadata for ResourceDefinition types including icon names and colors.
4259
- * Icon names reference @tabler/icons-react - UI layer maps these to actual components.
4513
+ * Supports two variants:
4514
+ * - `default`: Compact card with ThemeIcon (used in admin overviews)
4515
+ * - `hero`: Glass card with glowing icon ring (used on dashboards)
4516
+ *
4517
+ * @example
4518
+ * ```tsx
4519
+ * // Default variant
4520
+ * <StatCard label="Total Executions" value={150} icon={IconPlayerPlay} color="blue" />
4521
+ *
4522
+ * // Hero variant
4523
+ * <StatCard variant="hero" label="Executions" value={43} icon={IconPlayerPlay} isLoading={false} />
4524
+ * ```
4260
4525
  */
4261
-
4526
+ declare function StatCard(props: StatCardProps): react_jsx_runtime.JSX.Element;
4262
4527
  /**
4263
- * Node color types for graph visualization
4264
- * Used by both @repo/core (metadata) and @repo/ui (components)
4528
+ * StatCardSkeleton - Loading skeleton for StatCard (default variant)
4265
4529
  */
4266
- type NodeColorType = 'violet' | 'blue' | 'orange' | 'teal' | 'gray' | 'yellow';
4530
+ declare function StatCardSkeleton(): react_jsx_runtime.JSX.Element;
4267
4531
 
4268
- type ActivityType = 'workflow_execution' | 'agent_run' | 'hitl_action' | 'webhook_received' | 'webhook_executed' | 'webhook_failed' | 'credential_change' | 'api_key_change' | 'deployment_change' | 'membership_change';
4269
- type ActivityStatus = 'success' | 'failure' | 'pending' | 'approved' | 'rejected' | 'completed';
4270
- interface Activity {
4271
- id: string;
4272
- organizationId: string;
4273
- activityType: ActivityType;
4274
- status: ActivityStatus;
4275
- title: string;
4276
- description: string | null;
4277
- entityType: string;
4278
- entityId: string;
4279
- entityName: string | null;
4280
- metadata: Record<string, unknown> | null;
4281
- actorId: string | null;
4282
- actorType: string | null;
4283
- occurredAt: Date;
4284
- createdAt: Date;
4532
+ interface StyledMarkdownProps {
4533
+ /** Markdown content to render */
4534
+ children: string;
4535
+ /** Custom component overrides */
4536
+ components?: Partial<Components>;
4537
+ /** Additional class name */
4538
+ className?: string;
4539
+ /** Inline styles for the wrapper div */
4540
+ style?: React.CSSProperties;
4285
4541
  }
4286
-
4287
4542
  /**
4288
- * Execution Runner Types
4543
+ * Styled markdown renderer with Mantine components and syntax highlighting
4289
4544
  *
4290
- * Shared types for the Execution Runner UI feature.
4291
- * Used by both API (apps/api) and frontend (apps/command-center).
4545
+ * Features:
4546
+ * - Colored headings using theme primary color
4547
+ * - Syntax-highlighted code blocks (oneDark theme, no token backgrounds)
4548
+ * - Styled inline code with Mantine Code component
4549
+ * - Styled blockquotes with left border
4550
+ * - Proper list styling
4551
+ *
4552
+ * @example
4553
+ * ```tsx
4554
+ * import { StyledMarkdown } from '@repo/ui'
4555
+ *
4556
+ * <StyledMarkdown>{markdownContent}</StyledMarkdown>
4557
+ * ```
4292
4558
  */
4559
+ declare function StyledMarkdown({ children, components, className, style }: StyledMarkdownProps): react_jsx_runtime.JSX.Element;
4293
4560
 
4294
- interface ExecutionRunnerCatalogItem {
4295
- resourceId: string;
4296
- resourceName: string;
4297
- resourceType: 'workflow' | 'agent';
4298
- description?: string;
4299
- status: 'dev' | 'prod';
4300
- version: string;
4301
- interface: SerializedExecutionInterface;
4561
+ interface JsonViewerProps {
4562
+ /** JSON data to display (will be stringified) or pre-formatted JSON string */
4563
+ data: unknown;
4564
+ /** Maximum height with scroll (e.g., '300px'). If not set, expands to content */
4565
+ maxHeight?: string | number;
4566
+ /** Font size override */
4567
+ fontSize?: string | number;
4302
4568
  }
4303
-
4304
4569
  /**
4305
- * Deployment types browser-safe
4570
+ * Syntax-highlighted JSON viewer component
4306
4571
  *
4307
- * Canonical API response types for the deployment resource.
4308
- * The API's transformRow converts snake_case DB columns to these camelCase fields.
4572
+ * @example
4573
+ * ```tsx
4574
+ * import { JsonViewer } from '@repo/ui'
4575
+ *
4576
+ * <JsonViewer data={{ foo: 'bar', count: 42 }} />
4577
+ * <JsonViewer data={apiResponse} maxHeight={300} />
4578
+ * ```
4309
4579
  */
4310
- type DeploymentStatus = 'deploying' | 'active' | 'failed' | 'rolled_back' | 'stopped';
4311
- interface Deployment {
4312
- id: string;
4313
- organizationId: string;
4314
- status: DeploymentStatus;
4315
- sdkVersion: string;
4316
- deploymentVersion: string | null;
4317
- port: number | null;
4318
- pid: number | null;
4319
- tarballPath: string | null;
4320
- errorMessage: string | null;
4321
- createdAt: string;
4322
- updatedAt: string;
4323
- }
4580
+ declare function JsonViewer({ data, maxHeight, fontSize }: JsonViewerProps): react_jsx_runtime.JSX.Element;
4324
4581
 
4582
+ interface ContextViewerProps {
4583
+ /** Any JSON-serializable data to display in a human-readable format */
4584
+ data: unknown;
4585
+ }
4325
4586
  /**
4326
- * GET /api/credentials - List credentials
4587
+ * Auto-formats any JSON context into a human-readable layout.
4588
+ *
4589
+ * - Strings → rendered as markdown (supports formatting, lists, tables)
4590
+ * - Flat key-value objects → labeled field list
4591
+ * - Nested objects → indented subsections with left border
4592
+ * - Arrays → bulleted lists or bordered cards
4593
+ * - null/undefined/boolean/number → inline text
4594
+ *
4595
+ * No display configuration needed — the component infers layout from data shape.
4327
4596
  */
4328
- declare const ListCredentialsResponseSchema: z.ZodObject<{
4329
- credentials: z.ZodArray<z.ZodObject<{
4330
- id: z.ZodString;
4331
- name: z.ZodString;
4332
- type: z.ZodString;
4333
- provider: z.ZodNullable<z.ZodString>;
4334
- createdAt: z.ZodString;
4335
- }, z.core.$strip>>;
4336
- }, z.core.$strip>;
4337
- /** API response type for a single credential list item */
4338
- type CredentialListItem = z.infer<typeof ListCredentialsResponseSchema>['credentials'][number];
4597
+ declare function ContextViewer({ data }: ContextViewerProps): react_jsx_runtime.JSX.Element;
4339
4598
 
4340
4599
  interface TimeRangeSelectorProps {
4341
4600
  value: TimeRange;
@@ -4446,7 +4705,7 @@ interface ICustomModalProps {
4446
4705
  children: React__default.ReactNode | React__default.ReactNode[] | string;
4447
4706
  loading?: boolean;
4448
4707
  style?: React__default.CSSProperties;
4449
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4708
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full' | string;
4450
4709
  }
4451
4710
  declare const CustomModal: ({ children, opened, onClose, loading, style, size }: ICustomModalProps) => react_jsx_runtime.JSX.Element;
4452
4711
 
@@ -4633,7 +4892,8 @@ interface CreateCredentialResponse {
4633
4892
  declare const WebhookEndpointResponseSchema: z.ZodObject<{
4634
4893
  id: z.ZodString;
4635
4894
  organizationId: z.ZodString;
4636
- key: z.ZodString;
4895
+ key: z.ZodOptional<z.ZodString>;
4896
+ keyPrefix: z.ZodNullable<z.ZodString>;
4637
4897
  name: z.ZodString;
4638
4898
  description: z.ZodNullable<z.ZodString>;
4639
4899
  resourceId: z.ZodNullable<z.ZodString>;
@@ -6296,6 +6556,9 @@ type FeatureIconComponent = ComponentType<{
6296
6556
  size?: number;
6297
6557
  stroke?: number;
6298
6558
  }>;
6559
+ type FeatureSidebarWidthResolver = number | ((context: {
6560
+ currentPath: string;
6561
+ }) => number);
6299
6562
  interface FeatureModule {
6300
6563
  /** Unique stable identifier for this feature module. */
6301
6564
  key: string;
@@ -6307,6 +6570,8 @@ interface FeatureModule {
6307
6570
  icon?: FeatureIconComponent;
6308
6571
  /** Sidebar component rendered when this feature's subtree route is active. */
6309
6572
  sidebar?: FeatureSidebarComponent;
6573
+ /** Optional shell sidebar width override. Defaults to 250px. */
6574
+ sidebarWidth?: FeatureSidebarWidthResolver;
6310
6575
  /** Operations-only bridge connecting this feature to the organization graph node. */
6311
6576
  organizationGraph?: OrganizationGraphFeatureBridge;
6312
6577
  }
@@ -6476,5 +6741,5 @@ declare const OperationsSidebarMiddle: () => react_jsx_runtime.JSX.Element;
6476
6741
 
6477
6742
  declare const operationsManifest: FeatureModule;
6478
6743
 
6479
- export { APIErrorAlert, AbsoluteScheduleForm, ActionModal, ActivityCard, ActivityFeedWidget, ActivityFilters as ActivityFiltersBar, ActivityTable, ActivityTimeline, AgentDefinitionDisplay, AgentExecutionLogs, AgentExecutionTimeline, AgentExecutionVisualizer, AgentIterationEdge, AgentIterationNode, AllTasksPage, ApiKeyDisplayModal, ApiKeyList, ApiKeySettings, BaseEdge, BaseExecutionLogs, BaseExecutionLogsHeader, BaseExecutionLogsStates, BaseNode, Breadcrumbs, BusinessImpactCard, CONTAINER_CONSTANTS, CardHeader, CenteredErrorState, CheckpointGroup, CollapsibleJsonSection, CollapsibleSection, CommandQueueSidebar, CommandQueueSidebarMiddle, CommandQueueSidebarTop, CommandQueueTaskRow, CommandViewEdge, CommandViewGraph, CommandViewNode, ConfigCard, ConfirmationInputModal, ConfirmationModal, ContentSections, ContextUsageBadge, ContextViewer, ContractDisplay, CostBreakdownCard, CostByModelTable, CostMetricsCard, CrashErrorFallback, CreateApiKeyModal, CreateCredentialModal, CreateScheduleModal, CredentialList, CredentialSettings, CrmOverview, CrmSidebar, CrmSidebarMiddle, CrmSidebarTop, CustomModal, CustomSelector, DEAL_STAGES, DEFAULT_KANBAN_CONFIG, DealDetailPage, DealDrawer, DealKanbanCard, DealsListPage, DeleteScheduleModal, DeploymentDetailModal, DeploymentList, DeploymentSettings, DeploymentStatusBadge, DetailCardSkeleton, EditApiKeyModal, ElevasisLoader, EmptyState, EmptyVisualizer, ErrorAnalysisCard, ErrorBreakdownTable, ErrorReportCard, ExecutionBreakdownTable, ExecutionErrorSection, ExecutionHealthCard, ExecutionLogsFilters as ExecutionLogsFilterBar, ExecutionLogsTable, ExecutionStats, ExecutionStatusBadge, FeatureUnavailableState, FilterBar, FormFieldRenderer, GlowDot, GraphBackground, GraphContainer, GraphFitViewButton, GraphFitViewHandler, GraphLegend, HealthStatusCard, JsonViewer, KanbanBoard, LEAD_GEN_ROUTE_LINKS, LIST_TEMPLATE_OPTIONS, LeadGenCompaniesPage, LeadGenContactsPage, LeadGenListDetailPage, LeadGenListsPage, LeadGenOverviewPage, LeadGenRouteShell, LeadGenSidebar, LeadGenSidebarMiddle, LeadGenSidebarTop, ListSkeleton, LogEntry, LogGroup, MdxRenderer, MembershipFeaturePanel, MembershipStatusBadge, MetricsStrip, MilestoneTimeline, MyTasksPanel, NavigationButton, NewKnowledgeMapEdge, NewKnowledgeMapGraph, NewKnowledgeMapNode, NotificationBell, NotificationItem, NotificationList, NotificationPanel, OAuthConnectModal, OperationsSidebar, OperationsSidebarMiddle, OperationsSidebarTop, OrganizationMembershipsList, PIPELINE_FUNNEL_ORDER, PageNotFound, PageTitleCaption, PipelineFunnelWidget, ProjectDetailPage, ProjectsListPage, ProjectsSidebar, ProjectsSidebarMiddle, ProjectsSidebarTop, QuickCreateActions, RecurringScheduleForm, RelativeScheduleForm, ResourceCard, ResourceDefinitionSection, ResourceErrorState, ResourceFilter, ResourceHeader, ResourceHealthChart, ResourceHealthPanel, ResourceNotFoundState, RichTextEditor, RunResourceButton, SAVED_VIEW_PRESETS, SEOSidebar, SEOSidebarMiddle, SEOSidebarTop, SHARED_VIZ_CONSTANTS, SavedViewsPanel, ScheduleCard, ScheduleDetailModal, ScheduleTypeSelector, SessionMemory, SortableHeader, StatCard, StatCardSkeleton, StatsCardSkeleton, StatusBadge, StyledMarkdown, TabCountBadge, TableSelectionToolbar, TaskCard, TaskScheduler, TasksDueWidget, TimeRangeSelector, TimelineAxis, TimelineBar, TimelineContainer, TimelineRow, ToolsListDisplay, TrendIndicator, UnifiedWorkflowEdge, UnifiedWorkflowGraph, UnifiedWorkflowNode, UpcomingMilestonesPage, VisualizerContainer, WebhookUrlDisplayModal, WorkflowDefinitionDisplay, WorkflowExecutionLogs, WorkflowExecutionTimeline, ZodFormRenderer, buildErrorReport, buildListConfig, calculateProgress, catalogItemToResourceDefinition, crmManifest, deliveryManifest, formatStatusLabel, getEnrichmentColor, getExecutionStatusConfig, getGraphBackgroundStyles, getHealthColor, getIcon, getLogLevelConfig, getStatusColor, iconMap, leadGenManifest, mdxComponents, milestoneStatusColors, monitoringManifest, noteTypeColors, operationsManifest, projectStatusColors, seoManifest, settingsManifest, showApiErrorNotification, showErrorNotification, showInfoNotification, showSuccessNotification, showWarningNotification, taskStatusColors, taskTypeColors, useCrmPipelineSummary, useCrmQuickMetrics, useDeleteLists, useGraphBackgroundStyles, useGraphTheme, useNewKnowledgeMapLayout, useRecentCrmActivity };
6480
- export type { ActivityEntry, ActivityFiltersProps, ActivityTableProps, BaseEdgeProps, BaseExecutionLogsProps, BreadcrumbsProps, CommandViewGraphRef, ContextViewerProps, CostByModelTableProps, CrashErrorFallbackProps, CrmOverviewProps, DealDrawerProps, DealKanbanCardProps, ErrorAnalysisCardProps, ErrorReportCardProps, ExecutionBreakdownTableProps, ExecutionHealthCardProps, ExecutionLogEntry, ExecutionLogsFiltersProps, ExecutionLogsTableProps, FeatureUnavailableStateProps, FitViewButtonVariant, FormFieldRendererProps, GraphFitViewHandlerProps, JsonViewerProps, KanbanBoardProps, KnowledgeMapEdgeData, KnowledgeMapNodeData, LogLevel, MdxRendererProps, NavigationButtonProps, ProjectsSidebarMiddleProps, ResourceHealthPanelProps, RichTextEditorProps, RunResourceButtonProps, RunResourceInputResolver, SavedViewPreset, ScheduleType, SerializedKnowledgeMap, SerializedKnowledgeNode, StatCardProps, StyledMarkdownProps, TaskFilterStatus, TrendIndicatorProps, ZodFormRendererProps };
6744
+ export { APIErrorAlert, AbsoluteScheduleForm, ActionModal, ActivityCard, ActivityFeedWidget, ActivityFilters as ActivityFiltersBar, ActivityTable, ActivityTimeline, AgentDefinitionDisplay, AgentExecutionLogs, AgentExecutionTimeline, AgentExecutionVisualizer, AgentIterationEdge, AgentIterationNode, AllTasksPage, ApiKeyDisplayModal, ApiKeyList, ApiKeySettings, BaseEdge, BaseExecutionLogs, BaseExecutionLogsHeader, BaseExecutionLogsStates, BaseNode, Breadcrumbs, BusinessImpactCard, CONTAINER_CONSTANTS, Can, CardHeader, CenteredErrorState, CheckpointGroup, CollapsibleJsonSection, CollapsibleSection, CommandQueueSidebar, CommandQueueSidebarMiddle, CommandQueueSidebarTop, CommandQueueTaskRow, CommandViewEdge, CommandViewGraph, CommandViewNode, ConfigCard, ConfirmationInputModal, ConfirmationModal, ContentSections, ContextUsageBadge, ContextViewer, ContractDisplay, CostBreakdownCard, CostByModelTable, CostMetricsCard, CrashErrorFallback, CreateApiKeyModal, CreateCredentialModal, CreateRoleModal, CreateScheduleModal, CredentialList, CredentialSettings, CrmOverview, CrmSidebar, CrmSidebarMiddle, CrmSidebarTop, CustomModal, CustomSelector, DEAL_STAGES, DEFAULT_KANBAN_CONFIG, DealDetailPage, DealDrawer, DealKanbanCard, DealsListPage, DeleteScheduleModal, DeploymentDetailModal, DeploymentList, DeploymentSettings, DeploymentStatusBadge, DetailCardSkeleton, EditApiKeyModal, ElevasisLoader, EmptyState, EmptyVisualizer, ErrorAnalysisCard, ErrorBreakdownTable, ErrorReportCard, ExecutionBreakdownTable, ExecutionErrorSection, ExecutionHealthCard, ExecutionLogsFilters as ExecutionLogsFilterBar, ExecutionLogsTable, ExecutionStats, ExecutionStatusBadge, FeatureUnavailableState, FilterBar, FormFieldRenderer, GlowDot, GraphBackground, GraphContainer, GraphFitViewButton, GraphFitViewHandler, GraphLegend, HealthStatusCard, JsonViewer, KanbanBoard, LEAD_GEN_ROUTE_LINKS, LIST_TEMPLATE_OPTIONS, LeadGenCompaniesPage, LeadGenContactsPage, LeadGenListDetailPage, LeadGenListsPage, LeadGenOverviewPage, LeadGenRouteShell, LeadGenSidebar, LeadGenSidebarMiddle, LeadGenSidebarTop, ListSkeleton, LogEntry, LogGroup, MdxRenderer, MembershipFeaturePanel, MembershipStatusBadge, MetricsStrip, MilestoneTimeline, MyTasksPanel, NavigationButton, NewKnowledgeMapEdge, NewKnowledgeMapGraph, NewKnowledgeMapNode, NoAccessState, NotificationBell, NotificationItem, NotificationList, NotificationPanel, OAuthConnectModal, OperationsSidebar, OperationsSidebarMiddle, OperationsSidebarTop, OrganizationMembershipsList, PIPELINE_FUNNEL_ORDER, PageNotFound, PageTitleCaption, PermissionMatrix, PipelineFunnelWidget, ProjectDetailPage, ProjectsListPage, ProjectsSidebar, ProjectsSidebarMiddle, ProjectsSidebarTop, QuickCreateActions, RecurringScheduleForm, RelativeScheduleForm, ResourceCard, ResourceDefinitionSection, ResourceErrorState, ResourceFilter, ResourceHeader, ResourceHealthChart, ResourceHealthPanel, ResourceNotFoundState, RichTextEditor, RoleBadge, RunResourceButton, SAVED_VIEW_PRESETS, SEOSidebar, SEOSidebarMiddle, SEOSidebarTop, SHARED_VIZ_CONSTANTS, SavedViewsPanel, ScheduleCard, ScheduleDetailModal, ScheduleTypeSelector, SessionMemory, SortableHeader, StatCard, StatCardSkeleton, StatsCardSkeleton, StatusBadge, StyledMarkdown, TabCountBadge, TableSelectionToolbar, TaskCard, TaskScheduler, TasksDueWidget, TimeRangeSelector, TimelineAxis, TimelineBar, TimelineContainer, TimelineRow, ToolsListDisplay, TrendIndicator, UnifiedWorkflowEdge, UnifiedWorkflowGraph, UnifiedWorkflowNode, UpcomingMilestonesPage, VisualizerContainer, WebhookUrlDisplayModal, WorkflowDefinitionDisplay, WorkflowExecutionLogs, WorkflowExecutionTimeline, ZodFormRenderer, buildErrorReport, buildListConfig, calculateProgress, catalogItemToResourceDefinition, crmManifest, deliveryManifest, formatStatusLabel, getEnrichmentColor, getExecutionStatusConfig, getGraphBackgroundStyles, getHealthColor, getIcon, getLogLevelConfig, getStatusColor, iconMap, leadGenManifest, mdxComponents, milestoneStatusColors, monitoringManifest, noteTypeColors, operationsManifest, projectStatusColors, seoManifest, settingsManifest, showApiErrorNotification, showAuthError, showErrorNotification, showInfoNotification, showSuccessNotification, showWarningNotification, taskStatusColors, taskTypeColors, useCrmPipelineSummary, useCrmQuickMetrics, useDeleteLists, useGraphBackgroundStyles, useGraphTheme, useNewKnowledgeMapLayout, useRecentCrmActivity };
6745
+ export type { ActivityEntry, ActivityFiltersProps, ActivityTableProps, BaseEdgeProps, BaseExecutionLogsProps, BreadcrumbsProps, CommandViewGraphRef, ContextViewerProps, CostByModelTableProps, CrashErrorFallbackProps, CreateRoleModalProps, CrmOverviewProps, DealDrawerProps, DealKanbanCardProps, ErrorAnalysisCardProps, ErrorReportCardProps, ExecutionBreakdownTableProps, ExecutionHealthCardProps, ExecutionLogEntry, ExecutionLogsFiltersProps, ExecutionLogsTableProps, FeatureUnavailableStateProps, FitViewButtonVariant, FormFieldRendererProps, GraphFitViewHandlerProps, JsonViewerProps, KanbanBoardProps, KnowledgeMapEdgeData, KnowledgeMapNodeData, LogLevel, MdxRendererProps, NavigationButtonProps, PermissionRow, ProjectsSidebarMiddleProps, ResourceHealthPanelProps, RichTextEditorProps, RunResourceButtonProps, RunResourceInputResolver, SavedViewPreset, ScheduleType, SerializedKnowledgeMap, SerializedKnowledgeNode, StatCardProps, StyledMarkdownProps, TaskFilterStatus, TrendIndicatorProps, ZodFormRendererProps };