@elevasis/ui 1.3.4 → 1.3.5

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 (213) hide show
  1. package/dist/api/index.js +1 -1
  2. package/dist/auth/index.d.ts +174 -14
  3. package/dist/{chunk-XLV6LYN2.js → chunk-LBPALY25.js} +0 -1
  4. package/dist/{chunk-LTQAAIGE.js → chunk-Y2I5JJ3N.js} +1 -1
  5. package/dist/hooks/index.d.ts +4401 -11
  6. package/dist/hooks/published.d.ts +5013 -19
  7. package/dist/index.d.ts +6316 -15
  8. package/dist/index.js +18 -97
  9. package/dist/initialization/index.d.ts +2222 -22
  10. package/dist/organization/index.d.ts +266 -21
  11. package/dist/profile/index.d.ts +2158 -14
  12. package/dist/provider/index.d.ts +266 -7
  13. package/dist/provider/index.js +12 -3
  14. package/dist/provider/published.d.ts +263 -9
  15. package/dist/provider/published.js +2 -2
  16. package/package.json +46 -5
  17. package/dist/auth/guards/AdminGuard.d.ts +0 -32
  18. package/dist/auth/guards/AdminGuard.d.ts.map +0 -1
  19. package/dist/auth/guards/ProtectedRoute.d.ts +0 -60
  20. package/dist/auth/guards/ProtectedRoute.d.ts.map +0 -1
  21. package/dist/auth/guards/__tests__/AdminGuard.test.d.ts +0 -12
  22. package/dist/auth/guards/__tests__/AdminGuard.test.d.ts.map +0 -1
  23. package/dist/auth/guards/__tests__/ProtectedRoute.test.d.ts +0 -14
  24. package/dist/auth/guards/__tests__/ProtectedRoute.test.d.ts.map +0 -1
  25. package/dist/auth/index.d.ts.map +0 -1
  26. package/dist/hooks/command-queue/index.d.ts +0 -7
  27. package/dist/hooks/command-queue/index.d.ts.map +0 -1
  28. package/dist/hooks/command-queue/useCommandQueue.d.ts +0 -33
  29. package/dist/hooks/command-queue/useCommandQueue.d.ts.map +0 -1
  30. package/dist/hooks/command-queue/useCommandQueueTotals.d.ts +0 -17
  31. package/dist/hooks/command-queue/useCommandQueueTotals.d.ts.map +0 -1
  32. package/dist/hooks/command-queue/useDeleteTask.d.ts +0 -5
  33. package/dist/hooks/command-queue/useDeleteTask.d.ts.map +0 -1
  34. package/dist/hooks/command-queue/usePatchTask.d.ts +0 -6
  35. package/dist/hooks/command-queue/usePatchTask.d.ts.map +0 -1
  36. package/dist/hooks/command-queue/useSubmitAction.d.ts +0 -29
  37. package/dist/hooks/command-queue/useSubmitAction.d.ts.map +0 -1
  38. package/dist/hooks/executions/index.d.ts +0 -16
  39. package/dist/hooks/executions/index.d.ts.map +0 -1
  40. package/dist/hooks/executions/useBulkDeleteExecutions.d.ts +0 -15
  41. package/dist/hooks/executions/useBulkDeleteExecutions.d.ts.map +0 -1
  42. package/dist/hooks/executions/useCancelExecution.d.ts +0 -20
  43. package/dist/hooks/executions/useCancelExecution.d.ts.map +0 -1
  44. package/dist/hooks/executions/useDeleteExecution.d.ts +0 -13
  45. package/dist/hooks/executions/useDeleteExecution.d.ts.map +0 -1
  46. package/dist/hooks/executions/useExecuteAsync.d.ts +0 -21
  47. package/dist/hooks/executions/useExecuteAsync.d.ts.map +0 -1
  48. package/dist/hooks/executions/useExecution.d.ts +0 -10
  49. package/dist/hooks/executions/useExecution.d.ts.map +0 -1
  50. package/dist/hooks/executions/useExecutions.d.ts +0 -16
  51. package/dist/hooks/executions/useExecutions.d.ts.map +0 -1
  52. package/dist/hooks/executions/useResourceDefinition.d.ts +0 -9
  53. package/dist/hooks/executions/useResourceDefinition.d.ts.map +0 -1
  54. package/dist/hooks/executions/useResources.d.ts +0 -15
  55. package/dist/hooks/executions/useResources.d.ts.map +0 -1
  56. package/dist/hooks/executions/useRetryExecution.d.ts +0 -16
  57. package/dist/hooks/executions/useRetryExecution.d.ts.map +0 -1
  58. package/dist/hooks/feature-access/createUseFeatureAccess.d.ts +0 -44
  59. package/dist/hooks/feature-access/createUseFeatureAccess.d.ts.map +0 -1
  60. package/dist/hooks/feature-access/index.d.ts +0 -2
  61. package/dist/hooks/feature-access/index.d.ts.map +0 -1
  62. package/dist/hooks/index.d.ts.map +0 -1
  63. package/dist/hooks/monitoring/index.d.ts +0 -9
  64. package/dist/hooks/monitoring/index.d.ts.map +0 -1
  65. package/dist/hooks/monitoring/useActivities.d.ts +0 -52
  66. package/dist/hooks/monitoring/useActivities.d.ts.map +0 -1
  67. package/dist/hooks/monitoring/useCostSummary.d.ts +0 -7
  68. package/dist/hooks/monitoring/useCostSummary.d.ts.map +0 -1
  69. package/dist/hooks/monitoring/useExecutionHealth.d.ts +0 -10
  70. package/dist/hooks/monitoring/useExecutionHealth.d.ts.map +0 -1
  71. package/dist/hooks/monitoring/useExecutionLogs.d.ts +0 -56
  72. package/dist/hooks/monitoring/useExecutionLogs.d.ts.map +0 -1
  73. package/dist/hooks/monitoring/useNotifications.d.ts +0 -11
  74. package/dist/hooks/monitoring/useNotifications.d.ts.map +0 -1
  75. package/dist/hooks/notifications/index.d.ts +0 -8
  76. package/dist/hooks/notifications/index.d.ts.map +0 -1
  77. package/dist/hooks/notifications/useMarkAllAsRead.d.ts +0 -2
  78. package/dist/hooks/notifications/useMarkAllAsRead.d.ts.map +0 -1
  79. package/dist/hooks/notifications/useMarkAsRead.d.ts +0 -2
  80. package/dist/hooks/notifications/useMarkAsRead.d.ts.map +0 -1
  81. package/dist/hooks/notifications/useNotificationCount.d.ts +0 -8
  82. package/dist/hooks/notifications/useNotificationCount.d.ts.map +0 -1
  83. package/dist/hooks/observability/index.d.ts +0 -19
  84. package/dist/hooks/observability/index.d.ts.map +0 -1
  85. package/dist/hooks/observability/useBusinessImpact.d.ts +0 -9
  86. package/dist/hooks/observability/useBusinessImpact.d.ts.map +0 -1
  87. package/dist/hooks/observability/useCostBreakdown.d.ts +0 -10
  88. package/dist/hooks/observability/useCostBreakdown.d.ts.map +0 -1
  89. package/dist/hooks/observability/useCostByModel.d.ts +0 -3
  90. package/dist/hooks/observability/useCostByModel.d.ts.map +0 -1
  91. package/dist/hooks/observability/useCostTrends.d.ts +0 -3
  92. package/dist/hooks/observability/useCostTrends.d.ts.map +0 -1
  93. package/dist/hooks/observability/useDashboardMetrics.d.ts +0 -3
  94. package/dist/hooks/observability/useDashboardMetrics.d.ts.map +0 -1
  95. package/dist/hooks/observability/useErrorAnalysis.d.ts +0 -7
  96. package/dist/hooks/observability/useErrorAnalysis.d.ts.map +0 -1
  97. package/dist/hooks/observability/useErrorDetails.d.ts +0 -20
  98. package/dist/hooks/observability/useErrorDetails.d.ts.map +0 -1
  99. package/dist/hooks/observability/useErrorDistribution.d.ts +0 -12
  100. package/dist/hooks/observability/useErrorDistribution.d.ts.map +0 -1
  101. package/dist/hooks/observability/useErrorTrends.d.ts +0 -12
  102. package/dist/hooks/observability/useErrorTrends.d.ts.map +0 -1
  103. package/dist/hooks/observability/useResolveError.d.ts +0 -17
  104. package/dist/hooks/observability/useResolveError.d.ts.map +0 -1
  105. package/dist/hooks/observability/useTopFailingResources.d.ts +0 -13
  106. package/dist/hooks/observability/useTopFailingResources.d.ts.map +0 -1
  107. package/dist/hooks/published.d.ts.map +0 -1
  108. package/dist/hooks/scheduling/index.d.ts +0 -5
  109. package/dist/hooks/scheduling/index.d.ts.map +0 -1
  110. package/dist/hooks/scheduling/useSchedules.d.ts +0 -185
  111. package/dist/hooks/scheduling/useSchedules.d.ts.map +0 -1
  112. package/dist/hooks/sessions/index.d.ts +0 -8
  113. package/dist/hooks/sessions/index.d.ts.map +0 -1
  114. package/dist/hooks/sessions/useSessionExecutions.d.ts +0 -13
  115. package/dist/hooks/sessions/useSessionExecutions.d.ts.map +0 -1
  116. package/dist/hooks/sessions/useSessionMessages.d.ts +0 -7
  117. package/dist/hooks/sessions/useSessionMessages.d.ts.map +0 -1
  118. package/dist/hooks/sessions/useSessions.d.ts +0 -26
  119. package/dist/hooks/sessions/useSessions.d.ts.map +0 -1
  120. package/dist/index.d.ts.map +0 -1
  121. package/dist/initialization/InitializationProvider.d.ts +0 -48
  122. package/dist/initialization/InitializationProvider.d.ts.map +0 -1
  123. package/dist/initialization/hooks/useAppInitialization.d.ts +0 -32
  124. package/dist/initialization/hooks/useAppInitialization.d.ts.map +0 -1
  125. package/dist/initialization/index.d.ts.map +0 -1
  126. package/dist/organization/context/OrganizationProvider.d.ts +0 -20
  127. package/dist/organization/context/OrganizationProvider.d.ts.map +0 -1
  128. package/dist/organization/hooks/useOrgInitialization.d.ts +0 -56
  129. package/dist/organization/hooks/useOrgInitialization.d.ts.map +0 -1
  130. package/dist/organization/index.d.ts.map +0 -1
  131. package/dist/profile/context/ProfileProvider.d.ts +0 -27
  132. package/dist/profile/context/ProfileProvider.d.ts.map +0 -1
  133. package/dist/profile/hooks/useUserProfile.d.ts +0 -31
  134. package/dist/profile/hooks/useUserProfile.d.ts.map +0 -1
  135. package/dist/profile/index.d.ts.map +0 -1
  136. package/dist/provider/CoreAuthKitInner.d.ts +0 -12
  137. package/dist/provider/CoreAuthKitInner.d.ts.map +0 -1
  138. package/dist/provider/ElevasisCoreProvider.d.ts +0 -39
  139. package/dist/provider/ElevasisCoreProvider.d.ts.map +0 -1
  140. package/dist/provider/ElevasisServiceContext.d.ts +0 -31
  141. package/dist/provider/ElevasisServiceContext.d.ts.map +0 -1
  142. package/dist/provider/__tests__/CoreAuthKitInner.test.d.ts +0 -2
  143. package/dist/provider/__tests__/CoreAuthKitInner.test.d.ts.map +0 -1
  144. package/dist/provider/__tests__/ElevasisCoreProvider.test.d.ts +0 -2
  145. package/dist/provider/__tests__/ElevasisCoreProvider.test.d.ts.map +0 -1
  146. package/dist/provider/index.d.ts.map +0 -1
  147. package/dist/provider/published.d.ts.map +0 -1
  148. package/dist/provider/types.d.ts +0 -143
  149. package/dist/provider/types.d.ts.map +0 -1
  150. package/dist/provider/types.js +0 -1
  151. package/dist/sdk-barrel.d.ts +0 -20
  152. package/dist/sdk-barrel.d.ts.map +0 -1
  153. package/dist/theme/cssVariables.d.ts +0 -12
  154. package/dist/theme/cssVariables.d.ts.map +0 -1
  155. package/dist/theme/cssVariables.js +0 -93
  156. package/dist/theme/index.d.ts +0 -4
  157. package/dist/theme/index.d.ts.map +0 -1
  158. package/dist/theme/index.js +0 -1
  159. package/dist/theme/presets/__tests__/getPreset.test.d.ts +0 -2
  160. package/dist/theme/presets/__tests__/getPreset.test.d.ts.map +0 -1
  161. package/dist/theme/presets/abyss.d.ts +0 -3
  162. package/dist/theme/presets/abyss.d.ts.map +0 -1
  163. package/dist/theme/presets/abyss.js +0 -54
  164. package/dist/theme/presets/aurora.d.ts +0 -8
  165. package/dist/theme/presets/aurora.d.ts.map +0 -1
  166. package/dist/theme/presets/aurora.js +0 -59
  167. package/dist/theme/presets/canopy.d.ts +0 -3
  168. package/dist/theme/presets/canopy.d.ts.map +0 -1
  169. package/dist/theme/presets/canopy.js +0 -58
  170. package/dist/theme/presets/cyber-flux.d.ts +0 -8
  171. package/dist/theme/presets/cyber-flux.d.ts.map +0 -1
  172. package/dist/theme/presets/cyber-flux.js +0 -66
  173. package/dist/theme/presets/cyber-strike.d.ts +0 -9
  174. package/dist/theme/presets/cyber-strike.d.ts.map +0 -1
  175. package/dist/theme/presets/cyber-strike.js +0 -62
  176. package/dist/theme/presets/cyber-void.d.ts +0 -8
  177. package/dist/theme/presets/cyber-void.d.ts.map +0 -1
  178. package/dist/theme/presets/cyber-void.js +0 -62
  179. package/dist/theme/presets/cyber-volt.d.ts +0 -8
  180. package/dist/theme/presets/cyber-volt.d.ts.map +0 -1
  181. package/dist/theme/presets/cyber-volt.js +0 -66
  182. package/dist/theme/presets/default.d.ts +0 -4
  183. package/dist/theme/presets/default.d.ts.map +0 -1
  184. package/dist/theme/presets/ember.d.ts +0 -8
  185. package/dist/theme/presets/ember.d.ts.map +0 -1
  186. package/dist/theme/presets/ember.js +0 -63
  187. package/dist/theme/presets/honey.d.ts +0 -3
  188. package/dist/theme/presets/honey.d.ts.map +0 -1
  189. package/dist/theme/presets/honey.js +0 -62
  190. package/dist/theme/presets/index.d.ts +0 -6
  191. package/dist/theme/presets/index.d.ts.map +0 -1
  192. package/dist/theme/presets/index.js +0 -39
  193. package/dist/theme/presets/midnight.d.ts +0 -8
  194. package/dist/theme/presets/midnight.d.ts.map +0 -1
  195. package/dist/theme/presets/midnight.js +0 -68
  196. package/dist/theme/presets/obsidian.d.ts +0 -3
  197. package/dist/theme/presets/obsidian.d.ts.map +0 -1
  198. package/dist/theme/presets/obsidian.js +0 -56
  199. package/dist/theme/presets/regal.d.ts +0 -8
  200. package/dist/theme/presets/regal.d.ts.map +0 -1
  201. package/dist/theme/presets/regal.js +0 -63
  202. package/dist/theme/presets/rose-gold.d.ts +0 -8
  203. package/dist/theme/presets/rose-gold.d.ts.map +0 -1
  204. package/dist/theme/presets/rose-gold.js +0 -63
  205. package/dist/theme/presets/slate.d.ts +0 -3
  206. package/dist/theme/presets/slate.d.ts.map +0 -1
  207. package/dist/theme/presets/slate.js +0 -56
  208. package/dist/theme/presets/tactical.d.ts +0 -8
  209. package/dist/theme/presets/tactical.d.ts.map +0 -1
  210. package/dist/theme/presets/tactical.js +0 -57
  211. package/dist/theme/presets/types.d.ts +0 -26
  212. package/dist/theme/presets/types.d.ts.map +0 -1
  213. package/dist/theme/presets/types.js +0 -1
