@elevasis/ui 1.3.4 → 1.3.6

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