@@ -1,11 +1,4401 @@
1
- export * from './command-queue';
2
- export * from './executions';
3
- export * from './monitoring';
4
- export * from './notifications';
5
- export * from './observability';
6
- export * from './scheduling';
7
- export * from './services';
8
- export * from './table';
9
- export * from './feature-access';
10
- export * from './sse';
11
- //# sourceMappingURL=index.d.ts.map
1
+ import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import * as react from 'react';
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Error categories for observability grouping and classification.
7
+ * Used to categorize errors in the execution_errors table metadata.
8
+ */
9
+ type ExecutionErrorCategory = 'llm' | 'tool' | 'workflow' | 'agent' | 'validation' | 'system';
10
+
11
+ /**
12
+ * Shared form field types for dynamic form generation
13
+ * Used by: Command Queue, Execution Runner UI, future form-based features
14
+ */
15
+ /**
16
+ * Supported form field types for action payloads
17
+ * Maps to Mantine form components
18
+ */
19
+ type FormFieldType = 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | 'richtext';
20
+ /**
21
+ * Form field definition
22
+ */
23
+ interface FormField {
24
+ /** Field key in payload object */
25
+ name: string;
26
+ /** Field label for UI */
27
+ label: string;
28
+ /** Field type (determines UI component) */
29
+ type: FormFieldType;
30
+ /** Default value */
31
+ defaultValue?: unknown;
32
+ /** Required field */
33
+ required?: boolean;
34
+ /** Placeholder text */
35
+ placeholder?: string;
36
+ /** Help text */
37
+ description?: string;
38
+ /** Options for select/radio */
39
+ options?: Array<{
40
+ label: string;
41
+ value: string | number;
42
+ }>;
43
+ /** Min/max for number */
44
+ min?: number;
45
+ max?: number;
46
+ /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
47
+ defaultValueFromContext?: string;
48
+ }
49
+ /**
50
+ * Form schema for action payload collection
51
+ */
52
+ interface FormSchema {
53
+ /** Form title */
54
+ title?: string;
55
+ /** Form description */
56
+ description?: string;
57
+ /** Form fields */
58
+ fields: FormField[];
59
+ }
60
+
61
+ /**
62
+ * Serialized Registry Types
63
+ *
64
+ * Pre-computed JSON-safe types for API responses and Command View.
65
+ * Serialization happens once at API startup, enabling instant response times.
66
+ */
67
+
68
+ /**
69
+ * Serialized form field for API responses
70
+ */
71
+ interface SerializedFormField {
72
+ name: string;
73
+ label: string;
74
+ type: FormFieldType;
75
+ defaultValue?: unknown;
76
+ required?: boolean;
77
+ placeholder?: string;
78
+ description?: string;
79
+ options?: Array<{
80
+ label: string;
81
+ value: string | number;
82
+ }>;
83
+ min?: number;
84
+ max?: number;
85
+ }
86
+ /**
87
+ * Serialized form schema for API responses
88
+ */
89
+ interface SerializedFormSchema {
90
+ title?: string;
91
+ description?: string;
92
+ fields: SerializedFormField[];
93
+ layout?: 'vertical' | 'horizontal' | 'grid';
94
+ }
95
+ /**
96
+ * Serialized execution form schema for API responses
97
+ */
98
+ interface SerializedExecutionFormSchema extends SerializedFormSchema {
99
+ fieldMappings?: Record<string, string>;
100
+ submitButton?: {
101
+ label?: string;
102
+ loadingLabel?: string;
103
+ confirmMessage?: string;
104
+ };
105
+ }
106
+ /**
107
+ * Serialized schedule config for API responses
108
+ */
109
+ interface SerializedScheduleConfig {
110
+ enabled: boolean;
111
+ defaultSchedule?: string;
112
+ allowedPatterns?: string[];
113
+ }
114
+ /**
115
+ * Serialized webhook config for API responses
116
+ */
117
+ interface SerializedWebhookConfig {
118
+ enabled: boolean;
119
+ payloadSchema?: unknown;
120
+ }
121
+ /**
122
+ * Serialized execution interface for API responses
123
+ */
124
+ interface SerializedExecutionInterface {
125
+ form: SerializedExecutionFormSchema;
126
+ schedule?: SerializedScheduleConfig;
127
+ webhook?: SerializedWebhookConfig;
128
+ }
129
+ /**
130
+ * Serialized agent definition (JSON-safe)
131
+ * Result of serializeDefinition(AgentDefinition)
132
+ */
133
+ interface SerializedAgentDefinition {
134
+ config: {
135
+ resourceId: string;
136
+ name: string;
137
+ description: string;
138
+ version: string;
139
+ type: 'agent';
140
+ status: 'dev' | 'prod';
141
+ /** Whether this resource is archived and should be excluded from registration and deployment */
142
+ archived?: boolean;
143
+ systemPrompt: string;
144
+ constraints?: {
145
+ maxIterations?: number;
146
+ timeout?: number;
147
+ maxSessionMemoryKeys?: number;
148
+ maxMemoryTokens?: number;
149
+ };
150
+ sessionCapable?: boolean;
151
+ memoryPreferences?: string;
152
+ };
153
+ modelConfig: {
154
+ provider: string;
155
+ model: string;
156
+ apiKey: string;
157
+ temperature: number;
158
+ maxOutputTokens: number;
159
+ topP?: number;
160
+ modelOptions?: Record<string, unknown>;
161
+ };
162
+ contract: {
163
+ inputSchema: object;
164
+ outputSchema?: object;
165
+ };
166
+ tools: Array<{
167
+ name: string;
168
+ description: string;
169
+ inputSchema?: object;
170
+ outputSchema?: object;
171
+ }>;
172
+ knowledgeMap?: {
173
+ nodeCount: number;
174
+ nodes: Array<{
175
+ id: string;
176
+ description: string;
177
+ loaded: boolean;
178
+ hasPrompt: boolean;
179
+ }>;
180
+ };
181
+ metricsConfig?: object;
182
+ interface?: SerializedExecutionInterface;
183
+ }
184
+ /**
185
+ * Serialized workflow definition (JSON-safe)
186
+ * Result of serializeDefinition(WorkflowDefinition)
187
+ */
188
+ interface SerializedWorkflowDefinition {
189
+ config: {
190
+ resourceId: string;
191
+ name: string;
192
+ description: string;
193
+ version: string;
194
+ type: 'workflow';
195
+ status: 'dev' | 'prod';
196
+ /** Whether this resource is archived and should be excluded from registration and deployment */
197
+ archived?: boolean;
198
+ };
199
+ entryPoint: string;
200
+ steps: Array<{
201
+ id: string;
202
+ name: string;
203
+ description: string;
204
+ inputSchema?: object;
205
+ outputSchema?: object;
206
+ next: {
207
+ type: 'linear' | 'conditional';
208
+ target?: string;
209
+ routes?: Array<{
210
+ target: string;
211
+ }>;
212
+ default?: string;
213
+ } | null;
214
+ }>;
215
+ contract: {
216
+ inputSchema: object;
217
+ outputSchema?: object;
218
+ };
219
+ metricsConfig?: object;
220
+ interface?: SerializedExecutionInterface;
221
+ }
222
+
223
+ /**
224
+ * Memory type definitions
225
+ * Types for agent memory management with semantic entry types
226
+ */
227
+ /**
228
+ * Semantic memory entry types
229
+ * Use-case agnostic types that describe the purpose of each entry
230
+ * Memory types mirror action types for clarity and filtering
231
+ */
232
+ type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'delegation-result' | 'error';
233
+ /**
234
+ * Memory entry - represents a single entry in agent memory
235
+ * Stored in agent memory, translated by adapters to vendor-specific formats
236
+ */
237
+ interface MemoryEntry {
238
+ type: MemoryEntryType;
239
+ content: string;
240
+ timestamp: number;
241
+ turnNumber: number | null;
242
+ iterationNumber: number | null;
243
+ }
244
+ /**
245
+ * Agent memory - Self-orchestrated memory with session + working storage
246
+ * Agent has full control over what persists, framework handles auto-compaction
247
+ */
248
+ interface AgentMemory {
249
+ /**
250
+ * Session memory - Persists for session/conversation duration
251
+ * Never auto-trimmed by framework
252
+ * Agent-managed key-value store for critical information
253
+ * Agent provides strings, framework wraps in MemoryEntry
254
+ */
255
+ sessionMemory: Record<string, MemoryEntry>;
256
+ /**
257
+ * Working memory - Execution history
258
+ * Automatically compacted by framework when needed
259
+ * Agent doesn't control compaction
260
+ */
261
+ history: MemoryEntry[];
262
+ }
263
+
264
+ type Json = string | number | boolean | null | {
265
+ [key: string]: Json | undefined;
266
+ } | Json[];
267
+ type Database = {
268
+ __InternalSupabase: {
269
+ PostgrestVersion: "12.2.3 (519615d)";
270
+ };
271
+ public: {
272
+ Tables: {
273
+ acq_companies: {
274
+ Row: {
275
+ attio_company_id: string | null;
276
+ batch_id: string | null;
277
+ category: string | null;
278
+ category_pain: string | null;
279
+ created_at: string;
280
+ domain: string | null;
281
+ enrichment_data: Json | null;
282
+ filter_reason: string | null;
283
+ founded_year: number | null;
284
+ id: string;
285
+ linkedin_url: string | null;
286
+ location_city: string | null;
287
+ location_state: string | null;
288
+ name: string;
289
+ num_employees: number | null;
290
+ organization_id: string;
291
+ pipeline_status: Json;
292
+ segment: string | null;
293
+ source: string | null;
294
+ status: string;
295
+ updated_at: string;
296
+ website: string | null;
297
+ };
298
+ Insert: {
299
+ attio_company_id?: string | null;
300
+ batch_id?: string | null;
301
+ category?: string | null;
302
+ category_pain?: string | null;
303
+ created_at?: string;
304
+ domain?: string | null;
305
+ enrichment_data?: Json | null;
306
+ filter_reason?: string | null;
307
+ founded_year?: number | null;
308
+ id?: string;
309
+ linkedin_url?: string | null;
310
+ location_city?: string | null;
311
+ location_state?: string | null;
312
+ name: string;
313
+ num_employees?: number | null;
314
+ organization_id: string;
315
+ pipeline_status?: Json;
316
+ segment?: string | null;
317
+ source?: string | null;
318
+ status?: string;
319
+ updated_at?: string;
320
+ website?: string | null;
321
+ };
322
+ Update: {
323
+ attio_company_id?: string | null;
324
+ batch_id?: string | null;
325
+ category?: string | null;
326
+ category_pain?: string | null;
327
+ created_at?: string;
328
+ domain?: string | null;
329
+ enrichment_data?: Json | null;
330
+ filter_reason?: string | null;
331
+ founded_year?: number | null;
332
+ id?: string;
333
+ linkedin_url?: string | null;
334
+ location_city?: string | null;
335
+ location_state?: string | null;
336
+ name?: string;
337
+ num_employees?: number | null;
338
+ organization_id?: string;
339
+ pipeline_status?: Json;
340
+ segment?: string | null;
341
+ source?: string | null;
342
+ status?: string;
343
+ updated_at?: string;
344
+ website?: string | null;
345
+ };
346
+ Relationships: [
347
+ {
348
+ foreignKeyName: "acq_companies_organization_id_fkey";
349
+ columns: ["organization_id"];
350
+ isOneToOne: false;
351
+ referencedRelation: "organizations";
352
+ referencedColumns: ["id"];
353
+ }
354
+ ];
355
+ };
356
+ acq_contacts: {
357
+ Row: {
358
+ attio_person_id: string | null;
359
+ batch_id: string | null;
360
+ brochure_first_viewed_at: string | null;
361
+ brochure_view_count: number;
362
+ company_id: string | null;
363
+ created_at: string;
364
+ email: string;
365
+ email_valid: string | null;
366
+ enrichment_data: Json;
367
+ filter_reason: string | null;
368
+ first_name: string | null;
369
+ headline: string | null;
370
+ id: string;
371
+ last_name: string | null;
372
+ linkedin_url: string | null;
373
+ nurture: boolean;
374
+ opening_line: string | null;
375
+ organization_id: string;
376
+ pipeline_status: Json;
377
+ source: string | null;
378
+ source_id: string | null;
379
+ status: string;
380
+ title: string | null;
381
+ updated_at: string;
382
+ };
383
+ Insert: {
384
+ attio_person_id?: string | null;
385
+ batch_id?: string | null;
386
+ brochure_first_viewed_at?: string | null;
387
+ brochure_view_count?: number;
388
+ company_id?: string | null;
389
+ created_at?: string;
390
+ email: string;
391
+ email_valid?: string | null;
392
+ enrichment_data?: Json;
393
+ filter_reason?: string | null;
394
+ first_name?: string | null;
395
+ headline?: string | null;
396
+ id?: string;
397
+ last_name?: string | null;
398
+ linkedin_url?: string | null;
399
+ nurture?: boolean;
400
+ opening_line?: string | null;
401
+ organization_id: string;
402
+ pipeline_status?: Json;
403
+ source?: string | null;
404
+ source_id?: string | null;
405
+ status?: string;
406
+ title?: string | null;
407
+ updated_at?: string;
408
+ };
409
+ Update: {
410
+ attio_person_id?: string | null;
411
+ batch_id?: string | null;
412
+ brochure_first_viewed_at?: string | null;
413
+ brochure_view_count?: number;
414
+ company_id?: string | null;
415
+ created_at?: string;
416
+ email?: string;
417
+ email_valid?: string | null;
418
+ enrichment_data?: Json;
419
+ filter_reason?: string | null;
420
+ first_name?: string | null;
421
+ headline?: string | null;
422
+ id?: string;
423
+ last_name?: string | null;
424
+ linkedin_url?: string | null;
425
+ nurture?: boolean;
426
+ opening_line?: string | null;
427
+ organization_id?: string;
428
+ pipeline_status?: Json;
429
+ source?: string | null;
430
+ source_id?: string | null;
431
+ status?: string;
432
+ title?: string | null;
433
+ updated_at?: string;
434
+ };
435
+ Relationships: [
436
+ {
437
+ foreignKeyName: "acq_contacts_company_id_fkey";
438
+ columns: ["company_id"];
439
+ isOneToOne: false;
440
+ referencedRelation: "acq_companies";
441
+ referencedColumns: ["id"];
442
+ },
443
+ {
444
+ foreignKeyName: "acq_contacts_organization_id_fkey";
445
+ columns: ["organization_id"];
446
+ isOneToOne: false;
447
+ referencedRelation: "organizations";
448
+ referencedColumns: ["id"];
449
+ }
450
+ ];
451
+ };
452
+ acq_content: {
453
+ Row: {
454
+ body: string | null;
455
+ created_at: string;
456
+ id: string;
457
+ organization_id: string;
458
+ pillar: string;
459
+ status: string;
460
+ title: string;
461
+ updated_at: string;
462
+ };
463
+ Insert: {
464
+ body?: string | null;
465
+ created_at?: string;
466
+ id?: string;
467
+ organization_id: string;
468
+ pillar: string;
469
+ status?: string;
470
+ title: string;
471
+ updated_at?: string;
472
+ };
473
+ Update: {
474
+ body?: string | null;
475
+ created_at?: string;
476
+ id?: string;
477
+ organization_id?: string;
478
+ pillar?: string;
479
+ status?: string;
480
+ title?: string;
481
+ updated_at?: string;
482
+ };
483
+ Relationships: [
484
+ {
485
+ foreignKeyName: "acq_content_organization_id_fkey";
486
+ columns: ["organization_id"];
487
+ isOneToOne: false;
488
+ referencedRelation: "organizations";
489
+ referencedColumns: ["id"];
490
+ }
491
+ ];
492
+ };
493
+ acq_content_distributions: {
494
+ Row: {
495
+ adapted_body: string | null;
496
+ checklist: Json | null;
497
+ content_id: string;
498
+ created_at: string;
499
+ format: string;
500
+ id: string;
501
+ media_urls: Json;
502
+ metrics: Json;
503
+ metrics_updated_at: string | null;
504
+ organization_id: string;
505
+ platform: string;
506
+ platform_content: Json | null;
507
+ platform_post_id: string | null;
508
+ platform_url: string | null;
509
+ published_at: string | null;
510
+ status: string;
511
+ updated_at: string;
512
+ };
513
+ Insert: {
514
+ adapted_body?: string | null;
515
+ checklist?: Json | null;
516
+ content_id: string;
517
+ created_at?: string;
518
+ format: string;
519
+ id?: string;
520
+ media_urls?: Json;
521
+ metrics?: Json;
522
+ metrics_updated_at?: string | null;
523
+ organization_id: string;
524
+ platform: string;
525
+ platform_content?: Json | null;
526
+ platform_post_id?: string | null;
527
+ platform_url?: string | null;
528
+ published_at?: string | null;
529
+ status?: string;
530
+ updated_at?: string;
531
+ };
532
+ Update: {
533
+ adapted_body?: string | null;
534
+ checklist?: Json | null;
535
+ content_id?: string;
536
+ created_at?: string;
537
+ format?: string;
538
+ id?: string;
539
+ media_urls?: Json;
540
+ metrics?: Json;
541
+ metrics_updated_at?: string | null;
542
+ organization_id?: string;
543
+ platform?: string;
544
+ platform_content?: Json | null;
545
+ platform_post_id?: string | null;
546
+ platform_url?: string | null;
547
+ published_at?: string | null;
548
+ status?: string;
549
+ updated_at?: string;
550
+ };
551
+ Relationships: [
552
+ {
553
+ foreignKeyName: "acq_content_distributions_content_id_fkey";
554
+ columns: ["content_id"];
555
+ isOneToOne: false;
556
+ referencedRelation: "acq_content";
557
+ referencedColumns: ["id"];
558
+ },
559
+ {
560
+ foreignKeyName: "acq_content_distributions_organization_id_fkey";
561
+ columns: ["organization_id"];
562
+ isOneToOne: false;
563
+ referencedRelation: "organizations";
564
+ referencedColumns: ["id"];
565
+ }
566
+ ];
567
+ };
568
+ acq_deals: {
569
+ Row: {
570
+ activity_log: Json;
571
+ attio_deal_id: string;
572
+ cached_stage: string | null;
573
+ closed_lost_at: string | null;
574
+ closed_lost_reason: string | null;
575
+ contact_email: string;
576
+ contact_id: string | null;
577
+ created_at: string;
578
+ discovery_data: Json | null;
579
+ discovery_submitted_at: string | null;
580
+ discovery_submitted_by: string | null;
581
+ id: string;
582
+ initial_fee: number | null;
583
+ monthly_fee: number | null;
584
+ organization_id: string;
585
+ payment_link_sent_at: string | null;
586
+ payment_received_at: string | null;
587
+ proposal_data: Json | null;
588
+ proposal_generated_at: string | null;
589
+ proposal_pdf_url: string | null;
590
+ proposal_reviewed_at: string | null;
591
+ proposal_reviewed_by: string | null;
592
+ proposal_sent_at: string | null;
593
+ proposal_signed_at: string | null;
594
+ proposal_status: string | null;
595
+ signature_envelope_id: string | null;
596
+ source_list_id: string | null;
597
+ source_type: string | null;
598
+ stripe_payment_id: string | null;
599
+ stripe_payment_link: string | null;
600
+ stripe_payment_link_id: string | null;
601
+ stripe_subscription_id: string | null;
602
+ updated_at: string;
603
+ };
604
+ Insert: {
605
+ activity_log?: Json;
606
+ attio_deal_id: string;
607
+ cached_stage?: string | null;
608
+ closed_lost_at?: string | null;
609
+ closed_lost_reason?: string | null;
610
+ contact_email: string;
611
+ contact_id?: string | null;
612
+ created_at?: string;
613
+ discovery_data?: Json | null;
614
+ discovery_submitted_at?: string | null;
615
+ discovery_submitted_by?: string | null;
616
+ id?: string;
617
+ initial_fee?: number | null;
618
+ monthly_fee?: number | null;
619
+ organization_id: string;
620
+ payment_link_sent_at?: string | null;
621
+ payment_received_at?: string | null;
622
+ proposal_data?: Json | null;
623
+ proposal_generated_at?: string | null;
624
+ proposal_pdf_url?: string | null;
625
+ proposal_reviewed_at?: string | null;
626
+ proposal_reviewed_by?: string | null;
627
+ proposal_sent_at?: string | null;
628
+ proposal_signed_at?: string | null;
629
+ proposal_status?: string | null;
630
+ signature_envelope_id?: string | null;
631
+ source_list_id?: string | null;
632
+ source_type?: string | null;
633
+ stripe_payment_id?: string | null;
634
+ stripe_payment_link?: string | null;
635
+ stripe_payment_link_id?: string | null;
636
+ stripe_subscription_id?: string | null;
637
+ updated_at?: string;
638
+ };
639
+ Update: {
640
+ activity_log?: Json;
641
+ attio_deal_id?: string;
642
+ cached_stage?: string | null;
643
+ closed_lost_at?: string | null;
644
+ closed_lost_reason?: string | null;
645
+ contact_email?: string;
646
+ contact_id?: string | null;
647
+ created_at?: string;
648
+ discovery_data?: Json | null;
649
+ discovery_submitted_at?: string | null;
650
+ discovery_submitted_by?: string | null;
651
+ id?: string;
652
+ initial_fee?: number | null;
653
+ monthly_fee?: number | null;
654
+ organization_id?: string;
655
+ payment_link_sent_at?: string | null;
656
+ payment_received_at?: string | null;
657
+ proposal_data?: Json | null;
658
+ proposal_generated_at?: string | null;
659
+ proposal_pdf_url?: string | null;
660
+ proposal_reviewed_at?: string | null;
661
+ proposal_reviewed_by?: string | null;
662
+ proposal_sent_at?: string | null;
663
+ proposal_signed_at?: string | null;
664
+ proposal_status?: string | null;
665
+ signature_envelope_id?: string | null;
666
+ source_list_id?: string | null;
667
+ source_type?: string | null;
668
+ stripe_payment_id?: string | null;
669
+ stripe_payment_link?: string | null;
670
+ stripe_payment_link_id?: string | null;
671
+ stripe_subscription_id?: string | null;
672
+ updated_at?: string;
673
+ };
674
+ Relationships: [
675
+ {
676
+ foreignKeyName: "acq_deals_contact_id_fkey";
677
+ columns: ["contact_id"];
678
+ isOneToOne: false;
679
+ referencedRelation: "acq_contacts";
680
+ referencedColumns: ["id"];
681
+ },
682
+ {
683
+ foreignKeyName: "acq_deals_organization_id_fkey";
684
+ columns: ["organization_id"];
685
+ isOneToOne: false;
686
+ referencedRelation: "organizations";
687
+ referencedColumns: ["id"];
688
+ },
689
+ {
690
+ foreignKeyName: "acq_deals_source_list_id_fkey";
691
+ columns: ["source_list_id"];
692
+ isOneToOne: false;
693
+ referencedRelation: "acq_lists";
694
+ referencedColumns: ["id"];
695
+ }
696
+ ];
697
+ };
698
+ acq_list_members: {
699
+ Row: {
700
+ added_at: string;
701
+ added_by: string | null;
702
+ contact_id: string;
703
+ id: string;
704
+ list_id: string;
705
+ };
706
+ Insert: {
707
+ added_at?: string;
708
+ added_by?: string | null;
709
+ contact_id: string;
710
+ id?: string;
711
+ list_id: string;
712
+ };
713
+ Update: {
714
+ added_at?: string;
715
+ added_by?: string | null;
716
+ contact_id?: string;
717
+ id?: string;
718
+ list_id?: string;
719
+ };
720
+ Relationships: [
721
+ {
722
+ foreignKeyName: "acq_list_members_contact_id_fkey";
723
+ columns: ["contact_id"];
724
+ isOneToOne: false;
725
+ referencedRelation: "acq_contacts";
726
+ referencedColumns: ["id"];
727
+ },
728
+ {
729
+ foreignKeyName: "acq_list_members_list_id_fkey";
730
+ columns: ["list_id"];
731
+ isOneToOne: false;
732
+ referencedRelation: "acq_lists";
733
+ referencedColumns: ["id"];
734
+ }
735
+ ];
736
+ };
737
+ acq_lists: {
738
+ Row: {
739
+ batch_ids: string[];
740
+ completed_at: string | null;
741
+ created_at: string;
742
+ description: string | null;
743
+ id: string;
744
+ instantly_campaign_id: string | null;
745
+ launched_at: string | null;
746
+ metadata: Json;
747
+ name: string;
748
+ organization_id: string;
749
+ status: string;
750
+ type: string;
751
+ };
752
+ Insert: {
753
+ batch_ids?: string[];
754
+ completed_at?: string | null;
755
+ created_at?: string;
756
+ description?: string | null;
757
+ id?: string;
758
+ instantly_campaign_id?: string | null;
759
+ launched_at?: string | null;
760
+ metadata?: Json;
761
+ name: string;
762
+ organization_id: string;
763
+ status?: string;
764
+ type?: string;
765
+ };
766
+ Update: {
767
+ batch_ids?: string[];
768
+ completed_at?: string | null;
769
+ created_at?: string;
770
+ description?: string | null;
771
+ id?: string;
772
+ instantly_campaign_id?: string | null;
773
+ launched_at?: string | null;
774
+ metadata?: Json;
775
+ name?: string;
776
+ organization_id?: string;
777
+ status?: string;
778
+ type?: string;
779
+ };
780
+ Relationships: [
781
+ {
782
+ foreignKeyName: "acq_lists_organization_id_fkey";
783
+ columns: ["organization_id"];
784
+ isOneToOne: false;
785
+ referencedRelation: "organizations";
786
+ referencedColumns: ["id"];
787
+ }
788
+ ];
789
+ };
790
+ acq_seo_metrics: {
791
+ Row: {
792
+ ai_citations: Json | null;
793
+ avg_position: number | null;
794
+ clicks: number | null;
795
+ created_at: string;
796
+ cta_clicks: number | null;
797
+ ctr: number | null;
798
+ data_point_count: number | null;
799
+ faq_count: number | null;
800
+ form_submissions: number | null;
801
+ id: string;
802
+ impressions: number | null;
803
+ organization_id: string;
804
+ period: string;
805
+ quality_score: number | null;
806
+ readability: number | null;
807
+ scroll_100: number | null;
808
+ scroll_25: number | null;
809
+ scroll_50: number | null;
810
+ scroll_75: number | null;
811
+ seo_page_id: string;
812
+ word_count: number | null;
813
+ };
814
+ Insert: {
815
+ ai_citations?: Json | null;
816
+ avg_position?: number | null;
817
+ clicks?: number | null;
818
+ created_at?: string;
819
+ cta_clicks?: number | null;
820
+ ctr?: number | null;
821
+ data_point_count?: number | null;
822
+ faq_count?: number | null;
823
+ form_submissions?: number | null;
824
+ id?: string;
825
+ impressions?: number | null;
826
+ organization_id: string;
827
+ period: string;
828
+ quality_score?: number | null;
829
+ readability?: number | null;
830
+ scroll_100?: number | null;
831
+ scroll_25?: number | null;
832
+ scroll_50?: number | null;
833
+ scroll_75?: number | null;
834
+ seo_page_id: string;
835
+ word_count?: number | null;
836
+ };
837
+ Update: {
838
+ ai_citations?: Json | null;
839
+ avg_position?: number | null;
840
+ clicks?: number | null;
841
+ created_at?: string;
842
+ cta_clicks?: number | null;
843
+ ctr?: number | null;
844
+ data_point_count?: number | null;
845
+ faq_count?: number | null;
846
+ form_submissions?: number | null;
847
+ id?: string;
848
+ impressions?: number | null;
849
+ organization_id?: string;
850
+ period?: string;
851
+ quality_score?: number | null;
852
+ readability?: number | null;
853
+ scroll_100?: number | null;
854
+ scroll_25?: number | null;
855
+ scroll_50?: number | null;
856
+ scroll_75?: number | null;
857
+ seo_page_id?: string;
858
+ word_count?: number | null;
859
+ };
860
+ Relationships: [
861
+ {
862
+ foreignKeyName: "acq_seo_metrics_organization_id_fkey";
863
+ columns: ["organization_id"];
864
+ isOneToOne: false;
865
+ referencedRelation: "organizations";
866
+ referencedColumns: ["id"];
867
+ },
868
+ {
869
+ foreignKeyName: "acq_seo_metrics_seo_page_id_fkey";
870
+ columns: ["seo_page_id"];
871
+ isOneToOne: false;
872
+ referencedRelation: "acq_seo_pages";
873
+ referencedColumns: ["id"];
874
+ }
875
+ ];
876
+ };
877
+ acq_seo_pages: {
878
+ Row: {
879
+ city: string | null;
880
+ content: Json | null;
881
+ created_at: string;
882
+ faq_items: Json | null;
883
+ hero_image_url: string | null;
884
+ id: string;
885
+ internal_links: Json | null;
886
+ local_data: Json | null;
887
+ meta_description: string | null;
888
+ organization_id: string;
889
+ page_type: string;
890
+ published_at: string | null;
891
+ refreshed_at: string | null;
892
+ schema_markup: Json | null;
893
+ slug: string;
894
+ state: string | null;
895
+ status: string;
896
+ title: string;
897
+ updated_at: string;
898
+ use_case: string | null;
899
+ vertical: string;
900
+ };
901
+ Insert: {
902
+ city?: string | null;
903
+ content?: Json | null;
904
+ created_at?: string;
905
+ faq_items?: Json | null;
906
+ hero_image_url?: string | null;
907
+ id?: string;
908
+ internal_links?: Json | null;
909
+ local_data?: Json | null;
910
+ meta_description?: string | null;
911
+ organization_id: string;
912
+ page_type: string;
913
+ published_at?: string | null;
914
+ refreshed_at?: string | null;
915
+ schema_markup?: Json | null;
916
+ slug: string;
917
+ state?: string | null;
918
+ status?: string;
919
+ title: string;
920
+ updated_at?: string;
921
+ use_case?: string | null;
922
+ vertical: string;
923
+ };
924
+ Update: {
925
+ city?: string | null;
926
+ content?: Json | null;
927
+ created_at?: string;
928
+ faq_items?: Json | null;
929
+ hero_image_url?: string | null;
930
+ id?: string;
931
+ internal_links?: Json | null;
932
+ local_data?: Json | null;
933
+ meta_description?: string | null;
934
+ organization_id?: string;
935
+ page_type?: string;
936
+ published_at?: string | null;
937
+ refreshed_at?: string | null;
938
+ schema_markup?: Json | null;
939
+ slug?: string;
940
+ state?: string | null;
941
+ status?: string;
942
+ title?: string;
943
+ updated_at?: string;
944
+ use_case?: string | null;
945
+ vertical?: string;
946
+ };
947
+ Relationships: [
948
+ {
949
+ foreignKeyName: "acq_seo_pages_organization_id_fkey";
950
+ columns: ["organization_id"];
951
+ isOneToOne: false;
952
+ referencedRelation: "organizations";
953
+ referencedColumns: ["id"];
954
+ }
955
+ ];
956
+ };
957
+ acq_social_posts: {
958
+ Row: {
959
+ author_name: string;
960
+ author_url: string | null;
961
+ comments_count: number;
962
+ created_at: string;
963
+ discovered_at: string;
964
+ engagement_count: number;
965
+ feedback: string | null;
966
+ final_response: string | null;
967
+ fully_reviewed: boolean;
968
+ id: string;
969
+ initial_draft: string | null;
970
+ matched_keywords: string[];
971
+ matched_query: string | null;
972
+ metadata: Json;
973
+ organization_id: string;
974
+ platform: string;
975
+ platform_post_id: string;
976
+ post_text: string;
977
+ post_title: string;
978
+ post_url: string;
979
+ posted_at: string;
980
+ relevance_score: number;
981
+ responded_at: string | null;
982
+ reviewed_at: string | null;
983
+ skip_reason: string | null;
984
+ source_category: string | null;
985
+ status: string;
986
+ updated_at: string;
987
+ };
988
+ Insert: {
989
+ author_name: string;
990
+ author_url?: string | null;
991
+ comments_count?: number;
992
+ created_at?: string;
993
+ discovered_at?: string;
994
+ engagement_count?: number;
995
+ feedback?: string | null;
996
+ final_response?: string | null;
997
+ fully_reviewed?: boolean;
998
+ id?: string;
999
+ initial_draft?: string | null;
1000
+ matched_keywords?: string[];
1001
+ matched_query?: string | null;
1002
+ metadata?: Json;
1003
+ organization_id: string;
1004
+ platform: string;
1005
+ platform_post_id: string;
1006
+ post_text: string;
1007
+ post_title: string;
1008
+ post_url: string;
1009
+ posted_at: string;
1010
+ relevance_score?: number;
1011
+ responded_at?: string | null;
1012
+ reviewed_at?: string | null;
1013
+ skip_reason?: string | null;
1014
+ source_category?: string | null;
1015
+ status?: string;
1016
+ updated_at?: string;
1017
+ };
1018
+ Update: {
1019
+ author_name?: string;
1020
+ author_url?: string | null;
1021
+ comments_count?: number;
1022
+ created_at?: string;
1023
+ discovered_at?: string;
1024
+ engagement_count?: number;
1025
+ feedback?: string | null;
1026
+ final_response?: string | null;
1027
+ fully_reviewed?: boolean;
1028
+ id?: string;
1029
+ initial_draft?: string | null;
1030
+ matched_keywords?: string[];
1031
+ matched_query?: string | null;
1032
+ metadata?: Json;
1033
+ organization_id?: string;
1034
+ platform?: string;
1035
+ platform_post_id?: string;
1036
+ post_text?: string;
1037
+ post_title?: string;
1038
+ post_url?: string;
1039
+ posted_at?: string;
1040
+ relevance_score?: number;
1041
+ responded_at?: string | null;
1042
+ reviewed_at?: string | null;
1043
+ skip_reason?: string | null;
1044
+ source_category?: string | null;
1045
+ status?: string;
1046
+ updated_at?: string;
1047
+ };
1048
+ Relationships: [
1049
+ {
1050
+ foreignKeyName: "acq_social_posts_organization_id_fkey";
1051
+ columns: ["organization_id"];
1052
+ isOneToOne: false;
1053
+ referencedRelation: "organizations";
1054
+ referencedColumns: ["id"];
1055
+ }
1056
+ ];
1057
+ };
1058
+ activities: {
1059
+ Row: {
1060
+ activity_type: string;
1061
+ actor_id: string | null;
1062
+ actor_type: string | null;
1063
+ created_at: string;
1064
+ description: string | null;
1065
+ entity_id: string;
1066
+ entity_name: string | null;
1067
+ entity_type: string;
1068
+ id: string;
1069
+ metadata: Json | null;
1070
+ occurred_at: string;
1071
+ organization_id: string;
1072
+ status: string;
1073
+ title: string;
1074
+ };
1075
+ Insert: {
1076
+ activity_type: string;
1077
+ actor_id?: string | null;
1078
+ actor_type?: string | null;
1079
+ created_at?: string;
1080
+ description?: string | null;
1081
+ entity_id: string;
1082
+ entity_name?: string | null;
1083
+ entity_type: string;
1084
+ id?: string;
1085
+ metadata?: Json | null;
1086
+ occurred_at?: string;
1087
+ organization_id: string;
1088
+ status: string;
1089
+ title: string;
1090
+ };
1091
+ Update: {
1092
+ activity_type?: string;
1093
+ actor_id?: string | null;
1094
+ actor_type?: string | null;
1095
+ created_at?: string;
1096
+ description?: string | null;
1097
+ entity_id?: string;
1098
+ entity_name?: string | null;
1099
+ entity_type?: string;
1100
+ id?: string;
1101
+ metadata?: Json | null;
1102
+ occurred_at?: string;
1103
+ organization_id?: string;
1104
+ status?: string;
1105
+ title?: string;
1106
+ };
1107
+ Relationships: [
1108
+ {
1109
+ foreignKeyName: "activities_organization_id_fkey";
1110
+ columns: ["organization_id"];
1111
+ isOneToOne: false;
1112
+ referencedRelation: "organizations";
1113
+ referencedColumns: ["id"];
1114
+ }
1115
+ ];
1116
+ };
1117
+ api_keys: {
1118
+ Row: {
1119
+ created_at: string | null;
1120
+ id: string;
1121
+ key_hash: string;
1122
+ last_used_at: string | null;
1123
+ name: string;
1124
+ organization_id: string;
1125
+ };
1126
+ Insert: {
1127
+ created_at?: string | null;
1128
+ id?: string;
1129
+ key_hash: string;
1130
+ last_used_at?: string | null;
1131
+ name: string;
1132
+ organization_id: string;
1133
+ };
1134
+ Update: {
1135
+ created_at?: string | null;
1136
+ id?: string;
1137
+ key_hash?: string;
1138
+ last_used_at?: string | null;
1139
+ name?: string;
1140
+ organization_id?: string;
1141
+ };
1142
+ Relationships: [
1143
+ {
1144
+ foreignKeyName: "api_keys_organization_id_fkey";
1145
+ columns: ["organization_id"];
1146
+ isOneToOne: false;
1147
+ referencedRelation: "organizations";
1148
+ referencedColumns: ["id"];
1149
+ }
1150
+ ];
1151
+ };
1152
+ calibration_projects: {
1153
+ Row: {
1154
+ created_at: string | null;
1155
+ description: string | null;
1156
+ id: string;
1157
+ name: string;
1158
+ organization_id: string;
1159
+ resource_id: string;
1160
+ resource_type: string;
1161
+ updated_at: string | null;
1162
+ };
1163
+ Insert: {
1164
+ created_at?: string | null;
1165
+ description?: string | null;
1166
+ id?: string;
1167
+ name: string;
1168
+ organization_id: string;
1169
+ resource_id: string;
1170
+ resource_type: string;
1171
+ updated_at?: string | null;
1172
+ };
1173
+ Update: {
1174
+ created_at?: string | null;
1175
+ description?: string | null;
1176
+ id?: string;
1177
+ name?: string;
1178
+ organization_id?: string;
1179
+ resource_id?: string;
1180
+ resource_type?: string;
1181
+ updated_at?: string | null;
1182
+ };
1183
+ Relationships: [
1184
+ {
1185
+ foreignKeyName: "calibration_projects_organization_id_fkey";
1186
+ columns: ["organization_id"];
1187
+ isOneToOne: false;
1188
+ referencedRelation: "organizations";
1189
+ referencedColumns: ["id"];
1190
+ }
1191
+ ];
1192
+ };
1193
+ calibration_runs: {
1194
+ Row: {
1195
+ completed_at: string | null;
1196
+ config_variants: Json;
1197
+ created_at: string | null;
1198
+ description: string | null;
1199
+ execution_mode: string;
1200
+ grader_model: string | null;
1201
+ grading_rubric: Json | null;
1202
+ id: string;
1203
+ name: string;
1204
+ organization_id: string;
1205
+ project_id: string;
1206
+ results: Json;
1207
+ status: string;
1208
+ test_inputs: Json;
1209
+ };
1210
+ Insert: {
1211
+ completed_at?: string | null;
1212
+ config_variants: Json;
1213
+ created_at?: string | null;
1214
+ description?: string | null;
1215
+ execution_mode?: string;
1216
+ grader_model?: string | null;
1217
+ grading_rubric?: Json | null;
1218
+ id?: string;
1219
+ name: string;
1220
+ organization_id: string;
1221
+ project_id: string;
1222
+ results?: Json;
1223
+ status?: string;
1224
+ test_inputs: Json;
1225
+ };
1226
+ Update: {
1227
+ completed_at?: string | null;
1228
+ config_variants?: Json;
1229
+ created_at?: string | null;
1230
+ description?: string | null;
1231
+ execution_mode?: string;
1232
+ grader_model?: string | null;
1233
+ grading_rubric?: Json | null;
1234
+ id?: string;
1235
+ name?: string;
1236
+ organization_id?: string;
1237
+ project_id?: string;
1238
+ results?: Json;
1239
+ status?: string;
1240
+ test_inputs?: Json;
1241
+ };
1242
+ Relationships: [
1243
+ {
1244
+ foreignKeyName: "calibration_runs_organization_id_fkey";
1245
+ columns: ["organization_id"];
1246
+ isOneToOne: false;
1247
+ referencedRelation: "organizations";
1248
+ referencedColumns: ["id"];
1249
+ },
1250
+ {
1251
+ foreignKeyName: "calibration_runs_project_id_fkey";
1252
+ columns: ["project_id"];
1253
+ isOneToOne: false;
1254
+ referencedRelation: "calibration_projects";
1255
+ referencedColumns: ["id"];
1256
+ }
1257
+ ];
1258
+ };
1259
+ command_queue: {
1260
+ Row: {
1261
+ action_payload: Json | null;
1262
+ actions: Json;
1263
+ completed_at: string | null;
1264
+ completed_by: string | null;
1265
+ context: Json;
1266
+ created_at: string;
1267
+ description: string | null;
1268
+ expires_at: string | null;
1269
+ human_checkpoint: string | null;
1270
+ id: string;
1271
+ idempotency_key: string | null;
1272
+ metadata: Json | null;
1273
+ organization_id: string;
1274
+ origin_execution_id: string;
1275
+ origin_resource_id: string;
1276
+ origin_resource_type: string;
1277
+ priority: number;
1278
+ selected_action: string | null;
1279
+ status: string;
1280
+ target_execution_id: string | null;
1281
+ target_resource_id: string | null;
1282
+ target_resource_type: string | null;
1283
+ };
1284
+ Insert: {
1285
+ action_payload?: Json | null;
1286
+ actions: Json;
1287
+ completed_at?: string | null;
1288
+ completed_by?: string | null;
1289
+ context: Json;
1290
+ created_at?: string;
1291
+ description?: string | null;
1292
+ expires_at?: string | null;
1293
+ human_checkpoint?: string | null;
1294
+ id?: string;
1295
+ idempotency_key?: string | null;
1296
+ metadata?: Json | null;
1297
+ organization_id: string;
1298
+ origin_execution_id: string;
1299
+ origin_resource_id: string;
1300
+ origin_resource_type: string;
1301
+ priority?: number;
1302
+ selected_action?: string | null;
1303
+ status?: string;
1304
+ target_execution_id?: string | null;
1305
+ target_resource_id?: string | null;
1306
+ target_resource_type?: string | null;
1307
+ };
1308
+ Update: {
1309
+ action_payload?: Json | null;
1310
+ actions?: Json;
1311
+ completed_at?: string | null;
1312
+ completed_by?: string | null;
1313
+ context?: Json;
1314
+ created_at?: string;
1315
+ description?: string | null;
1316
+ expires_at?: string | null;
1317
+ human_checkpoint?: string | null;
1318
+ id?: string;
1319
+ idempotency_key?: string | null;
1320
+ metadata?: Json | null;
1321
+ organization_id?: string;
1322
+ origin_execution_id?: string;
1323
+ origin_resource_id?: string;
1324
+ origin_resource_type?: string;
1325
+ priority?: number;
1326
+ selected_action?: string | null;
1327
+ status?: string;
1328
+ target_execution_id?: string | null;
1329
+ target_resource_id?: string | null;
1330
+ target_resource_type?: string | null;
1331
+ };
1332
+ Relationships: [
1333
+ {
1334
+ foreignKeyName: "command_queue_completed_by_fkey";
1335
+ columns: ["completed_by"];
1336
+ isOneToOne: false;
1337
+ referencedRelation: "users";
1338
+ referencedColumns: ["id"];
1339
+ },
1340
+ {
1341
+ foreignKeyName: "command_queue_organization_id_fkey";
1342
+ columns: ["organization_id"];
1343
+ isOneToOne: false;
1344
+ referencedRelation: "organizations";
1345
+ referencedColumns: ["id"];
1346
+ },
1347
+ {
1348
+ foreignKeyName: "command_queue_target_execution_id_fkey";
1349
+ columns: ["target_execution_id"];
1350
+ isOneToOne: false;
1351
+ referencedRelation: "execution_logs";
1352
+ referencedColumns: ["execution_id"];
1353
+ }
1354
+ ];
1355
+ };
1356
+ credentials: {
1357
+ Row: {
1358
+ created_at: string;
1359
+ created_by: string | null;
1360
+ encrypted_value: string;
1361
+ id: string;
1362
+ name: string;
1363
+ organization_id: string;
1364
+ provider: string | null;
1365
+ type: string;
1366
+ updated_at: string;
1367
+ };
1368
+ Insert: {
1369
+ created_at?: string;
1370
+ created_by?: string | null;
1371
+ encrypted_value: string;
1372
+ id?: string;
1373
+ name: string;
1374
+ organization_id: string;
1375
+ provider?: string | null;
1376
+ type?: string;
1377
+ updated_at?: string;
1378
+ };
1379
+ Update: {
1380
+ created_at?: string;
1381
+ created_by?: string | null;
1382
+ encrypted_value?: string;
1383
+ id?: string;
1384
+ name?: string;
1385
+ organization_id?: string;
1386
+ provider?: string | null;
1387
+ type?: string;
1388
+ updated_at?: string;
1389
+ };
1390
+ Relationships: [
1391
+ {
1392
+ foreignKeyName: "credentials_created_by_fkey";
1393
+ columns: ["created_by"];
1394
+ isOneToOne: false;
1395
+ referencedRelation: "users";
1396
+ referencedColumns: ["id"];
1397
+ },
1398
+ {
1399
+ foreignKeyName: "credentials_organization_id_fkey";
1400
+ columns: ["organization_id"];
1401
+ isOneToOne: false;
1402
+ referencedRelation: "organizations";
1403
+ referencedColumns: ["id"];
1404
+ }
1405
+ ];
1406
+ };
1407
+ deployments: {
1408
+ Row: {
1409
+ compiled_docs: Json | null;
1410
+ created_at: string;
1411
+ deployment_version: string | null;
1412
+ documentation: Json | null;
1413
+ error_message: string | null;
1414
+ id: string;
1415
+ organization_id: string;
1416
+ pid: number | null;
1417
+ port: number | null;
1418
+ sdk_version: string;
1419
+ status: string;
1420
+ tarball_path: string | null;
1421
+ updated_at: string;
1422
+ };
1423
+ Insert: {
1424
+ compiled_docs?: Json | null;
1425
+ created_at?: string;
1426
+ deployment_version?: string | null;
1427
+ documentation?: Json | null;
1428
+ error_message?: string | null;
1429
+ id?: string;
1430
+ organization_id: string;
1431
+ pid?: number | null;
1432
+ port?: number | null;
1433
+ sdk_version: string;
1434
+ status?: string;
1435
+ tarball_path?: string | null;
1436
+ updated_at?: string;
1437
+ };
1438
+ Update: {
1439
+ compiled_docs?: Json | null;
1440
+ created_at?: string;
1441
+ deployment_version?: string | null;
1442
+ documentation?: Json | null;
1443
+ error_message?: string | null;
1444
+ id?: string;
1445
+ organization_id?: string;
1446
+ pid?: number | null;
1447
+ port?: number | null;
1448
+ sdk_version?: string;
1449
+ status?: string;
1450
+ tarball_path?: string | null;
1451
+ updated_at?: string;
1452
+ };
1453
+ Relationships: [
1454
+ {
1455
+ foreignKeyName: "deployments_organization_id_fkey";
1456
+ columns: ["organization_id"];
1457
+ isOneToOne: false;
1458
+ referencedRelation: "organizations";
1459
+ referencedColumns: ["id"];
1460
+ }
1461
+ ];
1462
+ };
1463
+ execution_errors: {
1464
+ Row: {
1465
+ created_at: string | null;
1466
+ error_category: string;
1467
+ error_message: string;
1468
+ error_severity: string;
1469
+ error_stack_trace: string | null;
1470
+ error_type: string;
1471
+ execution_id: string;
1472
+ id: string;
1473
+ metadata: Json | null;
1474
+ occurred_at: string;
1475
+ organization_id: string;
1476
+ resolved: boolean;
1477
+ resolved_at: string | null;
1478
+ resolved_by: string | null;
1479
+ };
1480
+ Insert: {
1481
+ created_at?: string | null;
1482
+ error_category: string;
1483
+ error_message: string;
1484
+ error_severity: string;
1485
+ error_stack_trace?: string | null;
1486
+ error_type: string;
1487
+ execution_id: string;
1488
+ id?: string;
1489
+ metadata?: Json | null;
1490
+ occurred_at?: string;
1491
+ organization_id: string;
1492
+ resolved?: boolean;
1493
+ resolved_at?: string | null;
1494
+ resolved_by?: string | null;
1495
+ };
1496
+ Update: {
1497
+ created_at?: string | null;
1498
+ error_category?: string;
1499
+ error_message?: string;
1500
+ error_severity?: string;
1501
+ error_stack_trace?: string | null;
1502
+ error_type?: string;
1503
+ execution_id?: string;
1504
+ id?: string;
1505
+ metadata?: Json | null;
1506
+ occurred_at?: string;
1507
+ organization_id?: string;
1508
+ resolved?: boolean;
1509
+ resolved_at?: string | null;
1510
+ resolved_by?: string | null;
1511
+ };
1512
+ Relationships: [
1513
+ {
1514
+ foreignKeyName: "execution_errors_execution_id_fkey";
1515
+ columns: ["execution_id"];
1516
+ isOneToOne: false;
1517
+ referencedRelation: "execution_logs";
1518
+ referencedColumns: ["execution_id"];
1519
+ },
1520
+ {
1521
+ foreignKeyName: "execution_errors_organization_id_fkey";
1522
+ columns: ["organization_id"];
1523
+ isOneToOne: false;
1524
+ referencedRelation: "organizations";
1525
+ referencedColumns: ["id"];
1526
+ },
1527
+ {
1528
+ foreignKeyName: "execution_errors_resolved_by_fkey";
1529
+ columns: ["resolved_by"];
1530
+ isOneToOne: false;
1531
+ referencedRelation: "users";
1532
+ referencedColumns: ["id"];
1533
+ }
1534
+ ];
1535
+ };
1536
+ execution_logs: {
1537
+ Row: {
1538
+ api_version: string | null;
1539
+ completed_at: string | null;
1540
+ created_at: string | null;
1541
+ error: string | null;
1542
+ execution_id: string;
1543
+ input: Json | null;
1544
+ last_heartbeat_at: string | null;
1545
+ logs: Json | null;
1546
+ organization_id: string;
1547
+ origin_execution_id: string | null;
1548
+ output: Json | null;
1549
+ resource_id: string;
1550
+ resource_status: string;
1551
+ resource_type: string;
1552
+ resource_version: string | null;
1553
+ sdk_version: string | null;
1554
+ session_id: string | null;
1555
+ session_turn_number: number | null;
1556
+ started_at: string;
1557
+ status: string;
1558
+ trigger_type: string | null;
1559
+ updated_at: string | null;
1560
+ user_id: string | null;
1561
+ };
1562
+ Insert: {
1563
+ api_version?: string | null;
1564
+ completed_at?: string | null;
1565
+ created_at?: string | null;
1566
+ error?: string | null;
1567
+ execution_id?: string;
1568
+ input?: Json | null;
1569
+ last_heartbeat_at?: string | null;
1570
+ logs?: Json | null;
1571
+ organization_id: string;
1572
+ origin_execution_id?: string | null;
1573
+ output?: Json | null;
1574
+ resource_id: string;
1575
+ resource_status?: string;
1576
+ resource_type?: string;
1577
+ resource_version?: string | null;
1578
+ sdk_version?: string | null;
1579
+ session_id?: string | null;
1580
+ session_turn_number?: number | null;
1581
+ started_at?: string;
1582
+ status: string;
1583
+ trigger_type?: string | null;
1584
+ updated_at?: string | null;
1585
+ user_id?: string | null;
1586
+ };
1587
+ Update: {
1588
+ api_version?: string | null;
1589
+ completed_at?: string | null;
1590
+ created_at?: string | null;
1591
+ error?: string | null;
1592
+ execution_id?: string;
1593
+ input?: Json | null;
1594
+ last_heartbeat_at?: string | null;
1595
+ logs?: Json | null;
1596
+ organization_id?: string;
1597
+ origin_execution_id?: string | null;
1598
+ output?: Json | null;
1599
+ resource_id?: string;
1600
+ resource_status?: string;
1601
+ resource_type?: string;
1602
+ resource_version?: string | null;
1603
+ sdk_version?: string | null;
1604
+ session_id?: string | null;
1605
+ session_turn_number?: number | null;
1606
+ started_at?: string;
1607
+ status?: string;
1608
+ trigger_type?: string | null;
1609
+ updated_at?: string | null;
1610
+ user_id?: string | null;
1611
+ };
1612
+ Relationships: [
1613
+ {
1614
+ foreignKeyName: "execution_history_organization_id_fkey";
1615
+ columns: ["organization_id"];
1616
+ isOneToOne: false;
1617
+ referencedRelation: "organizations";
1618
+ referencedColumns: ["id"];
1619
+ },
1620
+ {
1621
+ foreignKeyName: "execution_logs_origin_execution_id_fkey";
1622
+ columns: ["origin_execution_id"];
1623
+ isOneToOne: false;
1624
+ referencedRelation: "execution_logs";
1625
+ referencedColumns: ["execution_id"];
1626
+ },
1627
+ {
1628
+ foreignKeyName: "execution_logs_session_id_fkey";
1629
+ columns: ["session_id"];
1630
+ isOneToOne: false;
1631
+ referencedRelation: "sessions";
1632
+ referencedColumns: ["session_id"];
1633
+ },
1634
+ {
1635
+ foreignKeyName: "execution_logs_user_id_fkey";
1636
+ columns: ["user_id"];
1637
+ isOneToOne: false;
1638
+ referencedRelation: "users";
1639
+ referencedColumns: ["id"];
1640
+ }
1641
+ ];
1642
+ };
1643
+ execution_metrics: {
1644
+ Row: {
1645
+ ai_call_count: number;
1646
+ ai_calls: Json | null;
1647
+ automation_savings_usd: number | null;
1648
+ created_at: string | null;
1649
+ duration_ms: number | null;
1650
+ execution_id: string;
1651
+ organization_id: string;
1652
+ resource_id: string;
1653
+ total_cost_usd: number;
1654
+ total_input_tokens: number;
1655
+ total_output_tokens: number;
1656
+ };
1657
+ Insert: {
1658
+ ai_call_count: number;
1659
+ ai_calls?: Json | null;
1660
+ automation_savings_usd?: number | null;
1661
+ created_at?: string | null;
1662
+ duration_ms?: number | null;
1663
+ execution_id: string;
1664
+ organization_id: string;
1665
+ resource_id: string;
1666
+ total_cost_usd: number;
1667
+ total_input_tokens: number;
1668
+ total_output_tokens: number;
1669
+ };
1670
+ Update: {
1671
+ ai_call_count?: number;
1672
+ ai_calls?: Json | null;
1673
+ automation_savings_usd?: number | null;
1674
+ created_at?: string | null;
1675
+ duration_ms?: number | null;
1676
+ execution_id?: string;
1677
+ organization_id?: string;
1678
+ resource_id?: string;
1679
+ total_cost_usd?: number;
1680
+ total_input_tokens?: number;
1681
+ total_output_tokens?: number;
1682
+ };
1683
+ Relationships: [
1684
+ {
1685
+ foreignKeyName: "execution_metrics_execution_id_fkey";
1686
+ columns: ["execution_id"];
1687
+ isOneToOne: true;
1688
+ referencedRelation: "execution_logs";
1689
+ referencedColumns: ["execution_id"];
1690
+ },
1691
+ {
1692
+ foreignKeyName: "execution_metrics_organization_id_fkey";
1693
+ columns: ["organization_id"];
1694
+ isOneToOne: false;
1695
+ referencedRelation: "organizations";
1696
+ referencedColumns: ["id"];
1697
+ }
1698
+ ];
1699
+ };
1700
+ notifications: {
1701
+ Row: {
1702
+ action_url: string | null;
1703
+ category: string;
1704
+ created_at: string | null;
1705
+ id: string;
1706
+ message: string;
1707
+ organization_id: string;
1708
+ read: boolean | null;
1709
+ read_at: string | null;
1710
+ title: string;
1711
+ user_id: string;
1712
+ };
1713
+ Insert: {
1714
+ action_url?: string | null;
1715
+ category: string;
1716
+ created_at?: string | null;
1717
+ id?: string;
1718
+ message: string;
1719
+ organization_id: string;
1720
+ read?: boolean | null;
1721
+ read_at?: string | null;
1722
+ title: string;
1723
+ user_id: string;
1724
+ };
1725
+ Update: {
1726
+ action_url?: string | null;
1727
+ category?: string;
1728
+ created_at?: string | null;
1729
+ id?: string;
1730
+ message?: string;
1731
+ organization_id?: string;
1732
+ read?: boolean | null;
1733
+ read_at?: string | null;
1734
+ title?: string;
1735
+ user_id?: string;
1736
+ };
1737
+ Relationships: [
1738
+ {
1739
+ foreignKeyName: "notifications_organization_id_fkey";
1740
+ columns: ["organization_id"];
1741
+ isOneToOne: false;
1742
+ referencedRelation: "organizations";
1743
+ referencedColumns: ["id"];
1744
+ },
1745
+ {
1746
+ foreignKeyName: "notifications_user_id_fkey";
1747
+ columns: ["user_id"];
1748
+ isOneToOne: false;
1749
+ referencedRelation: "users";
1750
+ referencedColumns: ["id"];
1751
+ }
1752
+ ];
1753
+ };
1754
+ org_invitations: {
1755
+ Row: {
1756
+ accept_invitation_url: string | null;
1757
+ accepted_at: string | null;
1758
+ created_at: string | null;
1759
+ email: string;
1760
+ expires_at: string;
1761
+ id: string;
1762
+ invitation_state: string | null;
1763
+ invitation_token: string | null;
1764
+ inviter_user_id: string | null;
1765
+ organization_id: string | null;
1766
+ revoked_at: string | null;
1767
+ role_slug: string | null;
1768
+ updated_at: string | null;
1769
+ workos_invitation_id: string;
1770
+ };
1771
+ Insert: {
1772
+ accept_invitation_url?: string | null;
1773
+ accepted_at?: string | null;
1774
+ created_at?: string | null;
1775
+ email: string;
1776
+ expires_at: string;
1777
+ id?: string;
1778
+ invitation_state?: string | null;
1779
+ invitation_token?: string | null;
1780
+ inviter_user_id?: string | null;
1781
+ organization_id?: string | null;
1782
+ revoked_at?: string | null;
1783
+ role_slug?: string | null;
1784
+ updated_at?: string | null;
1785
+ workos_invitation_id: string;
1786
+ };
1787
+ Update: {
1788
+ accept_invitation_url?: string | null;
1789
+ accepted_at?: string | null;
1790
+ created_at?: string | null;
1791
+ email?: string;
1792
+ expires_at?: string;
1793
+ id?: string;
1794
+ invitation_state?: string | null;
1795
+ invitation_token?: string | null;
1796
+ inviter_user_id?: string | null;
1797
+ organization_id?: string | null;
1798
+ revoked_at?: string | null;
1799
+ role_slug?: string | null;
1800
+ updated_at?: string | null;
1801
+ workos_invitation_id?: string;
1802
+ };
1803
+ Relationships: [
1804
+ {
1805
+ foreignKeyName: "org_invitations_inviter_user_id_fkey";
1806
+ columns: ["inviter_user_id"];
1807
+ isOneToOne: false;
1808
+ referencedRelation: "users";
1809
+ referencedColumns: ["id"];
1810
+ },
1811
+ {
1812
+ foreignKeyName: "org_invitations_organization_id_fkey";
1813
+ columns: ["organization_id"];
1814
+ isOneToOne: false;
1815
+ referencedRelation: "organizations";
1816
+ referencedColumns: ["id"];
1817
+ }
1818
+ ];
1819
+ };
1820
+ org_memberships: {
1821
+ Row: {
1822
+ config: Json;
1823
+ created_at: string | null;
1824
+ id: string;
1825
+ membership_status: string | null;
1826
+ organization_id: string;
1827
+ role_slug: string | null;
1828
+ updated_at: string | null;
1829
+ user_id: string;
1830
+ workos_membership_id: string | null;
1831
+ };
1832
+ Insert: {
1833
+ config?: Json;
1834
+ created_at?: string | null;
1835
+ id?: string;
1836
+ membership_status?: string | null;
1837
+ organization_id: string;
1838
+ role_slug?: string | null;
1839
+ updated_at?: string | null;
1840
+ user_id: string;
1841
+ workos_membership_id?: string | null;
1842
+ };
1843
+ Update: {
1844
+ config?: Json;
1845
+ created_at?: string | null;
1846
+ id?: string;
1847
+ membership_status?: string | null;
1848
+ organization_id?: string;
1849
+ role_slug?: string | null;
1850
+ updated_at?: string | null;
1851
+ user_id?: string;
1852
+ workos_membership_id?: string | null;
1853
+ };
1854
+ Relationships: [
1855
+ {
1856
+ foreignKeyName: "org_memberships_organization_id_fkey";
1857
+ columns: ["organization_id"];
1858
+ isOneToOne: false;
1859
+ referencedRelation: "organizations";
1860
+ referencedColumns: ["id"];
1861
+ },
1862
+ {
1863
+ foreignKeyName: "org_memberships_user_id_fkey";
1864
+ columns: ["user_id"];
1865
+ isOneToOne: false;
1866
+ referencedRelation: "users";
1867
+ referencedColumns: ["id"];
1868
+ }
1869
+ ];
1870
+ };
1871
+ organizations: {
1872
+ Row: {
1873
+ config: Json;
1874
+ created_at: string;
1875
+ id: string;
1876
+ is_test: boolean;
1877
+ metadata: Json;
1878
+ name: string;
1879
+ status: string;
1880
+ updated_at: string;
1881
+ workos_org_id: string;
1882
+ };
1883
+ Insert: {
1884
+ config?: Json;
1885
+ created_at?: string;
1886
+ id?: string;
1887
+ is_test?: boolean;
1888
+ metadata?: Json;
1889
+ name: string;
1890
+ status?: string;
1891
+ updated_at?: string;
1892
+ workos_org_id: string;
1893
+ };
1894
+ Update: {
1895
+ config?: Json;
1896
+ created_at?: string;
1897
+ id?: string;
1898
+ is_test?: boolean;
1899
+ metadata?: Json;
1900
+ name?: string;
1901
+ status?: string;
1902
+ updated_at?: string;
1903
+ workos_org_id?: string;
1904
+ };
1905
+ Relationships: [];
1906
+ };
1907
+ session_messages: {
1908
+ Row: {
1909
+ created_at: string | null;
1910
+ id: string;
1911
+ message: string;
1912
+ message_index: number | null;
1913
+ message_type: string | null;
1914
+ metadata: Json | null;
1915
+ role: string;
1916
+ session_id: string;
1917
+ session_turn_number: number;
1918
+ };
1919
+ Insert: {
1920
+ created_at?: string | null;
1921
+ id: string;
1922
+ message: string;
1923
+ message_index?: number | null;
1924
+ message_type?: string | null;
1925
+ metadata?: Json | null;
1926
+ role: string;
1927
+ session_id: string;
1928
+ session_turn_number: number;
1929
+ };
1930
+ Update: {
1931
+ created_at?: string | null;
1932
+ id?: string;
1933
+ message?: string;
1934
+ message_index?: number | null;
1935
+ message_type?: string | null;
1936
+ metadata?: Json | null;
1937
+ role?: string;
1938
+ session_id?: string;
1939
+ session_turn_number?: number;
1940
+ };
1941
+ Relationships: [
1942
+ {
1943
+ foreignKeyName: "session_messages_session_id_fkey";
1944
+ columns: ["session_id"];
1945
+ isOneToOne: false;
1946
+ referencedRelation: "sessions";
1947
+ referencedColumns: ["session_id"];
1948
+ }
1949
+ ];
1950
+ };
1951
+ sessions: {
1952
+ Row: {
1953
+ context_window_size: number;
1954
+ created_at: string | null;
1955
+ cumulative_input_tokens: number;
1956
+ cumulative_output_tokens: number;
1957
+ deleted_at: string | null;
1958
+ ended_at: string | null;
1959
+ memory_snapshot: Json;
1960
+ metadata: Json | null;
1961
+ organization_id: string;
1962
+ resource_id: string;
1963
+ session_id: string;
1964
+ session_total_turns: number | null;
1965
+ updated_at: string | null;
1966
+ user_id: string | null;
1967
+ };
1968
+ Insert: {
1969
+ context_window_size?: number;
1970
+ created_at?: string | null;
1971
+ cumulative_input_tokens?: number;
1972
+ cumulative_output_tokens?: number;
1973
+ deleted_at?: string | null;
1974
+ ended_at?: string | null;
1975
+ memory_snapshot: Json;
1976
+ metadata?: Json | null;
1977
+ organization_id: string;
1978
+ resource_id: string;
1979
+ session_id?: string;
1980
+ session_total_turns?: number | null;
1981
+ updated_at?: string | null;
1982
+ user_id?: string | null;
1983
+ };
1984
+ Update: {
1985
+ context_window_size?: number;
1986
+ created_at?: string | null;
1987
+ cumulative_input_tokens?: number;
1988
+ cumulative_output_tokens?: number;
1989
+ deleted_at?: string | null;
1990
+ ended_at?: string | null;
1991
+ memory_snapshot?: Json;
1992
+ metadata?: Json | null;
1993
+ organization_id?: string;
1994
+ resource_id?: string;
1995
+ session_id?: string;
1996
+ session_total_turns?: number | null;
1997
+ updated_at?: string | null;
1998
+ user_id?: string | null;
1999
+ };
2000
+ Relationships: [
2001
+ {
2002
+ foreignKeyName: "fk_organization";
2003
+ columns: ["organization_id"];
2004
+ isOneToOne: false;
2005
+ referencedRelation: "organizations";
2006
+ referencedColumns: ["id"];
2007
+ },
2008
+ {
2009
+ foreignKeyName: "fk_user";
2010
+ columns: ["user_id"];
2011
+ isOneToOne: false;
2012
+ referencedRelation: "users";
2013
+ referencedColumns: ["id"];
2014
+ }
2015
+ ];
2016
+ };
2017
+ task_schedules: {
2018
+ Row: {
2019
+ created_at: string;
2020
+ current_step: number;
2021
+ description: string | null;
2022
+ id: string;
2023
+ idempotency_key: string | null;
2024
+ last_execution_id: string | null;
2025
+ last_run_at: string | null;
2026
+ max_retries: number;
2027
+ metadata: Json | null;
2028
+ name: string;
2029
+ next_run_at: string | null;
2030
+ organization_id: string;
2031
+ origin_execution_id: string | null;
2032
+ origin_resource_id: string | null;
2033
+ origin_resource_type: string | null;
2034
+ retry_count: number;
2035
+ schedule_config: Json;
2036
+ status: string;
2037
+ target_resource_id: string;
2038
+ target_resource_type: string;
2039
+ updated_at: string;
2040
+ };
2041
+ Insert: {
2042
+ created_at?: string;
2043
+ current_step?: number;
2044
+ description?: string | null;
2045
+ id?: string;
2046
+ idempotency_key?: string | null;
2047
+ last_execution_id?: string | null;
2048
+ last_run_at?: string | null;
2049
+ max_retries?: number;
2050
+ metadata?: Json | null;
2051
+ name: string;
2052
+ next_run_at?: string | null;
2053
+ organization_id: string;
2054
+ origin_execution_id?: string | null;
2055
+ origin_resource_id?: string | null;
2056
+ origin_resource_type?: string | null;
2057
+ retry_count?: number;
2058
+ schedule_config: Json;
2059
+ status?: string;
2060
+ target_resource_id: string;
2061
+ target_resource_type: string;
2062
+ updated_at?: string;
2063
+ };
2064
+ Update: {
2065
+ created_at?: string;
2066
+ current_step?: number;
2067
+ description?: string | null;
2068
+ id?: string;
2069
+ idempotency_key?: string | null;
2070
+ last_execution_id?: string | null;
2071
+ last_run_at?: string | null;
2072
+ max_retries?: number;
2073
+ metadata?: Json | null;
2074
+ name?: string;
2075
+ next_run_at?: string | null;
2076
+ organization_id?: string;
2077
+ origin_execution_id?: string | null;
2078
+ origin_resource_id?: string | null;
2079
+ origin_resource_type?: string | null;
2080
+ retry_count?: number;
2081
+ schedule_config?: Json;
2082
+ status?: string;
2083
+ target_resource_id?: string;
2084
+ target_resource_type?: string;
2085
+ updated_at?: string;
2086
+ };
2087
+ Relationships: [
2088
+ {
2089
+ foreignKeyName: "task_schedules_organization_id_fkey";
2090
+ columns: ["organization_id"];
2091
+ isOneToOne: false;
2092
+ referencedRelation: "organizations";
2093
+ referencedColumns: ["id"];
2094
+ }
2095
+ ];
2096
+ };
2097
+ users: {
2098
+ Row: {
2099
+ config: Json;
2100
+ created_at: string;
2101
+ display_name: string | null;
2102
+ email: string;
2103
+ first_name: string | null;
2104
+ id: string;
2105
+ is_active: boolean;
2106
+ is_platform_admin: boolean | null;
2107
+ last_login_at: string | null;
2108
+ last_name: string | null;
2109
+ last_visited_org: string | null;
2110
+ profile_picture_url: string | null;
2111
+ updated_at: string;
2112
+ workos_user_id: string | null;
2113
+ };
2114
+ Insert: {
2115
+ config?: Json;
2116
+ created_at?: string;
2117
+ display_name?: string | null;
2118
+ email: string;
2119
+ first_name?: string | null;
2120
+ id?: string;
2121
+ is_active?: boolean;
2122
+ is_platform_admin?: boolean | null;
2123
+ last_login_at?: string | null;
2124
+ last_name?: string | null;
2125
+ last_visited_org?: string | null;
2126
+ profile_picture_url?: string | null;
2127
+ updated_at?: string;
2128
+ workos_user_id?: string | null;
2129
+ };
2130
+ Update: {
2131
+ config?: Json;
2132
+ created_at?: string;
2133
+ display_name?: string | null;
2134
+ email?: string;
2135
+ first_name?: string | null;
2136
+ id?: string;
2137
+ is_active?: boolean;
2138
+ is_platform_admin?: boolean | null;
2139
+ last_login_at?: string | null;
2140
+ last_name?: string | null;
2141
+ last_visited_org?: string | null;
2142
+ profile_picture_url?: string | null;
2143
+ updated_at?: string;
2144
+ workos_user_id?: string | null;
2145
+ };
2146
+ Relationships: [
2147
+ {
2148
+ foreignKeyName: "user_profiles_last_visited_org_fkey";
2149
+ columns: ["last_visited_org"];
2150
+ isOneToOne: false;
2151
+ referencedRelation: "organizations";
2152
+ referencedColumns: ["id"];
2153
+ }
2154
+ ];
2155
+ };
2156
+ webhook_endpoints: {
2157
+ Row: {
2158
+ created_at: string;
2159
+ description: string | null;
2160
+ id: string;
2161
+ key: string;
2162
+ last_triggered_at: string | null;
2163
+ name: string;
2164
+ organization_id: string;
2165
+ request_count: number;
2166
+ resource_id: string | null;
2167
+ status: string;
2168
+ updated_at: string;
2169
+ };
2170
+ Insert: {
2171
+ created_at?: string;
2172
+ description?: string | null;
2173
+ id?: string;
2174
+ key: string;
2175
+ last_triggered_at?: string | null;
2176
+ name: string;
2177
+ organization_id: string;
2178
+ request_count?: number;
2179
+ resource_id?: string | null;
2180
+ status?: string;
2181
+ updated_at?: string;
2182
+ };
2183
+ Update: {
2184
+ created_at?: string;
2185
+ description?: string | null;
2186
+ id?: string;
2187
+ key?: string;
2188
+ last_triggered_at?: string | null;
2189
+ name?: string;
2190
+ organization_id?: string;
2191
+ request_count?: number;
2192
+ resource_id?: string | null;
2193
+ status?: string;
2194
+ updated_at?: string;
2195
+ };
2196
+ Relationships: [
2197
+ {
2198
+ foreignKeyName: "webhook_endpoints_organization_id_fkey";
2199
+ columns: ["organization_id"];
2200
+ isOneToOne: false;
2201
+ referencedRelation: "organizations";
2202
+ referencedColumns: ["id"];
2203
+ }
2204
+ ];
2205
+ };
2206
+ };
2207
+ Views: {
2208
+ [_ in never]: never;
2209
+ };
2210
+ Functions: {
2211
+ acq_default_checklist: {
2212
+ Args: {
2213
+ p_platform: string;
2214
+ };
2215
+ Returns: Json;
2216
+ };
2217
+ append_deal_activity: {
2218
+ Args: {
2219
+ p_activity: Json;
2220
+ p_deal_id: string;
2221
+ p_organization_id: string;
2222
+ };
2223
+ Returns: undefined;
2224
+ };
2225
+ auth_jwt_claims: {
2226
+ Args: never;
2227
+ Returns: Json;
2228
+ };
2229
+ auth_uid_safe: {
2230
+ Args: never;
2231
+ Returns: string;
2232
+ };
2233
+ current_user_is_platform_admin: {
2234
+ Args: never;
2235
+ Returns: boolean;
2236
+ };
2237
+ current_user_supabase_id: {
2238
+ Args: never;
2239
+ Returns: string;
2240
+ };
2241
+ detect_stalled_executions: {
2242
+ Args: never;
2243
+ Returns: undefined;
2244
+ };
2245
+ execute_session_turn: {
2246
+ Args: {
2247
+ p_session_id: string;
2248
+ };
2249
+ Returns: {
2250
+ created_at: string;
2251
+ ended_at: string;
2252
+ memory_snapshot: Json;
2253
+ metadata: Json;
2254
+ organization_id: string;
2255
+ resource_id: string;
2256
+ session_id: string;
2257
+ session_total_turns: number;
2258
+ updated_at: string;
2259
+ user_id: string;
2260
+ }[];
2261
+ };
2262
+ get_storage_org_id: {
2263
+ Args: {
2264
+ file_path: string;
2265
+ };
2266
+ Returns: string;
2267
+ };
2268
+ get_workos_user_id: {
2269
+ Args: never;
2270
+ Returns: string;
2271
+ };
2272
+ is_org_admin: {
2273
+ Args: {
2274
+ org_id: string;
2275
+ };
2276
+ Returns: boolean;
2277
+ };
2278
+ is_org_member: {
2279
+ Args: {
2280
+ org_id: string;
2281
+ };
2282
+ Returns: boolean;
2283
+ };
2284
+ link_workos_membership_on_accept: {
2285
+ Args: {
2286
+ p_email: string;
2287
+ p_organization_id: string;
2288
+ p_workos_membership_id: string;
2289
+ };
2290
+ Returns: boolean;
2291
+ };
2292
+ pre_provision_invited_user: {
2293
+ Args: {
2294
+ p_email: string;
2295
+ p_organization_id: string;
2296
+ p_role_slug?: string;
2297
+ };
2298
+ Returns: Json;
2299
+ };
2300
+ process_due_schedules: {
2301
+ Args: never;
2302
+ Returns: Json;
2303
+ };
2304
+ upsert_user_profile: {
2305
+ Args: never;
2306
+ Returns: {
2307
+ profile_display_name: string;
2308
+ profile_email: string;
2309
+ profile_id: string;
2310
+ profile_workos_user_id: string;
2311
+ }[];
2312
+ };
2313
+ };
2314
+ Enums: {
2315
+ [_ in never]: never;
2316
+ };
2317
+ CompositeTypes: {
2318
+ [_ in never]: never;
2319
+ };
2320
+ };
2321
+ };
2322
+ type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">;
2323
+ type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">];
2324
+ type Tables<DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | {
2325
+ schema: keyof DatabaseWithoutInternals;
2326
+ }, TableName extends DefaultSchemaTableNameOrOptions extends {
2327
+ schema: keyof DatabaseWithoutInternals;
2328
+ } ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) : never = never> = DefaultSchemaTableNameOrOptions extends {
2329
+ schema: keyof DatabaseWithoutInternals;
2330
+ } ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
2331
+ Row: infer R;
2332
+ } ? R : never : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) ? (DefaultSchema["Tables"] & DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
2333
+ Row: infer R;
2334
+ } ? R : never : never;
2335
+
2336
+ type SupabaseUserProfile = Tables<'users'>;
2337
+
2338
+ /**
2339
+ * Action configuration for HITL tasks
2340
+ * Defines available user actions and their behavior
2341
+ */
2342
+ interface ActionConfig {
2343
+ /** Unique action identifier (e.g., 'approve', 'retry', 'escalate') */
2344
+ id: string;
2345
+ /** Display label for UI button */
2346
+ label: string;
2347
+ /** Button variant/style */
2348
+ type: 'primary' | 'secondary' | 'danger' | 'outline';
2349
+ /** Tabler icon name (e.g., 'IconCheck', 'IconRefresh') */
2350
+ icon?: string;
2351
+ /** Button color (Mantine theme colors) */
2352
+ color?: string;
2353
+ /** Button variant (Mantine button variant, e.g., 'light', 'filled', 'outline') */
2354
+ variant?: string;
2355
+ /** Execution target (agent/workflow to invoke) */
2356
+ target?: {
2357
+ resourceType: 'agent' | 'workflow';
2358
+ resourceId: string;
2359
+ /**
2360
+ * Optional session ID for agent continuation.
2361
+ * If provided, invokes a new turn on the existing session instead of standalone execution.
2362
+ * Only valid when resourceType is 'agent'.
2363
+ */
2364
+ sessionId?: string;
2365
+ };
2366
+ /** Form schema for collecting action-specific data */
2367
+ form?: FormSchema;
2368
+ /** Payload template for pre-filling forms */
2369
+ payloadTemplate?: unknown;
2370
+ /** Requires confirmation dialog */
2371
+ requiresConfirmation?: boolean;
2372
+ /** Confirmation message */
2373
+ confirmationMessage?: string;
2374
+ /** Help text / tooltip */
2375
+ description?: string;
2376
+ }
2377
+
2378
+ /**
2379
+ * Origin resource type - where an execution/task originated from.
2380
+ * Used for audit trails and tracking execution lineage.
2381
+ */
2382
+ type OriginResourceType = 'agent' | 'workflow' | 'scheduler' | 'api';
2383
+ /**
2384
+ * Origin tracking metadata - who/what created this execution/task.
2385
+ * Used by both TaskScheduler and CommandQueue for complete audit trails.
2386
+ */
2387
+ interface OriginTracking {
2388
+ originExecutionId: string;
2389
+ originResourceType: OriginResourceType;
2390
+ originResourceId: string;
2391
+ }
2392
+
2393
+ /**
2394
+ * Command queue task with flexible action system
2395
+ */
2396
+ interface Task extends OriginTracking {
2397
+ id: string;
2398
+ organizationId: string;
2399
+ actions: ActionConfig[];
2400
+ context: unknown;
2401
+ selectedAction?: string;
2402
+ actionPayload?: unknown;
2403
+ description?: string;
2404
+ priority: number;
2405
+ /** Optional checkpoint identifier for grouping related human approval tasks */
2406
+ humanCheckpoint?: string;
2407
+ status: TaskStatus;
2408
+ /**
2409
+ * Target resource tracking — mirrors origin columns.
2410
+ * Set when task is created; patchable to redirect execution to a different resource.
2411
+ */
2412
+ targetResourceId?: string;
2413
+ targetResourceType?: 'agent' | 'workflow';
2414
+ /**
2415
+ * Execution ID for the action that runs AFTER user approval.
2416
+ * NULL until execution starts.
2417
+ *
2418
+ * Naming distinction:
2419
+ * - originExecutionId = Parent execution that CREATED the HITL task
2420
+ * - targetExecutionId = Child execution that RUNS AFTER user approval
2421
+ */
2422
+ targetExecutionId?: string;
2423
+ createdAt: Date;
2424
+ completedAt?: Date;
2425
+ completedBy?: string;
2426
+ expiresAt?: Date;
2427
+ idempotencyKey?: string | null;
2428
+ }
2429
+ /**
2430
+ * Task status values
2431
+ * - pending: awaiting action
2432
+ * - processing: execution in progress after user approval
2433
+ * - completed: action was taken and execution succeeded
2434
+ * - failed: execution failed, task can be retried
2435
+ * - expired: timed out before action
2436
+ */
2437
+ type TaskStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
2438
+ /**
2439
+ * Parameters for patching mutable metadata on a task
2440
+ */
2441
+ interface PatchTaskParams {
2442
+ humanCheckpoint?: string | null;
2443
+ description?: string;
2444
+ priority?: number;
2445
+ context?: Record<string, unknown>;
2446
+ actions?: unknown[];
2447
+ targetResourceId?: string | null;
2448
+ targetResourceType?: 'agent' | 'workflow' | null;
2449
+ targetExecutionId?: string;
2450
+ status?: 'pending' | 'failed' | 'completed';
2451
+ }
2452
+
2453
+ /**
2454
+ * Checkpoint list item for sidebar grouping
2455
+ * The id field contains the resourceId of the human checkpoint
2456
+ */
2457
+ interface CheckpointListItem {
2458
+ /** Human checkpoint resourceId (or 'ungrouped' for tasks without checkpoint) */
2459
+ id: string;
2460
+ /** Display name (same as id, or "Ungrouped" for null) */
2461
+ name: string;
2462
+ /** Task count for this checkpoint */
2463
+ count: number;
2464
+ }
2465
+ /**
2466
+ * Status counts for pie chart display
2467
+ */
2468
+ interface StatusCounts {
2469
+ pending: number;
2470
+ completed: number;
2471
+ expired: number;
2472
+ }
2473
+ /**
2474
+ * Priority counts for donut chart display
2475
+ */
2476
+ interface PriorityCounts {
2477
+ critical: number;
2478
+ high: number;
2479
+ medium: number;
2480
+ low: number;
2481
+ }
2482
+ /**
2483
+ * Response from GET /command-queue/checkpoints endpoint
2484
+ */
2485
+ interface CheckpointListResponse {
2486
+ checkpoints: CheckpointListItem[];
2487
+ /** Total tasks across all checkpoints */
2488
+ total: number;
2489
+ /** Breakdown by status for donut chart */
2490
+ statusCounts: StatusCounts;
2491
+ /** Breakdown by priority for donut chart */
2492
+ priorityCounts: PriorityCounts;
2493
+ }
2494
+
2495
+ /**
2496
+ * Target for schedule execution - identifies what resource to execute.
2497
+ * Unlike ExecutionTarget, payload is NOT included here because schedules
2498
+ * store payload in the scheduleConfig (varies per step/item).
2499
+ */
2500
+ interface ScheduleTarget {
2501
+ resourceType: 'agent' | 'workflow';
2502
+ resourceId: string;
2503
+ }
2504
+ /**
2505
+ * Optional origin tracking for schedules.
2506
+ * Unlike OriginTracking (which is required), these fields are all optional
2507
+ * for schedules created directly via API (not triggered by another resource).
2508
+ */
2509
+ interface ScheduleOriginTracking {
2510
+ originExecutionId?: string;
2511
+ originResourceType?: OriginResourceType;
2512
+ originResourceId?: string;
2513
+ }
2514
+ type TaskScheduleConfig = RecurringScheduleConfig | RelativeScheduleConfig | AbsoluteScheduleConfig;
2515
+ interface RecurringScheduleConfig {
2516
+ type: 'recurring';
2517
+ cron?: string;
2518
+ interval?: 'daily' | 'weekly' | 'monthly';
2519
+ time?: string;
2520
+ timezone: string;
2521
+ payload: Record<string, unknown>;
2522
+ endAt?: string | null;
2523
+ overduePolicy?: 'skip' | 'execute';
2524
+ }
2525
+ interface RelativeScheduleConfig {
2526
+ type: 'relative';
2527
+ anchorAt: string;
2528
+ anchorLabel?: string;
2529
+ items: RelativeScheduleItem[];
2530
+ overduePolicy?: 'skip' | 'execute';
2531
+ }
2532
+ interface RelativeScheduleItem {
2533
+ offset: string;
2534
+ payload: Record<string, unknown>;
2535
+ label?: string;
2536
+ }
2537
+ interface AbsoluteScheduleConfig {
2538
+ type: 'absolute';
2539
+ items: AbsoluteScheduleItem[];
2540
+ overduePolicy?: 'skip' | 'execute';
2541
+ }
2542
+ interface AbsoluteScheduleItem {
2543
+ runAt: string;
2544
+ payload: Record<string, unknown>;
2545
+ label?: string;
2546
+ }
2547
+ interface TaskSchedule extends ScheduleOriginTracking {
2548
+ id: string;
2549
+ organizationId: string;
2550
+ name: string;
2551
+ description?: string;
2552
+ target: ScheduleTarget;
2553
+ scheduleConfig: TaskScheduleConfig;
2554
+ nextRunAt?: Date;
2555
+ currentStep: number;
2556
+ status: 'active' | 'paused' | 'completed' | 'cancelled';
2557
+ lastRunAt?: Date;
2558
+ lastExecutionId?: string;
2559
+ maxRetries: number;
2560
+ idempotencyKey?: string;
2561
+ createdAt: Date;
2562
+ updatedAt: Date;
2563
+ }
2564
+
2565
+ /**
2566
+ * Wire-format DTO for notification API responses.
2567
+ * Dates are ISO 8601 strings (not Date objects like the domain Notification type).
2568
+ * Used by frontend hooks that consume /api/notifications.
2569
+ */
2570
+ interface NotificationDTO {
2571
+ id: string;
2572
+ userId: string;
2573
+ organizationId: string;
2574
+ category: string;
2575
+ title: string;
2576
+ message: string;
2577
+ actionUrl: string | null;
2578
+ read: boolean;
2579
+ readAt: string | null;
2580
+ createdAt: string;
2581
+ }
2582
+
2583
+ /**
2584
+ * Session Data Transfer Object (DTO)
2585
+ * Transform type for API responses (snake_case DB → camelCase frontend)
2586
+ * Used by frontend apps to display session data
2587
+ */
2588
+ interface SessionDTO {
2589
+ sessionId: string;
2590
+ resourceId: string;
2591
+ organizationId: string;
2592
+ userId?: string | null;
2593
+ turnCount: number;
2594
+ isEnded: boolean;
2595
+ title?: string | null;
2596
+ memorySnapshot?: AgentMemory;
2597
+ metadata?: Record<string, unknown> | null;
2598
+ createdAt: Date;
2599
+ updatedAt: Date;
2600
+ endedAt?: Date | null;
2601
+ }
2602
+
2603
+ /**
2604
+ * Multi-tenancy configuration types
2605
+ *
2606
+ * Config is stored in dedicated `config` columns (NOT nested in metadata):
2607
+ * - organizations.config: Org-level feature config
2608
+ * - org_memberships.config: Per-user-per-org feature overrides
2609
+ * - users.config: User-global config
2610
+ */
2611
+ /**
2612
+ * Org-level feature config (stored in organizations.config)
2613
+ * Controls which features are available to all org members
2614
+ * Valid feature keys: operations, monitoring, acquisition, calibration, seo
2615
+ */
2616
+ interface OrgFeatureConfig {
2617
+ features?: {
2618
+ operations?: boolean;
2619
+ monitoring?: boolean;
2620
+ acquisition?: boolean;
2621
+ calibration?: boolean;
2622
+ seo?: boolean;
2623
+ };
2624
+ }
2625
+ /**
2626
+ * Per-user-per-org config (stored in org_memberships.config)
2627
+ * Overrides org-level feature config for specific users
2628
+ */
2629
+ type MembershipFeatureConfig = OrgFeatureConfig;
2630
+ /**
2631
+ * User-global config (stored in users.config)
2632
+ * Theme and onboarding are user-specific, NOT org-specific
2633
+ */
2634
+ interface UserConfig {
2635
+ theme?: {
2636
+ preset?: 'default' | 'tactical' | 'regal' | 'cyber-volt' | 'aurora' | 'rose-gold' | 'midnight' | 'ember' | 'obsidian' | 'honey' | 'abyss' | 'canopy' | 'slate' | 'cyber-strike' | 'cyber-flux' | 'cyber-void';
2637
+ colorScheme?: 'light' | 'dark' | 'auto';
2638
+ };
2639
+ onboarding?: {
2640
+ completed?: boolean;
2641
+ completedAt?: string;
2642
+ role?: string;
2643
+ primaryUseCase?: string[];
2644
+ experienceLevel?: string;
2645
+ /** Onboarding guide system state (set by checklist/tour system) */
2646
+ guides?: {
2647
+ completedIds?: string[];
2648
+ dismissed?: boolean;
2649
+ completedAt?: string;
2650
+ };
2651
+ };
2652
+ }
2653
+
2654
+ /**
2655
+ * Organization Membership types based on WorkOS API
2656
+ */
2657
+ interface OrganizationMembership {
2658
+ object: 'organization_membership';
2659
+ id: string;
2660
+ userId: string;
2661
+ organizationId: string;
2662
+ role: {
2663
+ slug: string;
2664
+ };
2665
+ status: 'active' | 'inactive';
2666
+ createdAt: string;
2667
+ updatedAt: string;
2668
+ }
2669
+ /**
2670
+ * Extended membership with user and organization details for UI
2671
+ */
2672
+ interface MembershipWithDetails extends OrganizationMembership {
2673
+ user?: {
2674
+ id: string;
2675
+ email: string;
2676
+ firstName?: string;
2677
+ lastName?: string;
2678
+ profilePictureUrl?: string;
2679
+ };
2680
+ organization?: {
2681
+ id: string;
2682
+ name: string;
2683
+ workos_org_id: string;
2684
+ primaryDomain?: string;
2685
+ is_test?: boolean;
2686
+ status?: string;
2687
+ metadata?: Record<string, unknown>;
2688
+ config?: OrgFeatureConfig;
2689
+ };
2690
+ config?: MembershipFeatureConfig;
2691
+ }
2692
+
2693
+ /**
2694
+ * Time range selector for dashboard metrics
2695
+ */
2696
+ type TimeRange = '1h' | '24h' | '7d' | '30d';
2697
+ /**
2698
+ * Execution health metrics response
2699
+ * Success rate, P95 duration, execution counts, and trend data
2700
+ * trendData includes executionCount for throughput visualization (eliminates separate API call)
2701
+ */
2702
+ interface ExecutionHealthMetrics {
2703
+ successRate: number;
2704
+ p95Duration: number;
2705
+ totalExecutions: number;
2706
+ trendData: Array<{
2707
+ time: string;
2708
+ rate: number;
2709
+ successCount: number;
2710
+ errorCount: number;
2711
+ warningCount: number;
2712
+ executionCount: number;
2713
+ }>;
2714
+ statusCounts: {
2715
+ success: number;
2716
+ failed: number;
2717
+ pending: number;
2718
+ warning: number;
2719
+ };
2720
+ peakPeriod: string;
2721
+ granularity: 'hour' | 'day';
2722
+ }
2723
+ /**
2724
+ * Error analysis metrics response
2725
+ * Error categories and top failing resources
2726
+ */
2727
+ interface ErrorAnalysisMetrics {
2728
+ totalErrors: number;
2729
+ errorsByCategory: Array<{
2730
+ category: string;
2731
+ count: number;
2732
+ percentage: number;
2733
+ }>;
2734
+ topFailingResources: Array<{
2735
+ resourceId: string;
2736
+ name: string;
2737
+ errorCount: number;
2738
+ failureRate: number;
2739
+ }>;
2740
+ }
2741
+ /**
2742
+ * Business impact metrics response
2743
+ * ROI, labor savings, and cost analysis
2744
+ */
2745
+ interface BusinessImpactMetrics$1 {
2746
+ totalSavingsUsd: number;
2747
+ totalCostUsd: number;
2748
+ netSavingsUsd: number;
2749
+ roi: number;
2750
+ }
2751
+ /**
2752
+ * Cost breakdown metrics response
2753
+ * Per-resource cost analysis
2754
+ */
2755
+ interface CostBreakdownMetrics {
2756
+ resources: Array<{
2757
+ resourceId: string;
2758
+ totalCostUsd: number;
2759
+ executionCount: number;
2760
+ avgCostUsd: number;
2761
+ }>;
2762
+ }
2763
+ /**
2764
+ * Dashboard metrics response
2765
+ * Aggregates core observability metrics in a single response
2766
+ * Note: Throughput data is now included in executionHealth.trendData.executionCount
2767
+ */
2768
+ interface DashboardMetrics {
2769
+ executionHealth: ExecutionHealthMetrics;
2770
+ costBreakdown: CostBreakdownMetrics;
2771
+ businessImpact: BusinessImpactMetrics$1;
2772
+ /** ISO timestamp of the currently active deployment, or null if none */
2773
+ activeDeploymentDate: string | null;
2774
+ /** Deployment version of the active deployment, or null if none */
2775
+ activeDeploymentVersion: string | null;
2776
+ }
2777
+ /**
2778
+ * Error record for list view (ErrorBreakdownTable)
2779
+ */
2780
+ interface ErrorRecord {
2781
+ id: string;
2782
+ timestamp: string;
2783
+ errorType: string;
2784
+ message: string;
2785
+ executionId: string;
2786
+ resourceId: string;
2787
+ resourceName: string;
2788
+ severity: 'critical' | 'warning' | 'info';
2789
+ category: ExecutionErrorCategory;
2790
+ resolved: boolean;
2791
+ resolvedAt: string | null;
2792
+ resolvedBy: string | null;
2793
+ }
2794
+ /**
2795
+ * Full error detail for modal view (ErrorDetailsModal)
2796
+ */
2797
+ interface ErrorDetailFull extends ErrorRecord {
2798
+ stackTrace?: string;
2799
+ retryAttempt?: number;
2800
+ stepName?: string;
2801
+ stepSequence?: number;
2802
+ errorContext?: Record<string, unknown>;
2803
+ executionContext?: Record<string, unknown>;
2804
+ }
2805
+ /**
2806
+ * Error details API response (paginated)
2807
+ */
2808
+ interface ErrorDetailResponse {
2809
+ errors: ErrorRecord[];
2810
+ total: number;
2811
+ page: number;
2812
+ limit: number;
2813
+ }
2814
+ /**
2815
+ * Error trend data for time-series charts
2816
+ */
2817
+ interface ErrorTrend {
2818
+ time: string;
2819
+ errorCount: number;
2820
+ criticalCount: number;
2821
+ warningCount: number;
2822
+ infoCount: number;
2823
+ }
2824
+ /**
2825
+ * Cost trend data point for time-series charts
2826
+ * Represents a single time bucket (hour or day)
2827
+ */
2828
+ interface CostTrendDataPoint {
2829
+ time: string;
2830
+ totalCostUsd: number;
2831
+ executionCount: number;
2832
+ avgCostPerExecution: number;
2833
+ }
2834
+ /**
2835
+ * Cost trends response (time-series data)
2836
+ */
2837
+ interface CostTrendsResponse {
2838
+ trendData: CostTrendDataPoint[];
2839
+ granularity: 'hour' | 'day';
2840
+ totalCostUsd: number;
2841
+ totalExecutions: number;
2842
+ }
2843
+ /**
2844
+ * Cost summary response with MTD and projections
2845
+ */
2846
+ interface CostSummaryResponse {
2847
+ current: {
2848
+ totalCostUsd: number;
2849
+ executionCount: number;
2850
+ };
2851
+ previous: {
2852
+ totalCostUsd: number;
2853
+ executionCount: number;
2854
+ };
2855
+ mtd: {
2856
+ totalCostUsd: number;
2857
+ daysElapsed: number;
2858
+ };
2859
+ projection: {
2860
+ monthlyCostUsd: number;
2861
+ confidence: 'low' | 'medium' | 'high';
2862
+ };
2863
+ trend: {
2864
+ changePercent: number;
2865
+ direction: 'up' | 'down' | 'flat';
2866
+ };
2867
+ }
2868
+ /**
2869
+ * Cost by model data for model-level breakdown
2870
+ */
2871
+ interface CostByModelData {
2872
+ model: string;
2873
+ totalCostUsd: number;
2874
+ callCount: number;
2875
+ totalInputTokens: number;
2876
+ totalOutputTokens: number;
2877
+ avgCostPerCall: number;
2878
+ }
2879
+ /**
2880
+ * Cost by model response
2881
+ */
2882
+ interface CostByModelResponse {
2883
+ models: CostByModelData[];
2884
+ totalCostUsd: number;
2885
+ totalCallCount: number;
2886
+ }
2887
+
2888
+ /**
2889
+ * Base Execution Engine type definitions
2890
+ * Core types shared across all Execution Engine resources
2891
+ */
2892
+
2893
+ /**
2894
+ * NOTE: AIResource interface has been removed and replaced with ResourceDefinition
2895
+ * from registry/types.ts. All resources (executable and non-executable) now extend
2896
+ * the unified ResourceDefinition base interface.
2897
+ *
2898
+ * AgentConfig and WorkflowConfig now extend ResourceDefinition directly.
2899
+ * See packages/core/src/registry/types.ts for the base interface definition.
2900
+ */
2901
+ type AIResourceDefinition = SerializedWorkflowDefinition | SerializedAgentDefinition;
2902
+
2903
+ /**
2904
+ * Resource Registry type definitions
2905
+ */
2906
+
2907
+ /**
2908
+ * Environment/deployment status for resources
2909
+ */
2910
+ type ResourceStatus$1 = 'dev' | 'prod';
2911
+ /**
2912
+ * All resource types in the platform
2913
+ * Used as the discriminator field in ResourceDefinition
2914
+ */
2915
+ type ResourceType$1 = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human';
2916
+ /**
2917
+ * Base interface for ALL platform resources
2918
+ * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
2919
+ */
2920
+ interface ResourceDefinition {
2921
+ /** Unique resource identifier */
2922
+ resourceId: string;
2923
+ /** Display name */
2924
+ name: string;
2925
+ /** Purpose and functionality description */
2926
+ description: string;
2927
+ /** Version for change tracking and evolution */
2928
+ version: string;
2929
+ /** Resource type discriminator */
2930
+ type: ResourceType$1;
2931
+ /** Environment/deployment status */
2932
+ status: ResourceStatus$1;
2933
+ /** Domain tags for filtering and organization */
2934
+ domains?: ResourceDomain[];
2935
+ /** Whether the agent supports multi-turn sessions (agents only) */
2936
+ sessionCapable?: boolean;
2937
+ /** Whether the resource is local (monorepo) or remote (externally deployed) */
2938
+ origin?: 'local' | 'remote';
2939
+ /** Whether this resource is archived and should be excluded from registration and deployment */
2940
+ archived?: boolean;
2941
+ }
2942
+
2943
+ /**
2944
+ * Standard Domain Definitions
2945
+ * Centralized domain constants and definitions for all organization resources.
2946
+ */
2947
+
2948
+ declare const DOMAINS: {
2949
+ readonly INBOUND_PIPELINE: "inbound-pipeline";
2950
+ readonly LEAD_GEN_PIPELINE: "lead-gen-pipeline";
2951
+ readonly SUPPORT: "support";
2952
+ readonly CLIENT_SUPPORT: "client-support";
2953
+ readonly DELIVERY: "delivery";
2954
+ readonly OPERATIONS: "operations";
2955
+ readonly FINANCE: "finance";
2956
+ readonly EXECUTIVE: "executive";
2957
+ readonly INSTANTLY: "instantly";
2958
+ readonly TESTING: "testing";
2959
+ readonly INTERNAL: "internal";
2960
+ readonly INTEGRATION: "integration";
2961
+ readonly UTILITY: "utility";
2962
+ readonly DIAGNOSTIC: "diagnostic";
2963
+ };
2964
+ /**
2965
+ * ResourceDomain - Strongly typed domain identifier
2966
+ * Use this type for all domain references to ensure compile-time validation.
2967
+ */
2968
+ type ResourceDomain = (typeof DOMAINS)[keyof typeof DOMAINS];
2969
+
2970
+ type ExecutionStatus$1 = 'pending' | 'running' | 'completed' | 'failed' | 'warning';
2971
+
2972
+ type ActivityType = 'workflow_execution' | 'agent_run' | 'hitl_action' | 'webhook_received' | 'webhook_executed' | 'webhook_failed' | 'credential_change' | 'api_key_change' | 'deployment_change' | 'membership_change';
2973
+ type ActivityStatus = 'success' | 'failure' | 'pending' | 'approved' | 'rejected' | 'completed';
2974
+ interface Activity {
2975
+ id: string;
2976
+ organizationId: string;
2977
+ activityType: ActivityType;
2978
+ status: ActivityStatus;
2979
+ title: string;
2980
+ description: string | null;
2981
+ entityType: string;
2982
+ entityId: string;
2983
+ entityName: string | null;
2984
+ metadata: Record<string, unknown> | null;
2985
+ actorId: string | null;
2986
+ actorType: string | null;
2987
+ occurredAt: Date;
2988
+ createdAt: Date;
2989
+ }
2990
+
2991
+ /**
2992
+ * Execution history item.
2993
+ * Represents a single execution triggered by a schedule.
2994
+ */
2995
+ declare const ExecutionHistoryItemSchema: z.ZodObject<{
2996
+ id: z.ZodString;
2997
+ createdAt: z.ZodString;
2998
+ status: z.ZodEnum<{
2999
+ completed: "completed";
3000
+ failed: "failed";
3001
+ running: "running";
3002
+ cancelled: "cancelled";
3003
+ }>;
3004
+ step: z.ZodNullable<z.ZodNumber>;
3005
+ itemLabel: z.ZodNullable<z.ZodString>;
3006
+ duration: z.ZodNullable<z.ZodNumber>;
3007
+ error: z.ZodNullable<z.ZodString>;
3008
+ }, z.core.$strip>;
3009
+ /**
3010
+ * Execution history response.
3011
+ * Returned by GET /schedules/:id/executions with pagination.
3012
+ */
3013
+ declare const ExecutionHistoryResponseSchema: z.ZodObject<{
3014
+ executions: z.ZodArray<z.ZodObject<{
3015
+ id: z.ZodString;
3016
+ createdAt: z.ZodString;
3017
+ status: z.ZodEnum<{
3018
+ completed: "completed";
3019
+ failed: "failed";
3020
+ running: "running";
3021
+ cancelled: "cancelled";
3022
+ }>;
3023
+ step: z.ZodNullable<z.ZodNumber>;
3024
+ itemLabel: z.ZodNullable<z.ZodString>;
3025
+ duration: z.ZodNullable<z.ZodNumber>;
3026
+ error: z.ZodNullable<z.ZodString>;
3027
+ }, z.core.$strip>>;
3028
+ total: z.ZodNumber;
3029
+ limit: z.ZodNumber;
3030
+ offset: z.ZodNumber;
3031
+ }, z.core.$strip>;
3032
+ type ExecutionHistoryItem = z.infer<typeof ExecutionHistoryItemSchema>;
3033
+ type ExecutionHistoryResponse = z.infer<typeof ExecutionHistoryResponseSchema>;
3034
+
3035
+ declare function useCommandQueue({ status, limit, offset, humanCheckpoint, timeRange, priorityMin, priorityMax, }?: {
3036
+ status?: TaskStatus;
3037
+ limit?: number;
3038
+ offset?: number;
3039
+ humanCheckpoint?: string;
3040
+ timeRange?: TimeRange;
3041
+ priorityMin?: number;
3042
+ priorityMax?: number;
3043
+ }): _tanstack_react_query.UseQueryResult<{
3044
+ createdAt: Date;
3045
+ completedAt: Date | undefined;
3046
+ expiresAt: Date | undefined;
3047
+ id: string;
3048
+ organizationId: string;
3049
+ actions: ActionConfig[];
3050
+ context: unknown;
3051
+ selectedAction?: string;
3052
+ actionPayload?: unknown;
3053
+ description?: string;
3054
+ priority: number;
3055
+ humanCheckpoint?: string;
3056
+ status: TaskStatus;
3057
+ targetResourceId?: string;
3058
+ targetResourceType?: "agent" | "workflow";
3059
+ targetExecutionId?: string;
3060
+ completedBy?: string;
3061
+ idempotencyKey?: string | null;
3062
+ originExecutionId: string;
3063
+ originResourceType: OriginResourceType;
3064
+ originResourceId: string;
3065
+ }[], Error>;
3066
+
3067
+ interface SubmitActionRequest {
3068
+ taskId: string;
3069
+ actionId: string;
3070
+ payload?: unknown;
3071
+ notes?: string;
3072
+ }
3073
+ interface OptimisticContext {
3074
+ previousData: Map<readonly unknown[], Task[] | undefined>;
3075
+ }
3076
+ interface ExecutionErrorDetails {
3077
+ message: string;
3078
+ type: string;
3079
+ severity: 'critical' | 'warning' | 'info';
3080
+ category: 'llm' | 'tool' | 'workflow' | 'agent' | 'validation' | 'system';
3081
+ details?: string;
3082
+ }
3083
+ interface SubmitActionResponse {
3084
+ task: unknown;
3085
+ execution?: {
3086
+ executionId: string;
3087
+ success: boolean;
3088
+ data?: unknown;
3089
+ error?: ExecutionErrorDetails;
3090
+ };
3091
+ }
3092
+ declare function useSubmitAction(): _tanstack_react_query.UseMutationResult<SubmitActionResponse, Error, SubmitActionRequest, OptimisticContext>;
3093
+
3094
+ declare function useDeleteTask(): _tanstack_react_query.UseMutationResult<void, Error, string, {
3095
+ previousData: Map<readonly unknown[], Task[] | undefined>;
3096
+ }>;
3097
+
3098
+ interface UseCommandQueueTotalsOptions {
3099
+ timeRange?: TimeRange;
3100
+ priorityMin?: number;
3101
+ priorityMax?: number;
3102
+ /** When set, priorityCounts are scoped to this status only */
3103
+ status?: 'pending' | 'completed' | 'expired';
3104
+ }
3105
+ /**
3106
+ * Fetches command queue totals and checkpoint groupings
3107
+ *
3108
+ * Returns distinct human checkpoints with task counts and status breakdown.
3109
+ * Used for sidebar grouping and donut charts (true totals, not paginated).
3110
+ */
3111
+ declare function useCommandQueueTotals({ timeRange, priorityMin, priorityMax, status }?: UseCommandQueueTotalsOptions): _tanstack_react_query.UseQueryResult<CheckpointListResponse, Error>;
3112
+
3113
+ declare function usePatchTask(): _tanstack_react_query.UseMutationResult<Task, Error, {
3114
+ taskId: string;
3115
+ params: PatchTaskParams;
3116
+ }, unknown>;
3117
+
3118
+ /**
3119
+ * Query key factory for executions TanStack Query hooks.
3120
+ * Uses organization UUID (not name) for cache isolation.
3121
+ */
3122
+ declare const executionsKeys: {
3123
+ all: readonly ["executions"];
3124
+ resources: (orgId: string | null) => readonly ["executions", "resources", string | null];
3125
+ resourceDefinition: (orgId: string | null, resourceId: string) => readonly ["executions", "definition", string | null, string];
3126
+ executions: (orgId: string | null, resourceId: string) => readonly ["executions", "list", string | null, string];
3127
+ execution: (orgId: string | null, resourceId: string, executionId: string) => readonly ["executions", "execution", string | null, string, string];
3128
+ };
3129
+
3130
+ /**
3131
+ * Workflow-specific logging types and utilities
3132
+ */
3133
+
3134
+
3135
+
3136
+ // Workflow start/end log context
3137
+ interface WorkflowExecutionContext {
3138
+ type: 'workflow'
3139
+ contextType: 'workflow-execution'
3140
+ executionId: string
3141
+ workflowId: string
3142
+ workflowName?: string
3143
+ organizationId: string
3144
+ executionPath?: string[]
3145
+ }
3146
+
3147
+ // Workflow failure log context
3148
+ interface WorkflowFailureContext {
3149
+ type: 'workflow'
3150
+ contextType: 'workflow-failure'
3151
+ executionId: string
3152
+ workflowId: string
3153
+ error: string
3154
+ }
3155
+
3156
+ // Step started log context
3157
+ interface StepStartedContext {
3158
+ type: 'workflow'
3159
+ contextType: 'step-started'
3160
+ stepId: string
3161
+ stepStatus: 'started'
3162
+ input: unknown
3163
+ startTime: number // Explicit start timestamp for timeline
3164
+ }
3165
+
3166
+ // Step completed log context
3167
+ interface StepCompletedContext {
3168
+ type: 'workflow'
3169
+ contextType: 'step-completed'
3170
+ stepId: string
3171
+ stepStatus: 'completed'
3172
+ output: unknown
3173
+ duration: number
3174
+ isTerminal: boolean
3175
+ startTime: number // Explicit start timestamp for timeline
3176
+ endTime: number // Explicit end timestamp for timeline
3177
+ }
3178
+
3179
+ // Step failed log context
3180
+ interface StepFailedContext {
3181
+ type: 'workflow'
3182
+ contextType: 'step-failed'
3183
+ stepId: string
3184
+ stepStatus: 'failed'
3185
+ error: string
3186
+ duration: number
3187
+ startTime: number // Explicit start timestamp for timeline
3188
+ endTime: number // Explicit end timestamp for timeline
3189
+ }
3190
+
3191
+ // Conditional routing log context
3192
+ interface ConditionalRouteContext {
3193
+ type: 'workflow'
3194
+ contextType: 'conditional-route'
3195
+ stepId: string
3196
+ target: string
3197
+ error?: string
3198
+ }
3199
+
3200
+ // Execution path log context
3201
+ interface ExecutionPathContext {
3202
+ type: 'workflow'
3203
+ contextType: 'execution-path'
3204
+ executionPath: string[]
3205
+ }
3206
+
3207
+ // Union of all workflow log contexts
3208
+ type WorkflowLogContext =
3209
+ | WorkflowExecutionContext
3210
+ | WorkflowFailureContext
3211
+ | StepStartedContext
3212
+ | StepCompletedContext
3213
+ | StepFailedContext
3214
+ | ConditionalRouteContext
3215
+ | ExecutionPathContext
3216
+
3217
+ /**
3218
+ * Agent-specific logging types
3219
+ * Simplified 2-event model: lifecycle, iteration
3220
+ *
3221
+ * Design Philosophy:
3222
+ * - LIFECYCLE EVENTS: Structural checkpoints (initialization, iteration, completion)
3223
+ * - ITERATION EVENTS: Execution activities (reasoning, actions during iterations)
3224
+ */
3225
+
3226
+
3227
+
3228
+ // ============================================================================
3229
+ // FORMAL TYPES
3230
+ // ============================================================================
3231
+
3232
+ /**
3233
+ * Agent lifecycle stages
3234
+ * Universal checkpoints that apply to all agent executions
3235
+ */
3236
+ type AgentLifecycle = 'initialization' | 'iteration' | 'completion'
3237
+
3238
+ /**
3239
+ * Iteration event types
3240
+ * Activities that occur during agent iterations
3241
+ */
3242
+ type IterationEventType = 'reasoning' | 'action' | 'tool-call'
3243
+
3244
+ // ============================================================================
3245
+ // LIFECYCLE EVENTS (Structural Checkpoints)
3246
+ // ============================================================================
3247
+
3248
+ /**
3249
+ * Base fields shared by all lifecycle events
3250
+ */
3251
+ interface AgentLifecycleEventBase {
3252
+ type: 'agent'
3253
+ agentId: string
3254
+ lifecycle: AgentLifecycle
3255
+ sessionId?: string // Optional: only present when agent runs in session context
3256
+ }
3257
+
3258
+ /**
3259
+ * Lifecycle started event - emitted when a phase begins
3260
+ * REQUIRED: startTime (phase has started, no end yet)
3261
+ */
3262
+ interface AgentLifecycleStartedEvent extends AgentLifecycleEventBase {
3263
+ stage: 'started'
3264
+ startTime: number // REQUIRED: Phase start timestamp
3265
+ iteration?: number // Only for 'iteration' lifecycle
3266
+ }
3267
+
3268
+ /**
3269
+ * Lifecycle completed event - emitted when a phase succeeds
3270
+ * REQUIRED: startTime, endTime, duration (phase has finished successfully)
3271
+ */
3272
+ interface AgentLifecycleCompletedEvent extends AgentLifecycleEventBase {
3273
+ stage: 'completed'
3274
+ startTime: number // REQUIRED: Phase start timestamp
3275
+ endTime: number // REQUIRED: Phase end timestamp
3276
+ duration: number // REQUIRED: Calculated duration (endTime - startTime)
3277
+ iteration?: number // Only for 'iteration' lifecycle
3278
+
3279
+ // Optional fields specific to certain lifecycles
3280
+ attempts?: number // Only for 'completion' lifecycle (tracks output generation attempts: 1 or 2)
3281
+ memorySize?: {
3282
+ sessionMemoryKeys: number
3283
+ historyEntries: number
3284
+ } // Only for 'completion' lifecycle (memory snapshot metadata)
3285
+ }
3286
+
3287
+ /**
3288
+ * Lifecycle failed event - emitted when a phase fails
3289
+ * REQUIRED: startTime, endTime, duration, error (phase has finished with error)
3290
+ */
3291
+ interface AgentLifecycleFailedEvent extends AgentLifecycleEventBase {
3292
+ stage: 'failed'
3293
+ startTime: number // REQUIRED: Phase start timestamp
3294
+ endTime: number // REQUIRED: Phase end timestamp
3295
+ duration: number // REQUIRED: Calculated duration (endTime - startTime)
3296
+ error: string // REQUIRED: Error message
3297
+ iteration?: number // Only for 'iteration' lifecycle
3298
+ }
3299
+
3300
+ /**
3301
+ * Union type for all lifecycle events
3302
+ * Discriminated by 'stage' field for type narrowing
3303
+ */
3304
+ type AgentLifecycleEvent = AgentLifecycleStartedEvent | AgentLifecycleCompletedEvent | AgentLifecycleFailedEvent
3305
+
3306
+ // ============================================================================
3307
+ // ITERATION EVENTS (Execution Activities)
3308
+ // ============================================================================
3309
+
3310
+ /**
3311
+ * Placeholder data for MVP
3312
+ * Will be typed per actionType in future
3313
+ */
3314
+ interface ActionPlaceholderData {
3315
+ message: string
3316
+ }
3317
+
3318
+ /**
3319
+ * Iteration event - captures activities during agent iterations
3320
+ * Consolidates reasoning (LLM thought process) and actions (tool use, memory ops, etc.)
3321
+ */
3322
+ interface AgentIterationEvent {
3323
+ type: 'agent'
3324
+ agentId: string
3325
+ lifecycle: 'iteration' // Always iteration
3326
+ eventType: IterationEventType
3327
+ iteration: number
3328
+ sessionId?: string // Optional: only present when agent runs in session context
3329
+
3330
+ // Timeline timing fields (v2 - Clean Break)
3331
+ startTime: number // Activity start timestamp
3332
+ endTime: number // Activity end timestamp
3333
+ duration: number // Calculated duration (endTime - startTime)
3334
+
3335
+ // Conditional fields based on eventType
3336
+ output?: string // For reasoning events
3337
+ actionType?: string // For action events (tool-use, delegate, memory-write, etc.)
3338
+ data?: ActionPlaceholderData // For action events
3339
+ }
3340
+
3341
+ /**
3342
+ * Tool call event - captures individual tool executions during iterations
3343
+ * Provides granular timing for each tool invocation
3344
+ */
3345
+ interface AgentToolCallEvent {
3346
+ type: 'agent'
3347
+ agentId: string
3348
+ lifecycle: 'iteration' // Always iteration
3349
+ eventType: 'tool-call' // Specific event type for tool calls
3350
+ iteration: number
3351
+ sessionId?: string // Optional: only present when agent runs in session context
3352
+
3353
+ // Tool identification and timing
3354
+ toolName: string // Tool identifier
3355
+ startTime: number // Tool call start timestamp
3356
+ endTime: number // Tool call end timestamp
3357
+ duration: number // Calculated duration
3358
+
3359
+ // Execution results
3360
+ success: boolean // Whether tool execution succeeded
3361
+ error?: string // Error message if failed
3362
+ input?: Record<string, unknown> // Tool input parameters
3363
+ output?: unknown // Tool output result
3364
+ }
3365
+
3366
+ // ============================================================================
3367
+ // UNION TYPES
3368
+ // ============================================================================
3369
+
3370
+ /**
3371
+ * Union type for all agent log contexts
3372
+ * 3 event types total (lifecycle, iteration, tool-call)
3373
+ */
3374
+ type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent
3375
+
3376
+ /**
3377
+ * Base execution logger for Execution Engine
3378
+ */
3379
+ type ExecutionLogLevel = 'debug' | 'info' | 'warn' | 'error'
3380
+
3381
+
3382
+ // Union type for all contexts
3383
+ type LogContext = WorkflowLogContext | AgentLogContext
3384
+
3385
+ // Updated interface with consolidated context
3386
+ interface ExecutionLogMessage {
3387
+ level: ExecutionLogLevel
3388
+ message: string
3389
+ timestamp: number
3390
+ context?: LogContext
3391
+ }
3392
+
3393
+ /**
3394
+ * Resource Registry type definitions
3395
+ */
3396
+
3397
+
3398
+
3399
+ // ============================================================================
3400
+ // Core Resource Type Definitions
3401
+ // ============================================================================
3402
+
3403
+ /**
3404
+ * Environment/deployment status for resources
3405
+ */
3406
+ type ResourceStatus = 'dev' | 'prod'
3407
+
3408
+ /**
3409
+ * All resource types in the platform
3410
+ * Used as the discriminator field in ResourceDefinition
3411
+ */
3412
+ type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human'
3413
+
3414
+ // Execution status type shared between API and UI
3415
+ type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'warning'
3416
+
3417
+ // API execution types
3418
+ interface APIExecutionSummary {
3419
+ id: string
3420
+ status: ExecutionStatus
3421
+ startTime: number
3422
+ endTime?: number
3423
+ resourceStatus?: ResourceStatus // 'dev' | 'prod' - optional for backward compatibility
3424
+ }
3425
+
3426
+ interface APIExecutionDetail extends APIExecutionSummary {
3427
+ executionLogs: ExecutionLogMessage[]
3428
+ input?: unknown
3429
+ result?: unknown
3430
+ error?: string
3431
+ resourceStatus: ResourceStatus // Required in detail view
3432
+ apiVersion?: string | null
3433
+ resourceVersion?: string | null
3434
+ sdkVersion?: string | null
3435
+ }
3436
+
3437
+ // API request/response types
3438
+ interface APIExecutionListResponse {
3439
+ executions: APIExecutionSummary[]
3440
+ }
3441
+
3442
+ /**
3443
+ * Fetch the execution list for a given resource.
3444
+ *
3445
+ * resourceStatus and limit are intentionally excluded from the query key so that
3446
+ * SSE invalidations (which target the unfiltered key) bust all filter variants.
3447
+ *
3448
+ * @example
3449
+ * const { data, isLoading } = useExecutions(resourceId)
3450
+ *
3451
+ * @example
3452
+ * // With status filter and limit
3453
+ * const { data } = useExecutions(resourceId, 'running', 20)
3454
+ */
3455
+ declare function useExecutions(resourceId: string, resourceStatus?: ResourceStatus | 'all', limit?: number): _tanstack_react_query.UseQueryResult<APIExecutionListResponse, Error>;
3456
+
3457
+ /**
3458
+ * Fetch a single execution detail.
3459
+ * Automatically polls every 2 seconds while the execution status is 'running'.
3460
+ *
3461
+ * @example
3462
+ * const { data: execution, isLoading } = useExecution(resourceId, executionId)
3463
+ */
3464
+ declare function useExecution(resourceId: string, executionId: string): _tanstack_react_query.UseQueryResult<APIExecutionDetail, Error>;
3465
+
3466
+ interface ExecuteAsyncParams {
3467
+ resourceId: string;
3468
+ resourceType: ResourceType;
3469
+ input: unknown;
3470
+ }
3471
+ interface ExecuteAsyncResult {
3472
+ executionId: string;
3473
+ status: string;
3474
+ resourceId: string;
3475
+ }
3476
+ /**
3477
+ * Trigger an async execution for a workflow or agent.
3478
+ * Invalidates the executions list on success so the new execution appears immediately.
3479
+ *
3480
+ * @example
3481
+ * const { mutate: execute, isPending } = useExecuteAsync()
3482
+ * execute({ resourceId, resourceType: 'workflow', input: { ... } })
3483
+ */
3484
+ declare function useExecuteAsync(): _tanstack_react_query.UseMutationResult<ExecuteAsyncResult, Error, ExecuteAsyncParams, unknown>;
3485
+
3486
+ interface RetryExecutionParams {
3487
+ resourceId: string;
3488
+ resourceType: ResourceType;
3489
+ input: unknown;
3490
+ }
3491
+ /**
3492
+ * Retry a failed execution by re-triggering it async.
3493
+ * Functionally identical to useExecuteAsync but named for intent clarity at call sites.
3494
+ */
3495
+ declare function useRetryExecution(): _tanstack_react_query.UseMutationResult<{
3496
+ resourceId: string;
3497
+ executionId: string;
3498
+ status: string;
3499
+ }, Error, RetryExecutionParams, unknown>;
3500
+
3501
+ interface CancelExecutionParams {
3502
+ resourceId: string;
3503
+ executionId: string;
3504
+ }
3505
+ interface CancelExecutionResult {
3506
+ cancelled: boolean;
3507
+ method: string;
3508
+ resourceId: string;
3509
+ executionId: string;
3510
+ }
3511
+ /**
3512
+ * Cancel a running execution.
3513
+ * Invalidates both the execution detail and the executions list on success.
3514
+ *
3515
+ * @example
3516
+ * const { mutate: cancel, isPending } = useCancelExecution()
3517
+ * cancel({ resourceId, executionId })
3518
+ */
3519
+ declare function useCancelExecution(): _tanstack_react_query.UseMutationResult<CancelExecutionResult, Error, CancelExecutionParams, unknown>;
3520
+
3521
+ interface DeleteExecutionParams {
3522
+ resourceId: string;
3523
+ executionId: string;
3524
+ }
3525
+ /**
3526
+ * Delete a single execution record.
3527
+ * Removes the execution from cache immediately and invalidates the list.
3528
+ */
3529
+ declare function useDeleteExecution(): _tanstack_react_query.UseMutationResult<{
3530
+ resourceId: string;
3531
+ executionId: string;
3532
+ }, Error, DeleteExecutionParams, unknown>;
3533
+
3534
+ interface BulkDeleteExecutionsParams {
3535
+ resourceId: string;
3536
+ resourceStatus?: ResourceStatus | 'all';
3537
+ }
3538
+ interface BulkDeleteExecutionsResult {
3539
+ resourceId: string;
3540
+ deletedCount: number;
3541
+ resourceStatus?: ResourceStatus | 'all';
3542
+ }
3543
+ /**
3544
+ * Bulk delete executions for a resource, optionally filtered by status.
3545
+ */
3546
+ declare function useBulkDeleteExecutions(): _tanstack_react_query.UseMutationResult<BulkDeleteExecutionsResult, Error, BulkDeleteExecutionsParams, unknown>;
3547
+
3548
+ /**
3549
+ * Fetch all available Execution Engine resources (workflows, agents, pipelines).
3550
+ *
3551
+ * @example
3552
+ * const { data, isLoading } = useResources()
3553
+ * const workflows = data?.workflows ?? []
3554
+ * const agents = data?.agents ?? []
3555
+ */
3556
+ declare function useResources(): _tanstack_react_query.UseQueryResult<{
3557
+ workflows: ResourceDefinition[];
3558
+ agents: ResourceDefinition[];
3559
+ pipelines: ResourceDefinition[];
3560
+ total: number;
3561
+ }, Error>;
3562
+
3563
+ /**
3564
+ * Fetch a resource definition (workflow steps, agent actions, etc.).
3565
+ *
3566
+ * @param resourceId - The resource ID to fetch
3567
+ * @param enabled - Whether the query should execute (default: true)
3568
+ */
3569
+ declare function useResourceDefinition(resourceId: string, enabled?: boolean): _tanstack_react_query.UseQueryResult<AIResourceDefinition, Error>;
3570
+
3571
+ interface UseActivitiesParams {
3572
+ limit?: number;
3573
+ offset?: number;
3574
+ activityType?: ActivityType;
3575
+ entityType?: string;
3576
+ entityId?: string;
3577
+ startDate?: string;
3578
+ endDate?: string;
3579
+ status?: string;
3580
+ search?: string;
3581
+ }
3582
+ interface ListActivitiesResponse {
3583
+ activities: Activity[];
3584
+ total: number;
3585
+ }
3586
+ /**
3587
+ * Fetch activities with filtering and pagination
3588
+ *
3589
+ * @example
3590
+ * // Basic usage - fetch recent activities
3591
+ * const { data, error, isLoading } = useActivities({ limit: 50 })
3592
+ *
3593
+ * @example
3594
+ * // Filtered by type
3595
+ * const { data } = useActivities({
3596
+ * activityType: 'workflow_execution',
3597
+ * limit: 20
3598
+ * })
3599
+ *
3600
+ * @example
3601
+ * // Filtered by entity
3602
+ * const { data } = useActivities({
3603
+ * entityType: 'workflow',
3604
+ * entityId: 'workflow-123'
3605
+ * })
3606
+ */
3607
+ interface ActivityTrendResponse {
3608
+ timestamps: Date[];
3609
+ total: number;
3610
+ }
3611
+ type UseActivityTrendParams = Omit<UseActivitiesParams, 'limit' | 'offset' | 'search' | 'status'>;
3612
+ /**
3613
+ * Fetch activity timestamps for the Activity Trend chart
3614
+ *
3615
+ * Uses /activities/trend endpoint which returns only occurred_at timestamps
3616
+ * up to ANALYTICS_SAFETY_LIMIT (10,000), bypassing the MAX_PAGE_LIMIT cap.
3617
+ * Provides accurate counts for any time range regardless of activity volume.
3618
+ */
3619
+ declare function useActivityTrend(params?: UseActivityTrendParams): _tanstack_react_query.UseQueryResult<ActivityTrendResponse, Error>;
3620
+ declare function useActivities(params?: UseActivitiesParams): _tanstack_react_query.UseQueryResult<ListActivitiesResponse, Error>;
3621
+
3622
+ interface UseExecutionLogsParams {
3623
+ resourceId?: string;
3624
+ status?: ExecutionStatus$1 | 'all';
3625
+ resourceStatus?: 'dev' | 'prod' | 'all';
3626
+ startDate?: number;
3627
+ endDate?: number;
3628
+ limit?: number;
3629
+ offset?: number;
3630
+ }
3631
+ /**
3632
+ * Response type for cross-resource execution list
3633
+ * Matches backend ExecutionLogsPageResponse in apps/api/src/execution-engine/handlers.ts
3634
+ */
3635
+ interface ExecutionLogsPageResponse {
3636
+ executions: Array<{
3637
+ id: string;
3638
+ resourceId: string;
3639
+ resourceName: string;
3640
+ resourceType: 'workflow' | 'agent' | 'pipeline';
3641
+ status: ExecutionStatus$1;
3642
+ startTime: number;
3643
+ endTime?: number;
3644
+ duration?: number;
3645
+ resourceStatus: 'dev' | 'prod';
3646
+ resourceVersion?: string | null;
3647
+ apiVersion?: string | null;
3648
+ sdkVersion?: string | null;
3649
+ }>;
3650
+ total: number;
3651
+ hasMore: boolean;
3652
+ }
3653
+ /**
3654
+ * Fetch execution logs across all resources with filtering and pagination
3655
+ *
3656
+ * @example
3657
+ * // Basic usage - fetch recent executions
3658
+ * const { data, error, isLoading } = useExecutionLogs({ limit: 50 })
3659
+ *
3660
+ * @example
3661
+ * // Filtered by status
3662
+ * const { data } = useExecutionLogs({
3663
+ * status: 'failed',
3664
+ * limit: 20
3665
+ * })
3666
+ *
3667
+ * @example
3668
+ * // Filtered by resource and date range
3669
+ * const { data } = useExecutionLogs({
3670
+ * resourceId: 'workflow-123',
3671
+ * startDate: Date.now() - 86400000, // Last 24 hours
3672
+ * endDate: Date.now()
3673
+ * })
3674
+ */
3675
+ declare function useExecutionLogs(params?: UseExecutionLogsParams): _tanstack_react_query.UseQueryResult<ExecutionLogsPageResponse, Error>;
3676
+
3677
+ interface UseNotificationsOptions {
3678
+ limit?: number;
3679
+ offset?: number;
3680
+ }
3681
+ declare function useNotifications({ limit, offset }?: UseNotificationsOptions): _tanstack_react_query.UseQueryResult<{
3682
+ notifications: NotificationDTO[];
3683
+ total: number;
3684
+ }, Error>;
3685
+
3686
+ declare function useCostSummary(timeRange: TimeRange): _tanstack_react_query.UseQueryResult<CostSummaryResponse, Error>;
3687
+
3688
+ interface UseExecutionHealthParams {
3689
+ timeRange: TimeRange;
3690
+ }
3691
+ declare function useExecutionHealth({ timeRange }: UseExecutionHealthParams): _tanstack_react_query.UseQueryResult<DashboardMetrics, Error>;
3692
+
3693
+ declare function useMarkAsRead(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
3694
+
3695
+ declare function useMarkAllAsRead(): _tanstack_react_query.UseMutationResult<void, Error, void, unknown>;
3696
+
3697
+ /**
3698
+ * API-only hook for unread notification count.
3699
+ *
3700
+ * For SSE-enhanced real-time counts, consumers should provide
3701
+ * the count via props (e.g., NotificationBell's `unreadCount` prop).
3702
+ */
3703
+ declare function useNotificationCount(): _tanstack_react_query.UseQueryResult<number, Error>;
3704
+
3705
+ /**
3706
+ * Hook that provides a standardized error notification handler
3707
+ * for use in React Query mutation hooks.
3708
+ *
3709
+ * Delegates to the active NotificationAdapter so it works in any
3710
+ * consumer (Mantine, Sonner, console fallback, etc.)
3711
+ *
3712
+ * @example
3713
+ * ```typescript
3714
+ * const mutation = useMutation({
3715
+ * mutationFn: deleteApiKey,
3716
+ * onError: useErrorNotification()
3717
+ * })
3718
+ * ```
3719
+ */
3720
+ declare function useErrorNotification(): (error: unknown) => void;
3721
+
3722
+ /**
3723
+ * Hook that provides a standardized success notification handler.
3724
+ * Delegates to the active NotificationAdapter.
3725
+ */
3726
+ declare function useSuccessNotification(): (title: string, message: string) => void;
3727
+
3728
+ /**
3729
+ * Hook that provides a standardized warning notification handler.
3730
+ * Delegates to the active NotificationAdapter.
3731
+ */
3732
+ declare function useWarningNotification(): (title: string, message: string) => void;
3733
+
3734
+ /**
3735
+ * Generic batch delete hook. Deletes multiple rows from a Supabase table by ID.
3736
+ *
3737
+ * @param tableName - Supabase table name (e.g. 'acq_social_posts')
3738
+ * @param invalidateQueryKeys - Array of query key prefixes to invalidate on success
3739
+ */
3740
+ declare function useBatchDelete(tableName: string, invalidateQueryKeys: readonly (readonly unknown[])[]): _tanstack_react_query.UseMutationResult<void, Error, string[], unknown>;
3741
+
3742
+ /**
3743
+ * Query key factories for observability hooks.
3744
+ * Scoped by organizationId for cache isolation between tenants.
3745
+ */
3746
+ declare const observabilityKeys: {
3747
+ all: readonly ["observability"];
3748
+ errorAnalysis: (organizationId: string | null, timeRange: string) => readonly ["observability", "error-analysis", string | null, string];
3749
+ errorDetails: (organizationId: string | null, filters: object) => readonly ["observability", "error-details", string | null, object];
3750
+ errorDetail: (organizationId: string | null, executionId: string | null) => readonly ["observability", "error-detail", string | null, string | null];
3751
+ errorTrends: (organizationId: string | null, startDate: string, endDate: string, granularity: string) => readonly ["observability", "error-trends", string | null, string, string, string];
3752
+ errorDistribution: (organizationId: string | null, startDate: string, endDate: string, groupBy: string) => readonly ["observability", "error-distribution", string | null, string, string, string];
3753
+ topFailingResources: (organizationId: string | null, startDate: string, endDate: string, limit: number) => readonly ["observability", "top-failing-resources", string | null, string, string, number];
3754
+ costTrends: (organizationId: string | null, timeRange: string, granularity: string) => readonly ["observability", "cost-trends", string | null, string, string];
3755
+ costByModel: (organizationId: string | null, timeRange: string) => readonly ["observability", "cost-by-model", string | null, string];
3756
+ costBreakdown: (organizationId: string | null, timeRange: string) => readonly ["observability", "cost-breakdown", string | null, string];
3757
+ dashboardMetrics: (organizationId: string | null, timeRange: string) => readonly ["observability", "dashboard-metrics", string | null, string];
3758
+ businessImpact: (organizationId: string | null, timeRange: string) => readonly ["observability", "business-impact", string | null, string];
3759
+ };
3760
+
3761
+ declare function useErrorAnalysis(timeRange: TimeRange): _tanstack_react_query.UseQueryResult<ErrorAnalysisMetrics, Error>;
3762
+
3763
+ interface ErrorFilters {
3764
+ errorType?: string;
3765
+ severity?: 'critical' | 'warning' | 'info';
3766
+ search?: string;
3767
+ startDate?: string;
3768
+ endDate?: string;
3769
+ page?: number;
3770
+ limit?: number;
3771
+ /** When true, show only resolved errors. When false, show only unresolved. Omit to show all. */
3772
+ resolved?: boolean;
3773
+ }
3774
+ declare function useErrorDetails(filters: ErrorFilters): _tanstack_react_query.UseQueryResult<ErrorDetailResponse, Error>;
3775
+ declare function useErrorDetail(executionId: string | null): _tanstack_react_query.UseQueryResult<ErrorDetailFull[] | null, Error>;
3776
+
3777
+ interface ErrorTrendsParams {
3778
+ startDate: string;
3779
+ endDate: string;
3780
+ granularity: 'hour' | 'day';
3781
+ }
3782
+ declare function useErrorTrends({ startDate, endDate, granularity }: ErrorTrendsParams): _tanstack_react_query.UseQueryResult<ErrorTrend[], Error>;
3783
+
3784
+ interface ErrorDistributionParams {
3785
+ startDate: string;
3786
+ endDate: string;
3787
+ groupBy: 'errorType' | 'resource' | 'severity';
3788
+ }
3789
+ interface ErrorDistributionItem {
3790
+ label: string;
3791
+ count: number;
3792
+ percentage: number;
3793
+ }
3794
+ declare function useErrorDistribution({ startDate, endDate, groupBy }: ErrorDistributionParams): _tanstack_react_query.UseQueryResult<ErrorDistributionItem[], Error>;
3795
+
3796
+ interface TopFailingResourcesParams {
3797
+ startDate: string;
3798
+ endDate: string;
3799
+ limit?: number;
3800
+ }
3801
+ interface FailingResource {
3802
+ resourceId: string;
3803
+ resourceType: string;
3804
+ errorCount: number;
3805
+ failureRate: number;
3806
+ }
3807
+ declare function useTopFailingResources({ startDate, endDate, limit }: TopFailingResourcesParams): _tanstack_react_query.UseQueryResult<FailingResource[], Error>;
3808
+
3809
+ /**
3810
+ * Resolve a single error by ID.
3811
+ */
3812
+ declare function useResolveError(): _tanstack_react_query.UseMutationResult<unknown, Error, string, unknown>;
3813
+ /**
3814
+ * Unresolve a previously resolved error.
3815
+ */
3816
+ declare function useUnresolveError(): _tanstack_react_query.UseMutationResult<unknown, Error, string, unknown>;
3817
+ /**
3818
+ * Resolve all errors in the organization.
3819
+ */
3820
+ declare function useResolveAllErrors(): _tanstack_react_query.UseMutationResult<unknown, Error, void, unknown>;
3821
+ /**
3822
+ * Resolve all errors for a specific execution.
3823
+ */
3824
+ declare function useResolveErrorsByExecution(): _tanstack_react_query.UseMutationResult<unknown, Error, string, unknown>;
3825
+
3826
+ declare function useCostTrends(timeRange: TimeRange, granularity?: 'hour' | 'day' | 'week'): _tanstack_react_query.UseQueryResult<CostTrendsResponse, Error>;
3827
+
3828
+ declare function useCostByModel(timeRange: TimeRange): _tanstack_react_query.UseQueryResult<CostByModelResponse, Error>;
3829
+
3830
+ interface CostBreakdownItem {
3831
+ resourceId: string;
3832
+ resourceType: string;
3833
+ model: string;
3834
+ totalCost: number;
3835
+ executionCount: number;
3836
+ }
3837
+ declare function useCostBreakdown(timeRange: TimeRange): _tanstack_react_query.UseQueryResult<CostBreakdownItem[], Error>;
3838
+
3839
+ declare function useDashboardMetrics(timeRange: TimeRange): _tanstack_react_query.UseQueryResult<unknown, Error>;
3840
+
3841
+ interface BusinessImpactMetrics {
3842
+ totalExecutions: number;
3843
+ estimatedTimeSavedMinutes: number;
3844
+ estimatedCostSavings: number;
3845
+ automationROI: number;
3846
+ }
3847
+ declare function useBusinessImpact(timeRange: TimeRange): _tanstack_react_query.UseQueryResult<BusinessImpactMetrics, Error>;
3848
+
3849
+ /**
3850
+ * Query key factory for schedule cache management.
3851
+ * Provides type-safe, hierarchical keys for TanStack Query.
3852
+ * Uses organizationId (UUID) for tenant-scoped cache isolation.
3853
+ */
3854
+ declare const scheduleKeys: {
3855
+ all: (orgId: string | null) => readonly ["schedules", string | null];
3856
+ lists: (orgId: string | null) => readonly ["schedules", string | null, "list"];
3857
+ list: (orgId: string | null, filters?: ListSchedulesFilters) => readonly ["schedules", string | null, "list", ListSchedulesFilters | undefined];
3858
+ details: (orgId: string | null) => readonly ["schedules", string | null, "detail"];
3859
+ detail: (orgId: string | null, id: string) => readonly ["schedules", string | null, "detail", string];
3860
+ executions: (orgId: string | null, id: string) => readonly ["schedules", string | null, "detail", string, "executions"];
3861
+ };
3862
+ /**
3863
+ * Filters for list schedules query.
3864
+ * Mirrors ListSchedulesQuery from @repo/core but typed for UI consumption.
3865
+ */
3866
+ interface ListSchedulesFilters {
3867
+ status?: 'active' | 'paused' | 'completed' | 'cancelled';
3868
+ targetResourceType?: 'agent' | 'workflow';
3869
+ targetResourceId?: string;
3870
+ limit?: number;
3871
+ offset?: number;
3872
+ }
3873
+
3874
+ interface CreateScheduleInput {
3875
+ name: string;
3876
+ description?: string;
3877
+ target: {
3878
+ resourceType: 'agent' | 'workflow';
3879
+ resourceId: string;
3880
+ };
3881
+ scheduleConfig: TaskScheduleConfig;
3882
+ maxRetries?: number;
3883
+ idempotencyKey?: string;
3884
+ originExecutionId?: string;
3885
+ originResourceType?: 'agent' | 'workflow' | 'scheduler' | 'api';
3886
+ originResourceId?: string;
3887
+ }
3888
+ interface UpdateScheduleInput {
3889
+ id: string;
3890
+ name?: string;
3891
+ description?: string | null;
3892
+ scheduleConfig?: TaskScheduleConfig;
3893
+ maxRetries?: number;
3894
+ }
3895
+ /** List response using domain type for CC compatibility. */
3896
+ interface ListSchedulesResponse {
3897
+ schedules: TaskSchedule[];
3898
+ total: number;
3899
+ limit: number;
3900
+ offset: number;
3901
+ }
3902
+ /**
3903
+ * List schedules with optional filters.
3904
+ *
3905
+ * @param filters - Optional filters for status, target resource, and pagination
3906
+ * @returns TanStack Query result with schedules array and pagination info
3907
+ *
3908
+ * @example
3909
+ * ```tsx
3910
+ * const { data, isLoading } = useListSchedules({ status: 'active', limit: 20 })
3911
+ * ```
3912
+ */
3913
+ declare function useListSchedules(filters?: ListSchedulesFilters): _tanstack_react_query.UseQueryResult<ListSchedulesResponse, Error>;
3914
+ /**
3915
+ * Get a single schedule by ID.
3916
+ *
3917
+ * @param id - Schedule UUID (undefined to disable query)
3918
+ * @returns TanStack Query result with schedule data
3919
+ *
3920
+ * @example
3921
+ * ```tsx
3922
+ * const { data: schedule, isLoading } = useGetSchedule(scheduleId)
3923
+ * ```
3924
+ */
3925
+ declare function useGetSchedule(id: string | undefined): _tanstack_react_query.UseQueryResult<TaskSchedule, Error>;
3926
+ /**
3927
+ * Get execution history for a schedule.
3928
+ *
3929
+ * @param scheduleId - Schedule UUID (undefined to disable query)
3930
+ * @param options - Pagination options (limit, offset)
3931
+ * @returns TanStack Query result with execution history and pagination info
3932
+ *
3933
+ * @example
3934
+ * ```tsx
3935
+ * const { data } = useGetExecutionHistory(scheduleId, { limit: 10 })
3936
+ * ```
3937
+ */
3938
+ declare function useGetExecutionHistory(scheduleId: string | undefined, options?: {
3939
+ limit?: number;
3940
+ offset?: number;
3941
+ }): _tanstack_react_query.UseQueryResult<{
3942
+ executions: {
3943
+ id: string;
3944
+ createdAt: string;
3945
+ status: "completed" | "failed" | "running" | "cancelled";
3946
+ step: number | null;
3947
+ itemLabel: string | null;
3948
+ duration: number | null;
3949
+ error: string | null;
3950
+ }[];
3951
+ total: number;
3952
+ limit: number;
3953
+ offset: number;
3954
+ }, Error>;
3955
+ /**
3956
+ * Create a new schedule.
3957
+ *
3958
+ * @returns TanStack Mutation for creating schedules
3959
+ *
3960
+ * @example
3961
+ * ```tsx
3962
+ * const createSchedule = useCreateSchedule()
3963
+ *
3964
+ * createSchedule.mutate({
3965
+ * name: 'Daily Report',
3966
+ * target: { resourceType: 'workflow', resourceId: 'wf-123' },
3967
+ * scheduleConfig: { type: 'recurring', cron: '0 9 * * *', timezone: 'UTC', payload: {} }
3968
+ * })
3969
+ * ```
3970
+ */
3971
+ declare function useCreateSchedule(): _tanstack_react_query.UseMutationResult<TaskSchedule, Error, CreateScheduleInput, unknown>;
3972
+ /**
3973
+ * Update schedule fields (name, description, scheduleConfig, maxRetries).
3974
+ * Only active or paused schedules can be updated.
3975
+ *
3976
+ * @returns TanStack Mutation for updating schedules
3977
+ *
3978
+ * @example
3979
+ * ```tsx
3980
+ * const updateSchedule = useUpdateSchedule()
3981
+ *
3982
+ * updateSchedule.mutate({ id: 'schedule-123', name: 'Updated Name' })
3983
+ * ```
3984
+ */
3985
+ declare function useUpdateSchedule(): _tanstack_react_query.UseMutationResult<TaskSchedule, Error, UpdateScheduleInput, unknown>;
3986
+ /**
3987
+ * Update anchor datetime for relative schedules.
3988
+ * Only applicable to schedules with type: 'relative'.
3989
+ *
3990
+ * @returns TanStack Mutation for updating schedule anchor
3991
+ *
3992
+ * @example
3993
+ * ```tsx
3994
+ * const updateAnchor = useUpdateAnchor()
3995
+ *
3996
+ * updateAnchor.mutate({ id: 'schedule-123', anchorAt: '2026-02-01T09:00:00Z' })
3997
+ * ```
3998
+ */
3999
+ declare function useUpdateAnchor(): _tanstack_react_query.UseMutationResult<TaskSchedule, Error, {
4000
+ id: string;
4001
+ anchorAt: string;
4002
+ }, unknown>;
4003
+ /**
4004
+ * Pause a schedule.
4005
+ * Paused schedules will not execute until resumed.
4006
+ *
4007
+ * @returns TanStack Mutation for pausing schedules
4008
+ *
4009
+ * @example
4010
+ * ```tsx
4011
+ * const pauseSchedule = usePauseSchedule()
4012
+ * pauseSchedule.mutate('schedule-123')
4013
+ * ```
4014
+ */
4015
+ declare function usePauseSchedule(): _tanstack_react_query.UseMutationResult<TaskSchedule, Error, string, unknown>;
4016
+ /**
4017
+ * Resume a paused schedule.
4018
+ *
4019
+ * @returns TanStack Mutation for resuming schedules
4020
+ *
4021
+ * @example
4022
+ * ```tsx
4023
+ * const resumeSchedule = useResumeSchedule()
4024
+ * resumeSchedule.mutate('schedule-123')
4025
+ * ```
4026
+ */
4027
+ declare function useResumeSchedule(): _tanstack_react_query.UseMutationResult<TaskSchedule, Error, string, unknown>;
4028
+ /**
4029
+ * Cancel a schedule permanently (soft delete).
4030
+ * Sets status to 'cancelled' -- schedule remains in DB for history.
4031
+ * Cancelled schedules cannot be resumed.
4032
+ *
4033
+ * @returns TanStack Mutation for cancelling schedules
4034
+ *
4035
+ * @example
4036
+ * ```tsx
4037
+ * const cancelSchedule = useCancelSchedule()
4038
+ * cancelSchedule.mutate('schedule-123')
4039
+ * ```
4040
+ */
4041
+ declare function useCancelSchedule(): _tanstack_react_query.UseMutationResult<TaskSchedule, Error, string, unknown>;
4042
+ /**
4043
+ * Delete a schedule permanently (hard delete).
4044
+ * Removes schedule from database entirely.
4045
+ *
4046
+ * @returns TanStack Mutation for deleting schedules
4047
+ *
4048
+ * @example
4049
+ * ```tsx
4050
+ * const deleteSchedule = useDeleteSchedule()
4051
+ * deleteSchedule.mutate('schedule-123')
4052
+ * ```
4053
+ */
4054
+ declare function useDeleteSchedule(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
4055
+
4056
+ interface SessionListItem {
4057
+ sessionId: string;
4058
+ resourceId: string;
4059
+ turnCount: number;
4060
+ isEnded: boolean;
4061
+ createdAt: Date;
4062
+ updatedAt: Date;
4063
+ }
4064
+ interface CreateSessionResponse {
4065
+ sessionId: string;
4066
+ resourceId: string;
4067
+ turnCount: number;
4068
+ createdAt: string;
4069
+ }
4070
+ /**
4071
+ * Response type from the /api/dev/execution-engine/resources endpoint
4072
+ */
4073
+ interface ResourcesResponse {
4074
+ workflows: ResourceDefinition[];
4075
+ agents: ResourceDefinition[];
4076
+ pipelines: ResourceDefinition[];
4077
+ }
4078
+ /**
4079
+ * Operations Service for fetching Execution Engine resources
4080
+ */
4081
+ declare class OperationsService {
4082
+ private apiRequest;
4083
+ constructor(apiRequest: <T>(endpoint: string, options?: RequestInit) => Promise<T>);
4084
+ /**
4085
+ * Fetch all available Execution Engine resources
4086
+ * Uses the unified /list-resources endpoint
4087
+ */
4088
+ getResources(): Promise<ResourcesResponse>;
4089
+ /**
4090
+ * Get detailed workflow information
4091
+ * Optional: For future detailed views
4092
+ */
4093
+ getWorkflowDetails(): Promise<ResourceDefinition[]>;
4094
+ /**
4095
+ * Get detailed agent information
4096
+ * Optional: For future detailed views
4097
+ */
4098
+ getAgentDetails(): Promise<ResourceDefinition[]>;
4099
+ /**
4100
+ * Get detailed pipeline information
4101
+ * Optional: For future detailed views
4102
+ */
4103
+ getPipelineDetails(): Promise<ResourceDefinition[]>;
4104
+ /**
4105
+ * Get resource definition (workflow steps, agent actions, pipeline stages, etc.)
4106
+ */
4107
+ getResourceDefinition(resourceId: string): Promise<AIResourceDefinition>;
4108
+ /**
4109
+ * List sessions with optional filtering
4110
+ */
4111
+ listSessions(params?: {
4112
+ resourceId?: string;
4113
+ }): Promise<SessionListItem[]>;
4114
+ /**
4115
+ * Get session details by ID
4116
+ */
4117
+ getSession(sessionId: string): Promise<SessionDTO>;
4118
+ /**
4119
+ * Create a new session for an agent
4120
+ */
4121
+ createSession(resourceId: string): Promise<CreateSessionResponse>;
4122
+ /**
4123
+ * Archive a session
4124
+ */
4125
+ archiveSession(sessionId: string): Promise<void>;
4126
+ }
4127
+
4128
+ /**
4129
+ * Shared hook for pagination state management.
4130
+ * Encapsulates page state, offset calculation, and reset-on-filter-change.
4131
+ *
4132
+ * @param pageSize - Number of items per page
4133
+ * @param resetDeps - When any dependency changes, page resets to 1. Omit to disable auto-reset.
4134
+ * @param total - When provided, automatically retreats to the last valid page if the current page becomes empty (e.g., after bulk deletion).
4135
+ */
4136
+ declare function usePaginationState(pageSize: number, resetDeps?: unknown[], total?: number): {
4137
+ page: number;
4138
+ setPage: react.Dispatch<react.SetStateAction<number>>;
4139
+ offset: number;
4140
+ totalPages: (total: number) => number;
4141
+ };
4142
+
4143
+ /**
4144
+ * Generic table row selection hook.
4145
+ * Tracks selected IDs, provides toggle/toggleAll/clear, and computes selection state.
4146
+ *
4147
+ * @param items - Current page items (must have `id: string`)
4148
+ * @param allItems - All items across all pages (for "select all" to work across pages). Defaults to `items`.
4149
+ */
4150
+ declare function useTableSelection<T extends {
4151
+ id: string;
4152
+ }>(items: T[], allItems?: T[]): {
4153
+ selectedIds: Set<string>;
4154
+ toggle: (id: string) => void;
4155
+ togglePage: () => void;
4156
+ clear: () => void;
4157
+ isPageAllSelected: boolean;
4158
+ isPagePartiallySelected: boolean;
4159
+ selectedCount: number;
4160
+ isSelected: (id: string) => boolean;
4161
+ };
4162
+
4163
+ type SortDirection = 'asc' | 'desc';
4164
+ interface SortState {
4165
+ column: string;
4166
+ direction: SortDirection;
4167
+ }
4168
+ /**
4169
+ * Generic table sorting hook.
4170
+ * Manages sort column + direction, and provides a sort utility for client-side data.
4171
+ */
4172
+ declare function useTableSort(defaultColumn: string, defaultDirection?: SortDirection): {
4173
+ sort: SortState;
4174
+ toggleSort: (column: string) => void;
4175
+ };
4176
+ /**
4177
+ * Sort an array of items by a column using accessor functions.
4178
+ *
4179
+ * @param data - Array to sort (not mutated)
4180
+ * @param sort - Current sort state
4181
+ * @param accessors - Map of column name → accessor function
4182
+ */
4183
+ declare function sortData<T>(data: T[], sort: SortState, accessors: Record<string, (item: T) => string | number | boolean | null | undefined>): T[];
4184
+ /**
4185
+ * Hook that combines useTableSort with memoized sortData.
4186
+ * Returns the sort state, toggle function, and a memoized sort function.
4187
+ */
4188
+ declare function useSortedData<T>(data: T[], defaultColumn: string, accessors: Record<string, (item: T) => string | number | boolean | null | undefined>, defaultDirection?: SortDirection): {
4189
+ sorted: T[];
4190
+ sort: SortState;
4191
+ toggleSort: (column: string) => void;
4192
+ };
4193
+
4194
+ interface InitializationError {
4195
+ layer: 'auth' | 'profile' | 'organization';
4196
+ message: string;
4197
+ originalError?: Error;
4198
+ }
4199
+ interface AppInitializationState {
4200
+ userReady: boolean;
4201
+ organizationReady: boolean;
4202
+ allReady: boolean;
4203
+ isInitializing: boolean;
4204
+ error: InitializationError | null;
4205
+ retry: () => void;
4206
+ profile: SupabaseUserProfile | null;
4207
+ }
4208
+
4209
+ /**
4210
+ * The value exposed by OrganizationProvider to all consumers.
4211
+ */
4212
+ interface OrganizationContextValue {
4213
+ /** WorkOS organization ID of the currently selected organization. */
4214
+ currentWorkOSOrganizationId: string | null;
4215
+ /** Supabase (UUID) organization ID of the currently selected organization. */
4216
+ currentSupabaseOrganizationId: string | null;
4217
+ /** Full membership record for the currently selected organization. */
4218
+ currentMembership: MembershipWithDetails | null;
4219
+ /** All memberships for the authenticated user. */
4220
+ memberships: MembershipWithDetails[];
4221
+ /** True while the initial membership list is being fetched. */
4222
+ isInitializing: boolean;
4223
+ /** True while a subsequent org switch / refresh is in flight. */
4224
+ isOrgRefreshing: boolean;
4225
+ /** Error message if the membership fetch or org switch failed. */
4226
+ error: string | null;
4227
+ /**
4228
+ * Switch the active organization.
4229
+ *
4230
+ * Persists the selection to `last_visited_org` on the user profile and
4231
+ * invalidates all org-scoped TanStack Query cache entries.
4232
+ *
4233
+ * @param workosOrgId - WorkOS organization ID to switch to.
4234
+ */
4235
+ switchOrganization: (workosOrgId: string) => void;
4236
+ /**
4237
+ * Re-fetch memberships and retry org selection after an error.
4238
+ */
4239
+ retry: () => Promise<void>;
4240
+ }
4241
+
4242
+ type RestrictionSource = 'org' | 'membership' | null;
4243
+ interface FeatureAccessResult {
4244
+ allowed: boolean;
4245
+ restrictedBy: RestrictionSource;
4246
+ }
4247
+ /**
4248
+ * Factory that creates a `useFeatureAccess` hook scoped to the consumer's
4249
+ * feature configuration.
4250
+ *
4251
+ * @param useInitialization - Initialization hook providing `profile` and `organizationReady`
4252
+ * @param useOrganization - Organization hook providing `currentMembership`
4253
+ * @param optInFeatures - Feature keys that are disabled by default (must be explicitly enabled)
4254
+ *
4255
+ * @example
4256
+ * ```typescript
4257
+ * // In your app's feature-access module
4258
+ * import { createUseFeatureAccess } from '@repo/ui/hooks'
4259
+ * import { useInitialization } from '@repo/ui/initialization'
4260
+ * import { useOrganization } from '@repo/ui/organization'
4261
+ *
4262
+ * export const useFeatureAccess = createUseFeatureAccess({
4263
+ * useInitialization,
4264
+ * useOrganization,
4265
+ * optInFeatures: ['acquisition', 'calibration'],
4266
+ * })
4267
+ * ```
4268
+ */
4269
+ declare function createUseFeatureAccess({ useInitialization, useOrganization, optInFeatures }: {
4270
+ useInitialization: () => Pick<AppInitializationState, 'profile' | 'organizationReady'>;
4271
+ useOrganization: () => Pick<OrganizationContextValue, 'currentMembership'>;
4272
+ optInFeatures?: string[];
4273
+ }): () => {
4274
+ orgConfig: OrgFeatureConfig | undefined;
4275
+ membershipConfig: OrgFeatureConfig | undefined;
4276
+ userConfig: UserConfig | undefined;
4277
+ hasFeature: (featureKey: string) => boolean;
4278
+ checkFeature: (featureKey: string) => FeatureAccessResult;
4279
+ isReady: boolean;
4280
+ };
4281
+
4282
+ interface EventSourceMessage {
4283
+ id: string;
4284
+ event: string;
4285
+ data: string;
4286
+ retry?: number;
4287
+ }
4288
+
4289
+ interface FetchEventSourceWithTokenRefreshOptions {
4290
+ url: string;
4291
+ getToken: () => Promise<string | undefined>;
4292
+ headers?: Record<string, string>;
4293
+ signal: AbortSignal;
4294
+ /** Delay in ms before reconnecting after token refresh. Defaults to 2000. */
4295
+ tokenRefreshDelayMs?: number;
4296
+ onopen?: (response: Response) => void | Promise<void>;
4297
+ onmessage?: (event: EventSourceMessage) => void;
4298
+ onerror?: (error: unknown) => void;
4299
+ onclose?: () => void;
4300
+ }
4301
+
4302
+ interface SSEConnectionManagerOptions {
4303
+ /** Grace period in ms before closing idle connections. Defaults to 5000. */
4304
+ closeGracePeriodMs?: number;
4305
+ }
4306
+ /**
4307
+ * SSE Connection Manager
4308
+ *
4309
+ * Ensures only ONE SSE connection exists per endpoint, preventing duplicate
4310
+ * connections when components re-render or remount.
4311
+ *
4312
+ * Benefits:
4313
+ * - Prevents resource waste from duplicate connections
4314
+ * - Eliminates race conditions from overlapping connections
4315
+ * - Automatically manages connection lifecycle
4316
+ * - Shares single connection across multiple subscribers
4317
+ */
4318
+ declare class SSEConnectionManager {
4319
+ private connections;
4320
+ private closeGracePeriodMs;
4321
+ constructor(options?: SSEConnectionManagerOptions);
4322
+ /**
4323
+ * Subscribe to an SSE endpoint
4324
+ *
4325
+ * If a connection already exists for this endpoint, reuses it.
4326
+ * Otherwise, creates a new connection.
4327
+ *
4328
+ * @param key - Unique identifier for the connection (e.g., 'notifications', 'resource-executive-agent')
4329
+ * @param subscriberId - Unique identifier for this subscriber (usually component instance)
4330
+ * @param options - SSE connection options
4331
+ * @returns Unsubscribe function to call when component unmounts
4332
+ */
4333
+ subscribe(key: string, subscriberId: string, options: Omit<FetchEventSourceWithTokenRefreshOptions, 'signal'>): () => void;
4334
+ /**
4335
+ * Unsubscribe from an SSE endpoint
4336
+ *
4337
+ * If this is the last subscriber, closes the connection after grace period.
4338
+ */
4339
+ private unsubscribe;
4340
+ /**
4341
+ * Force close a connection and all its subscribers
4342
+ */
4343
+ closeConnection(key: string): void;
4344
+ /**
4345
+ * Get current connection status
4346
+ */
4347
+ getConnectionInfo(): Map<string, {
4348
+ url: string;
4349
+ subscribers: number;
4350
+ }>;
4351
+ }
4352
+
4353
+ interface UseSSEConnectionOptions {
4354
+ manager: SSEConnectionManager;
4355
+ /** Shared connection key — all subscribers with the same key share ONE connection. */
4356
+ connectionKey: string;
4357
+ url: string;
4358
+ /** When false the subscription is skipped. Defaults to true. */
4359
+ enabled?: boolean;
4360
+ headers?: Record<string, string>;
4361
+ /** Called for each non-empty SSE message with the raw `event.data` string. */
4362
+ onmessage: (data: string) => void;
4363
+ /**
4364
+ * Called when the connection opens. Return a non-empty string to set it as
4365
+ * the error state (e.g. `response.status === 403 ? 'Access denied' : undefined`).
4366
+ */
4367
+ onopen?: (response: Response) => string | void;
4368
+ onerror?: (err: Error) => void;
4369
+ onclose?: () => void;
4370
+ }
4371
+ /**
4372
+ * Generic SSE subscription hook.
4373
+ *
4374
+ * Handles token refresh, connection state, subscriber ID generation, and
4375
+ * subscribe/cleanup lifecycle via the shared SSEConnectionManager.
4376
+ *
4377
+ * Domain-specific event parsing (e.g. `ExecutionSSEEvent`) stays in the
4378
+ * caller's `onmessage` handler.
4379
+ *
4380
+ * @example
4381
+ * ```typescript
4382
+ * const { connected, error } = useSSEConnection({
4383
+ * manager: sseConnectionManager,
4384
+ * connectionKey: `resource-${resourceId}`,
4385
+ * url: `${API_URL}/api/execution-engine/sse/${resourceId}`,
4386
+ * enabled: isOrganizationReady,
4387
+ * headers: { [HTTP_HEADERS.WORKOS_ORGANIZATION_ID]: orgId },
4388
+ * onmessage: (data) => {
4389
+ * const event = JSON.parse(data)
4390
+ * // handle domain-specific event
4391
+ * },
4392
+ * })
4393
+ * ```
4394
+ */
4395
+ declare function useSSEConnection({ manager, connectionKey, url, enabled, headers, onmessage, onopen, onerror, onclose }: UseSSEConnectionOptions): {
4396
+ connected: boolean;
4397
+ error: string | null;
4398
+ };
4399
+
4400
+ export { OperationsService, createUseFeatureAccess, executionsKeys, observabilityKeys, scheduleKeys, sortData, useActivities, useActivityTrend, useBatchDelete, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCommandQueue, useCommandQueueTotals, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateSchedule, useDashboardMetrics, useDeleteExecution, useDeleteSchedule, useDeleteTask, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useErrorTrends, useExecuteAsync, useExecution, useExecutionHealth, useExecutionLogs, useExecutions, useGetExecutionHistory, useGetSchedule, useListSchedules, useMarkAllAsRead, useMarkAsRead, useNotificationCount, useNotifications, usePaginationState, usePatchTask, usePauseSchedule, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResources, useResumeSchedule, useRetryExecution, useSSEConnection, useSortedData, useSubmitAction, useSuccessNotification, useTableSelection, useTableSort, useTopFailingResources, useUnresolveError, useUpdateAnchor, useUpdateSchedule, useWarningNotification };
4401
+ export type { ActivityTrendResponse, BulkDeleteExecutionsParams, BulkDeleteExecutionsResult, BusinessImpactMetrics, CancelExecutionParams, CancelExecutionResult, CostBreakdownItem, CreateScheduleInput, CreateSessionResponse, DeleteExecutionParams, ErrorDistributionItem, ErrorDistributionParams, ErrorFilters, ErrorTrendsParams, ExecuteAsyncParams, ExecuteAsyncResult, ExecutionErrorDetails, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogsPageResponse, FailingResource, ListActivitiesResponse, ListSchedulesFilters, ListSchedulesResponse, ResourcesResponse, RetryExecutionParams, SessionListItem, SortDirection, SortState, SubmitActionRequest, SubmitActionResponse, TaskSchedule, TopFailingResourcesParams, UpdateScheduleInput, UseActivitiesParams, UseActivityTrendParams, UseExecutionHealthParams, UseExecutionLogsParams, UseSSEConnectionOptions };