@elevasis/ui 1.3.5 → 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.
@@ -0,0 +1,3403 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Workflow-specific logging types and utilities
5
+ */
6
+
7
+ interface WorkflowExecutionContext {
8
+ type: 'workflow';
9
+ contextType: 'workflow-execution';
10
+ executionId: string;
11
+ workflowId: string;
12
+ workflowName?: string;
13
+ organizationId: string;
14
+ executionPath?: string[];
15
+ }
16
+ interface WorkflowFailureContext {
17
+ type: 'workflow';
18
+ contextType: 'workflow-failure';
19
+ executionId: string;
20
+ workflowId: string;
21
+ error: string;
22
+ }
23
+ interface StepStartedContext {
24
+ type: 'workflow';
25
+ contextType: 'step-started';
26
+ stepId: string;
27
+ stepStatus: 'started';
28
+ input: unknown;
29
+ startTime: number;
30
+ }
31
+ interface StepCompletedContext {
32
+ type: 'workflow';
33
+ contextType: 'step-completed';
34
+ stepId: string;
35
+ stepStatus: 'completed';
36
+ output: unknown;
37
+ duration: number;
38
+ isTerminal: boolean;
39
+ startTime: number;
40
+ endTime: number;
41
+ }
42
+ interface StepFailedContext {
43
+ type: 'workflow';
44
+ contextType: 'step-failed';
45
+ stepId: string;
46
+ stepStatus: 'failed';
47
+ error: string;
48
+ duration: number;
49
+ startTime: number;
50
+ endTime: number;
51
+ }
52
+ interface ConditionalRouteContext {
53
+ type: 'workflow';
54
+ contextType: 'conditional-route';
55
+ stepId: string;
56
+ target: string;
57
+ error?: string;
58
+ }
59
+ interface ExecutionPathContext {
60
+ type: 'workflow';
61
+ contextType: 'execution-path';
62
+ executionPath: string[];
63
+ }
64
+ type WorkflowLogContext = WorkflowExecutionContext | WorkflowFailureContext | StepStartedContext | StepCompletedContext | StepFailedContext | ConditionalRouteContext | ExecutionPathContext;
65
+
66
+ /**
67
+ * Agent-specific logging types
68
+ * Simplified 2-event model: lifecycle, iteration
69
+ *
70
+ * Design Philosophy:
71
+ * - LIFECYCLE EVENTS: Structural checkpoints (initialization, iteration, completion)
72
+ * - ITERATION EVENTS: Execution activities (reasoning, actions during iterations)
73
+ */
74
+
75
+ /**
76
+ * Agent lifecycle stages
77
+ * Universal checkpoints that apply to all agent executions
78
+ */
79
+ type AgentLifecycle = 'initialization' | 'iteration' | 'completion';
80
+ /**
81
+ * Iteration event types
82
+ * Activities that occur during agent iterations
83
+ */
84
+ type IterationEventType = 'reasoning' | 'action' | 'tool-call';
85
+ /**
86
+ * Base fields shared by all lifecycle events
87
+ */
88
+ interface AgentLifecycleEventBase {
89
+ type: 'agent';
90
+ agentId: string;
91
+ lifecycle: AgentLifecycle;
92
+ sessionId?: string;
93
+ }
94
+ /**
95
+ * Lifecycle started event - emitted when a phase begins
96
+ * REQUIRED: startTime (phase has started, no end yet)
97
+ */
98
+ interface AgentLifecycleStartedEvent extends AgentLifecycleEventBase {
99
+ stage: 'started';
100
+ startTime: number;
101
+ iteration?: number;
102
+ }
103
+ /**
104
+ * Lifecycle completed event - emitted when a phase succeeds
105
+ * REQUIRED: startTime, endTime, duration (phase has finished successfully)
106
+ */
107
+ interface AgentLifecycleCompletedEvent extends AgentLifecycleEventBase {
108
+ stage: 'completed';
109
+ startTime: number;
110
+ endTime: number;
111
+ duration: number;
112
+ iteration?: number;
113
+ attempts?: number;
114
+ memorySize?: {
115
+ sessionMemoryKeys: number;
116
+ historyEntries: number;
117
+ };
118
+ }
119
+ /**
120
+ * Lifecycle failed event - emitted when a phase fails
121
+ * REQUIRED: startTime, endTime, duration, error (phase has finished with error)
122
+ */
123
+ interface AgentLifecycleFailedEvent extends AgentLifecycleEventBase {
124
+ stage: 'failed';
125
+ startTime: number;
126
+ endTime: number;
127
+ duration: number;
128
+ error: string;
129
+ iteration?: number;
130
+ }
131
+ /**
132
+ * Union type for all lifecycle events
133
+ * Discriminated by 'stage' field for type narrowing
134
+ */
135
+ type AgentLifecycleEvent = AgentLifecycleStartedEvent | AgentLifecycleCompletedEvent | AgentLifecycleFailedEvent;
136
+ /**
137
+ * Placeholder data for MVP
138
+ * Will be typed per actionType in future
139
+ */
140
+ interface ActionPlaceholderData {
141
+ message: string;
142
+ }
143
+ /**
144
+ * Iteration event - captures activities during agent iterations
145
+ * Consolidates reasoning (LLM thought process) and actions (tool use, memory ops, etc.)
146
+ */
147
+ interface AgentIterationEvent {
148
+ type: 'agent';
149
+ agentId: string;
150
+ lifecycle: 'iteration';
151
+ eventType: IterationEventType;
152
+ iteration: number;
153
+ sessionId?: string;
154
+ startTime: number;
155
+ endTime: number;
156
+ duration: number;
157
+ output?: string;
158
+ actionType?: string;
159
+ data?: ActionPlaceholderData;
160
+ }
161
+ /**
162
+ * Tool call event - captures individual tool executions during iterations
163
+ * Provides granular timing for each tool invocation
164
+ */
165
+ interface AgentToolCallEvent {
166
+ type: 'agent';
167
+ agentId: string;
168
+ lifecycle: 'iteration';
169
+ eventType: 'tool-call';
170
+ iteration: number;
171
+ sessionId?: string;
172
+ toolName: string;
173
+ startTime: number;
174
+ endTime: number;
175
+ duration: number;
176
+ success: boolean;
177
+ error?: string;
178
+ input?: Record<string, unknown>;
179
+ output?: unknown;
180
+ }
181
+ /**
182
+ * Union type for all agent log contexts
183
+ * 3 event types total (lifecycle, iteration, tool-call)
184
+ */
185
+ type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent;
186
+
187
+ /**
188
+ * Base execution logger for Execution Engine
189
+ */
190
+ type ExecutionLogLevel = 'debug' | 'info' | 'warn' | 'error';
191
+
192
+ type LogContext = WorkflowLogContext | AgentLogContext;
193
+ interface ExecutionLogMessage {
194
+ level: ExecutionLogLevel;
195
+ message: string;
196
+ timestamp: number;
197
+ context?: LogContext;
198
+ }
199
+
200
+ /**
201
+ * Shared form field types for dynamic form generation
202
+ * Used by: Command Queue, Execution Runner UI, future form-based features
203
+ */
204
+ /**
205
+ * Supported form field types for action payloads
206
+ * Maps to Mantine form components
207
+ */
208
+ type FormFieldType$1 = 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | 'richtext';
209
+
210
+ /**
211
+ * Serialized Registry Types
212
+ *
213
+ * Pre-computed JSON-safe types for API responses and Command View.
214
+ * Serialization happens once at API startup, enabling instant response times.
215
+ */
216
+
217
+ /**
218
+ * Serialized form field for API responses
219
+ */
220
+ interface SerializedFormField {
221
+ name: string;
222
+ label: string;
223
+ type: FormFieldType$1;
224
+ defaultValue?: unknown;
225
+ required?: boolean;
226
+ placeholder?: string;
227
+ description?: string;
228
+ options?: Array<{
229
+ label: string;
230
+ value: string | number;
231
+ }>;
232
+ min?: number;
233
+ max?: number;
234
+ }
235
+ /**
236
+ * Serialized form schema for API responses
237
+ */
238
+ interface SerializedFormSchema {
239
+ title?: string;
240
+ description?: string;
241
+ fields: SerializedFormField[];
242
+ layout?: 'vertical' | 'horizontal' | 'grid';
243
+ }
244
+ /**
245
+ * Serialized execution form schema for API responses
246
+ */
247
+ interface SerializedExecutionFormSchema extends SerializedFormSchema {
248
+ fieldMappings?: Record<string, string>;
249
+ submitButton?: {
250
+ label?: string;
251
+ loadingLabel?: string;
252
+ confirmMessage?: string;
253
+ };
254
+ }
255
+ /**
256
+ * Serialized schedule config for API responses
257
+ */
258
+ interface SerializedScheduleConfig {
259
+ enabled: boolean;
260
+ defaultSchedule?: string;
261
+ allowedPatterns?: string[];
262
+ }
263
+ /**
264
+ * Serialized webhook config for API responses
265
+ */
266
+ interface SerializedWebhookConfig {
267
+ enabled: boolean;
268
+ payloadSchema?: unknown;
269
+ }
270
+ /**
271
+ * Serialized execution interface for API responses
272
+ */
273
+ interface SerializedExecutionInterface {
274
+ form: SerializedExecutionFormSchema;
275
+ schedule?: SerializedScheduleConfig;
276
+ webhook?: SerializedWebhookConfig;
277
+ }
278
+ /**
279
+ * Serialized agent definition (JSON-safe)
280
+ * Result of serializeDefinition(AgentDefinition)
281
+ */
282
+ interface SerializedAgentDefinition {
283
+ config: {
284
+ resourceId: string;
285
+ name: string;
286
+ description: string;
287
+ version: string;
288
+ type: 'agent';
289
+ status: 'dev' | 'prod';
290
+ /** Whether this resource is archived and should be excluded from registration and deployment */
291
+ archived?: boolean;
292
+ systemPrompt: string;
293
+ constraints?: {
294
+ maxIterations?: number;
295
+ timeout?: number;
296
+ maxSessionMemoryKeys?: number;
297
+ maxMemoryTokens?: number;
298
+ };
299
+ sessionCapable?: boolean;
300
+ memoryPreferences?: string;
301
+ };
302
+ modelConfig: {
303
+ provider: string;
304
+ model: string;
305
+ apiKey: string;
306
+ temperature: number;
307
+ maxOutputTokens: number;
308
+ topP?: number;
309
+ modelOptions?: Record<string, unknown>;
310
+ };
311
+ contract: {
312
+ inputSchema: object;
313
+ outputSchema?: object;
314
+ };
315
+ tools: Array<{
316
+ name: string;
317
+ description: string;
318
+ inputSchema?: object;
319
+ outputSchema?: object;
320
+ }>;
321
+ knowledgeMap?: {
322
+ nodeCount: number;
323
+ nodes: Array<{
324
+ id: string;
325
+ description: string;
326
+ loaded: boolean;
327
+ hasPrompt: boolean;
328
+ }>;
329
+ };
330
+ metricsConfig?: object;
331
+ interface?: SerializedExecutionInterface;
332
+ }
333
+ /**
334
+ * Serialized workflow definition (JSON-safe)
335
+ * Result of serializeDefinition(WorkflowDefinition)
336
+ */
337
+ interface SerializedWorkflowDefinition {
338
+ config: {
339
+ resourceId: string;
340
+ name: string;
341
+ description: string;
342
+ version: string;
343
+ type: 'workflow';
344
+ status: 'dev' | 'prod';
345
+ /** Whether this resource is archived and should be excluded from registration and deployment */
346
+ archived?: boolean;
347
+ };
348
+ entryPoint: string;
349
+ steps: Array<{
350
+ id: string;
351
+ name: string;
352
+ description: string;
353
+ inputSchema?: object;
354
+ outputSchema?: object;
355
+ next: {
356
+ type: 'linear' | 'conditional';
357
+ target?: string;
358
+ routes?: Array<{
359
+ target: string;
360
+ }>;
361
+ default?: string;
362
+ } | null;
363
+ }>;
364
+ contract: {
365
+ inputSchema: object;
366
+ outputSchema?: object;
367
+ };
368
+ metricsConfig?: object;
369
+ interface?: SerializedExecutionInterface;
370
+ }
371
+
372
+ /**
373
+ * Memory type definitions
374
+ * Types for agent memory management with semantic entry types
375
+ */
376
+ /**
377
+ * Semantic memory entry types
378
+ * Use-case agnostic types that describe the purpose of each entry
379
+ * Memory types mirror action types for clarity and filtering
380
+ */
381
+ type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'delegation-result' | 'error';
382
+ /**
383
+ * Memory entry - represents a single entry in agent memory
384
+ * Stored in agent memory, translated by adapters to vendor-specific formats
385
+ */
386
+ interface MemoryEntry {
387
+ type: MemoryEntryType;
388
+ content: string;
389
+ timestamp: number;
390
+ turnNumber: number | null;
391
+ iterationNumber: number | null;
392
+ }
393
+ /**
394
+ * Agent memory - Self-orchestrated memory with session + working storage
395
+ * Agent has full control over what persists, framework handles auto-compaction
396
+ */
397
+ interface AgentMemory {
398
+ /**
399
+ * Session memory - Persists for session/conversation duration
400
+ * Never auto-trimmed by framework
401
+ * Agent-managed key-value store for critical information
402
+ * Agent provides strings, framework wraps in MemoryEntry
403
+ */
404
+ sessionMemory: Record<string, MemoryEntry>;
405
+ /**
406
+ * Working memory - Execution history
407
+ * Automatically compacted by framework when needed
408
+ * Agent doesn't control compaction
409
+ */
410
+ history: MemoryEntry[];
411
+ }
412
+
413
+ type Json = string | number | boolean | null | {
414
+ [key: string]: Json | undefined;
415
+ } | Json[];
416
+ type Database = {
417
+ __InternalSupabase: {
418
+ PostgrestVersion: "12.2.3 (519615d)";
419
+ };
420
+ public: {
421
+ Tables: {
422
+ acq_companies: {
423
+ Row: {
424
+ attio_company_id: string | null;
425
+ batch_id: string | null;
426
+ category: string | null;
427
+ category_pain: string | null;
428
+ created_at: string;
429
+ domain: string | null;
430
+ enrichment_data: Json | null;
431
+ filter_reason: string | null;
432
+ founded_year: number | null;
433
+ id: string;
434
+ linkedin_url: string | null;
435
+ location_city: string | null;
436
+ location_state: string | null;
437
+ name: string;
438
+ num_employees: number | null;
439
+ organization_id: string;
440
+ pipeline_status: Json;
441
+ segment: string | null;
442
+ source: string | null;
443
+ status: string;
444
+ updated_at: string;
445
+ website: string | null;
446
+ };
447
+ Insert: {
448
+ attio_company_id?: string | null;
449
+ batch_id?: string | null;
450
+ category?: string | null;
451
+ category_pain?: string | null;
452
+ created_at?: string;
453
+ domain?: string | null;
454
+ enrichment_data?: Json | null;
455
+ filter_reason?: string | null;
456
+ founded_year?: number | null;
457
+ id?: string;
458
+ linkedin_url?: string | null;
459
+ location_city?: string | null;
460
+ location_state?: string | null;
461
+ name: string;
462
+ num_employees?: number | null;
463
+ organization_id: string;
464
+ pipeline_status?: Json;
465
+ segment?: string | null;
466
+ source?: string | null;
467
+ status?: string;
468
+ updated_at?: string;
469
+ website?: string | null;
470
+ };
471
+ Update: {
472
+ attio_company_id?: string | null;
473
+ batch_id?: string | null;
474
+ category?: string | null;
475
+ category_pain?: string | null;
476
+ created_at?: string;
477
+ domain?: string | null;
478
+ enrichment_data?: Json | null;
479
+ filter_reason?: string | null;
480
+ founded_year?: number | null;
481
+ id?: string;
482
+ linkedin_url?: string | null;
483
+ location_city?: string | null;
484
+ location_state?: string | null;
485
+ name?: string;
486
+ num_employees?: number | null;
487
+ organization_id?: string;
488
+ pipeline_status?: Json;
489
+ segment?: string | null;
490
+ source?: string | null;
491
+ status?: string;
492
+ updated_at?: string;
493
+ website?: string | null;
494
+ };
495
+ Relationships: [
496
+ {
497
+ foreignKeyName: "acq_companies_organization_id_fkey";
498
+ columns: ["organization_id"];
499
+ isOneToOne: false;
500
+ referencedRelation: "organizations";
501
+ referencedColumns: ["id"];
502
+ }
503
+ ];
504
+ };
505
+ acq_contacts: {
506
+ Row: {
507
+ attio_person_id: string | null;
508
+ batch_id: string | null;
509
+ brochure_first_viewed_at: string | null;
510
+ brochure_view_count: number;
511
+ company_id: string | null;
512
+ created_at: string;
513
+ email: string;
514
+ email_valid: string | null;
515
+ enrichment_data: Json;
516
+ filter_reason: string | null;
517
+ first_name: string | null;
518
+ headline: string | null;
519
+ id: string;
520
+ last_name: string | null;
521
+ linkedin_url: string | null;
522
+ nurture: boolean;
523
+ opening_line: string | null;
524
+ organization_id: string;
525
+ pipeline_status: Json;
526
+ source: string | null;
527
+ source_id: string | null;
528
+ status: string;
529
+ title: string | null;
530
+ updated_at: string;
531
+ };
532
+ Insert: {
533
+ attio_person_id?: string | null;
534
+ batch_id?: string | null;
535
+ brochure_first_viewed_at?: string | null;
536
+ brochure_view_count?: number;
537
+ company_id?: string | null;
538
+ created_at?: string;
539
+ email: string;
540
+ email_valid?: string | null;
541
+ enrichment_data?: Json;
542
+ filter_reason?: string | null;
543
+ first_name?: string | null;
544
+ headline?: string | null;
545
+ id?: string;
546
+ last_name?: string | null;
547
+ linkedin_url?: string | null;
548
+ nurture?: boolean;
549
+ opening_line?: string | null;
550
+ organization_id: string;
551
+ pipeline_status?: Json;
552
+ source?: string | null;
553
+ source_id?: string | null;
554
+ status?: string;
555
+ title?: string | null;
556
+ updated_at?: string;
557
+ };
558
+ Update: {
559
+ attio_person_id?: string | null;
560
+ batch_id?: string | null;
561
+ brochure_first_viewed_at?: string | null;
562
+ brochure_view_count?: number;
563
+ company_id?: string | null;
564
+ created_at?: string;
565
+ email?: string;
566
+ email_valid?: string | null;
567
+ enrichment_data?: Json;
568
+ filter_reason?: string | null;
569
+ first_name?: string | null;
570
+ headline?: string | null;
571
+ id?: string;
572
+ last_name?: string | null;
573
+ linkedin_url?: string | null;
574
+ nurture?: boolean;
575
+ opening_line?: string | null;
576
+ organization_id?: string;
577
+ pipeline_status?: Json;
578
+ source?: string | null;
579
+ source_id?: string | null;
580
+ status?: string;
581
+ title?: string | null;
582
+ updated_at?: string;
583
+ };
584
+ Relationships: [
585
+ {
586
+ foreignKeyName: "acq_contacts_company_id_fkey";
587
+ columns: ["company_id"];
588
+ isOneToOne: false;
589
+ referencedRelation: "acq_companies";
590
+ referencedColumns: ["id"];
591
+ },
592
+ {
593
+ foreignKeyName: "acq_contacts_organization_id_fkey";
594
+ columns: ["organization_id"];
595
+ isOneToOne: false;
596
+ referencedRelation: "organizations";
597
+ referencedColumns: ["id"];
598
+ }
599
+ ];
600
+ };
601
+ acq_content: {
602
+ Row: {
603
+ body: string | null;
604
+ created_at: string;
605
+ id: string;
606
+ organization_id: string;
607
+ pillar: string;
608
+ status: string;
609
+ title: string;
610
+ updated_at: string;
611
+ };
612
+ Insert: {
613
+ body?: string | null;
614
+ created_at?: string;
615
+ id?: string;
616
+ organization_id: string;
617
+ pillar: string;
618
+ status?: string;
619
+ title: string;
620
+ updated_at?: string;
621
+ };
622
+ Update: {
623
+ body?: string | null;
624
+ created_at?: string;
625
+ id?: string;
626
+ organization_id?: string;
627
+ pillar?: string;
628
+ status?: string;
629
+ title?: string;
630
+ updated_at?: string;
631
+ };
632
+ Relationships: [
633
+ {
634
+ foreignKeyName: "acq_content_organization_id_fkey";
635
+ columns: ["organization_id"];
636
+ isOneToOne: false;
637
+ referencedRelation: "organizations";
638
+ referencedColumns: ["id"];
639
+ }
640
+ ];
641
+ };
642
+ acq_content_distributions: {
643
+ Row: {
644
+ adapted_body: string | null;
645
+ checklist: Json | null;
646
+ content_id: string;
647
+ created_at: string;
648
+ format: string;
649
+ id: string;
650
+ media_urls: Json;
651
+ metrics: Json;
652
+ metrics_updated_at: string | null;
653
+ organization_id: string;
654
+ platform: string;
655
+ platform_content: Json | null;
656
+ platform_post_id: string | null;
657
+ platform_url: string | null;
658
+ published_at: string | null;
659
+ status: string;
660
+ updated_at: string;
661
+ };
662
+ Insert: {
663
+ adapted_body?: string | null;
664
+ checklist?: Json | null;
665
+ content_id: string;
666
+ created_at?: string;
667
+ format: string;
668
+ id?: string;
669
+ media_urls?: Json;
670
+ metrics?: Json;
671
+ metrics_updated_at?: string | null;
672
+ organization_id: string;
673
+ platform: string;
674
+ platform_content?: Json | null;
675
+ platform_post_id?: string | null;
676
+ platform_url?: string | null;
677
+ published_at?: string | null;
678
+ status?: string;
679
+ updated_at?: string;
680
+ };
681
+ Update: {
682
+ adapted_body?: string | null;
683
+ checklist?: Json | null;
684
+ content_id?: string;
685
+ created_at?: string;
686
+ format?: string;
687
+ id?: string;
688
+ media_urls?: Json;
689
+ metrics?: Json;
690
+ metrics_updated_at?: string | null;
691
+ organization_id?: string;
692
+ platform?: string;
693
+ platform_content?: Json | null;
694
+ platform_post_id?: string | null;
695
+ platform_url?: string | null;
696
+ published_at?: string | null;
697
+ status?: string;
698
+ updated_at?: string;
699
+ };
700
+ Relationships: [
701
+ {
702
+ foreignKeyName: "acq_content_distributions_content_id_fkey";
703
+ columns: ["content_id"];
704
+ isOneToOne: false;
705
+ referencedRelation: "acq_content";
706
+ referencedColumns: ["id"];
707
+ },
708
+ {
709
+ foreignKeyName: "acq_content_distributions_organization_id_fkey";
710
+ columns: ["organization_id"];
711
+ isOneToOne: false;
712
+ referencedRelation: "organizations";
713
+ referencedColumns: ["id"];
714
+ }
715
+ ];
716
+ };
717
+ acq_deals: {
718
+ Row: {
719
+ activity_log: Json;
720
+ attio_deal_id: string;
721
+ cached_stage: string | null;
722
+ closed_lost_at: string | null;
723
+ closed_lost_reason: string | null;
724
+ contact_email: string;
725
+ contact_id: string | null;
726
+ created_at: string;
727
+ discovery_data: Json | null;
728
+ discovery_submitted_at: string | null;
729
+ discovery_submitted_by: string | null;
730
+ id: string;
731
+ initial_fee: number | null;
732
+ monthly_fee: number | null;
733
+ organization_id: string;
734
+ payment_link_sent_at: string | null;
735
+ payment_received_at: string | null;
736
+ proposal_data: Json | null;
737
+ proposal_generated_at: string | null;
738
+ proposal_pdf_url: string | null;
739
+ proposal_reviewed_at: string | null;
740
+ proposal_reviewed_by: string | null;
741
+ proposal_sent_at: string | null;
742
+ proposal_signed_at: string | null;
743
+ proposal_status: string | null;
744
+ signature_envelope_id: string | null;
745
+ source_list_id: string | null;
746
+ source_type: string | null;
747
+ stripe_payment_id: string | null;
748
+ stripe_payment_link: string | null;
749
+ stripe_payment_link_id: string | null;
750
+ stripe_subscription_id: string | null;
751
+ updated_at: string;
752
+ };
753
+ Insert: {
754
+ activity_log?: Json;
755
+ attio_deal_id: string;
756
+ cached_stage?: string | null;
757
+ closed_lost_at?: string | null;
758
+ closed_lost_reason?: string | null;
759
+ contact_email: string;
760
+ contact_id?: string | null;
761
+ created_at?: string;
762
+ discovery_data?: Json | null;
763
+ discovery_submitted_at?: string | null;
764
+ discovery_submitted_by?: string | null;
765
+ id?: string;
766
+ initial_fee?: number | null;
767
+ monthly_fee?: number | null;
768
+ organization_id: string;
769
+ payment_link_sent_at?: string | null;
770
+ payment_received_at?: string | null;
771
+ proposal_data?: Json | null;
772
+ proposal_generated_at?: string | null;
773
+ proposal_pdf_url?: string | null;
774
+ proposal_reviewed_at?: string | null;
775
+ proposal_reviewed_by?: string | null;
776
+ proposal_sent_at?: string | null;
777
+ proposal_signed_at?: string | null;
778
+ proposal_status?: string | null;
779
+ signature_envelope_id?: string | null;
780
+ source_list_id?: string | null;
781
+ source_type?: string | null;
782
+ stripe_payment_id?: string | null;
783
+ stripe_payment_link?: string | null;
784
+ stripe_payment_link_id?: string | null;
785
+ stripe_subscription_id?: string | null;
786
+ updated_at?: string;
787
+ };
788
+ Update: {
789
+ activity_log?: Json;
790
+ attio_deal_id?: string;
791
+ cached_stage?: string | null;
792
+ closed_lost_at?: string | null;
793
+ closed_lost_reason?: string | null;
794
+ contact_email?: string;
795
+ contact_id?: string | null;
796
+ created_at?: string;
797
+ discovery_data?: Json | null;
798
+ discovery_submitted_at?: string | null;
799
+ discovery_submitted_by?: string | null;
800
+ id?: string;
801
+ initial_fee?: number | null;
802
+ monthly_fee?: number | null;
803
+ organization_id?: string;
804
+ payment_link_sent_at?: string | null;
805
+ payment_received_at?: string | null;
806
+ proposal_data?: Json | null;
807
+ proposal_generated_at?: string | null;
808
+ proposal_pdf_url?: string | null;
809
+ proposal_reviewed_at?: string | null;
810
+ proposal_reviewed_by?: string | null;
811
+ proposal_sent_at?: string | null;
812
+ proposal_signed_at?: string | null;
813
+ proposal_status?: string | null;
814
+ signature_envelope_id?: string | null;
815
+ source_list_id?: string | null;
816
+ source_type?: string | null;
817
+ stripe_payment_id?: string | null;
818
+ stripe_payment_link?: string | null;
819
+ stripe_payment_link_id?: string | null;
820
+ stripe_subscription_id?: string | null;
821
+ updated_at?: string;
822
+ };
823
+ Relationships: [
824
+ {
825
+ foreignKeyName: "acq_deals_contact_id_fkey";
826
+ columns: ["contact_id"];
827
+ isOneToOne: false;
828
+ referencedRelation: "acq_contacts";
829
+ referencedColumns: ["id"];
830
+ },
831
+ {
832
+ foreignKeyName: "acq_deals_organization_id_fkey";
833
+ columns: ["organization_id"];
834
+ isOneToOne: false;
835
+ referencedRelation: "organizations";
836
+ referencedColumns: ["id"];
837
+ },
838
+ {
839
+ foreignKeyName: "acq_deals_source_list_id_fkey";
840
+ columns: ["source_list_id"];
841
+ isOneToOne: false;
842
+ referencedRelation: "acq_lists";
843
+ referencedColumns: ["id"];
844
+ }
845
+ ];
846
+ };
847
+ acq_list_members: {
848
+ Row: {
849
+ added_at: string;
850
+ added_by: string | null;
851
+ contact_id: string;
852
+ id: string;
853
+ list_id: string;
854
+ };
855
+ Insert: {
856
+ added_at?: string;
857
+ added_by?: string | null;
858
+ contact_id: string;
859
+ id?: string;
860
+ list_id: string;
861
+ };
862
+ Update: {
863
+ added_at?: string;
864
+ added_by?: string | null;
865
+ contact_id?: string;
866
+ id?: string;
867
+ list_id?: string;
868
+ };
869
+ Relationships: [
870
+ {
871
+ foreignKeyName: "acq_list_members_contact_id_fkey";
872
+ columns: ["contact_id"];
873
+ isOneToOne: false;
874
+ referencedRelation: "acq_contacts";
875
+ referencedColumns: ["id"];
876
+ },
877
+ {
878
+ foreignKeyName: "acq_list_members_list_id_fkey";
879
+ columns: ["list_id"];
880
+ isOneToOne: false;
881
+ referencedRelation: "acq_lists";
882
+ referencedColumns: ["id"];
883
+ }
884
+ ];
885
+ };
886
+ acq_lists: {
887
+ Row: {
888
+ batch_ids: string[];
889
+ completed_at: string | null;
890
+ created_at: string;
891
+ description: string | null;
892
+ id: string;
893
+ instantly_campaign_id: string | null;
894
+ launched_at: string | null;
895
+ metadata: Json;
896
+ name: string;
897
+ organization_id: string;
898
+ status: string;
899
+ type: string;
900
+ };
901
+ Insert: {
902
+ batch_ids?: string[];
903
+ completed_at?: string | null;
904
+ created_at?: string;
905
+ description?: string | null;
906
+ id?: string;
907
+ instantly_campaign_id?: string | null;
908
+ launched_at?: string | null;
909
+ metadata?: Json;
910
+ name: string;
911
+ organization_id: string;
912
+ status?: string;
913
+ type?: string;
914
+ };
915
+ Update: {
916
+ batch_ids?: string[];
917
+ completed_at?: string | null;
918
+ created_at?: string;
919
+ description?: string | null;
920
+ id?: string;
921
+ instantly_campaign_id?: string | null;
922
+ launched_at?: string | null;
923
+ metadata?: Json;
924
+ name?: string;
925
+ organization_id?: string;
926
+ status?: string;
927
+ type?: string;
928
+ };
929
+ Relationships: [
930
+ {
931
+ foreignKeyName: "acq_lists_organization_id_fkey";
932
+ columns: ["organization_id"];
933
+ isOneToOne: false;
934
+ referencedRelation: "organizations";
935
+ referencedColumns: ["id"];
936
+ }
937
+ ];
938
+ };
939
+ acq_seo_metrics: {
940
+ Row: {
941
+ ai_citations: Json | null;
942
+ avg_position: number | null;
943
+ clicks: number | null;
944
+ created_at: string;
945
+ cta_clicks: number | null;
946
+ ctr: number | null;
947
+ data_point_count: number | null;
948
+ faq_count: number | null;
949
+ form_submissions: number | null;
950
+ id: string;
951
+ impressions: number | null;
952
+ organization_id: string;
953
+ period: string;
954
+ quality_score: number | null;
955
+ readability: number | null;
956
+ scroll_100: number | null;
957
+ scroll_25: number | null;
958
+ scroll_50: number | null;
959
+ scroll_75: number | null;
960
+ seo_page_id: string;
961
+ word_count: number | null;
962
+ };
963
+ Insert: {
964
+ ai_citations?: Json | null;
965
+ avg_position?: number | null;
966
+ clicks?: number | null;
967
+ created_at?: string;
968
+ cta_clicks?: number | null;
969
+ ctr?: number | null;
970
+ data_point_count?: number | null;
971
+ faq_count?: number | null;
972
+ form_submissions?: number | null;
973
+ id?: string;
974
+ impressions?: number | null;
975
+ organization_id: string;
976
+ period: string;
977
+ quality_score?: number | null;
978
+ readability?: number | null;
979
+ scroll_100?: number | null;
980
+ scroll_25?: number | null;
981
+ scroll_50?: number | null;
982
+ scroll_75?: number | null;
983
+ seo_page_id: string;
984
+ word_count?: number | null;
985
+ };
986
+ Update: {
987
+ ai_citations?: Json | null;
988
+ avg_position?: number | null;
989
+ clicks?: number | null;
990
+ created_at?: string;
991
+ cta_clicks?: number | null;
992
+ ctr?: number | null;
993
+ data_point_count?: number | null;
994
+ faq_count?: number | null;
995
+ form_submissions?: number | null;
996
+ id?: string;
997
+ impressions?: number | null;
998
+ organization_id?: string;
999
+ period?: string;
1000
+ quality_score?: number | null;
1001
+ readability?: number | null;
1002
+ scroll_100?: number | null;
1003
+ scroll_25?: number | null;
1004
+ scroll_50?: number | null;
1005
+ scroll_75?: number | null;
1006
+ seo_page_id?: string;
1007
+ word_count?: number | null;
1008
+ };
1009
+ Relationships: [
1010
+ {
1011
+ foreignKeyName: "acq_seo_metrics_organization_id_fkey";
1012
+ columns: ["organization_id"];
1013
+ isOneToOne: false;
1014
+ referencedRelation: "organizations";
1015
+ referencedColumns: ["id"];
1016
+ },
1017
+ {
1018
+ foreignKeyName: "acq_seo_metrics_seo_page_id_fkey";
1019
+ columns: ["seo_page_id"];
1020
+ isOneToOne: false;
1021
+ referencedRelation: "acq_seo_pages";
1022
+ referencedColumns: ["id"];
1023
+ }
1024
+ ];
1025
+ };
1026
+ acq_seo_pages: {
1027
+ Row: {
1028
+ city: string | null;
1029
+ content: Json | null;
1030
+ created_at: string;
1031
+ faq_items: Json | null;
1032
+ hero_image_url: string | null;
1033
+ id: string;
1034
+ internal_links: Json | null;
1035
+ local_data: Json | null;
1036
+ meta_description: string | null;
1037
+ organization_id: string;
1038
+ page_type: string;
1039
+ published_at: string | null;
1040
+ refreshed_at: string | null;
1041
+ schema_markup: Json | null;
1042
+ slug: string;
1043
+ state: string | null;
1044
+ status: string;
1045
+ title: string;
1046
+ updated_at: string;
1047
+ use_case: string | null;
1048
+ vertical: string;
1049
+ };
1050
+ Insert: {
1051
+ city?: string | null;
1052
+ content?: Json | null;
1053
+ created_at?: string;
1054
+ faq_items?: Json | null;
1055
+ hero_image_url?: string | null;
1056
+ id?: string;
1057
+ internal_links?: Json | null;
1058
+ local_data?: Json | null;
1059
+ meta_description?: string | null;
1060
+ organization_id: string;
1061
+ page_type: string;
1062
+ published_at?: string | null;
1063
+ refreshed_at?: string | null;
1064
+ schema_markup?: Json | null;
1065
+ slug: string;
1066
+ state?: string | null;
1067
+ status?: string;
1068
+ title: string;
1069
+ updated_at?: string;
1070
+ use_case?: string | null;
1071
+ vertical: string;
1072
+ };
1073
+ Update: {
1074
+ city?: string | null;
1075
+ content?: Json | null;
1076
+ created_at?: string;
1077
+ faq_items?: Json | null;
1078
+ hero_image_url?: string | null;
1079
+ id?: string;
1080
+ internal_links?: Json | null;
1081
+ local_data?: Json | null;
1082
+ meta_description?: string | null;
1083
+ organization_id?: string;
1084
+ page_type?: string;
1085
+ published_at?: string | null;
1086
+ refreshed_at?: string | null;
1087
+ schema_markup?: Json | null;
1088
+ slug?: string;
1089
+ state?: string | null;
1090
+ status?: string;
1091
+ title?: string;
1092
+ updated_at?: string;
1093
+ use_case?: string | null;
1094
+ vertical?: string;
1095
+ };
1096
+ Relationships: [
1097
+ {
1098
+ foreignKeyName: "acq_seo_pages_organization_id_fkey";
1099
+ columns: ["organization_id"];
1100
+ isOneToOne: false;
1101
+ referencedRelation: "organizations";
1102
+ referencedColumns: ["id"];
1103
+ }
1104
+ ];
1105
+ };
1106
+ acq_social_posts: {
1107
+ Row: {
1108
+ author_name: string;
1109
+ author_url: string | null;
1110
+ comments_count: number;
1111
+ created_at: string;
1112
+ discovered_at: string;
1113
+ engagement_count: number;
1114
+ feedback: string | null;
1115
+ final_response: string | null;
1116
+ fully_reviewed: boolean;
1117
+ id: string;
1118
+ initial_draft: string | null;
1119
+ matched_keywords: string[];
1120
+ matched_query: string | null;
1121
+ metadata: Json;
1122
+ organization_id: string;
1123
+ platform: string;
1124
+ platform_post_id: string;
1125
+ post_text: string;
1126
+ post_title: string;
1127
+ post_url: string;
1128
+ posted_at: string;
1129
+ relevance_score: number;
1130
+ responded_at: string | null;
1131
+ reviewed_at: string | null;
1132
+ skip_reason: string | null;
1133
+ source_category: string | null;
1134
+ status: string;
1135
+ updated_at: string;
1136
+ };
1137
+ Insert: {
1138
+ author_name: string;
1139
+ author_url?: string | null;
1140
+ comments_count?: number;
1141
+ created_at?: string;
1142
+ discovered_at?: string;
1143
+ engagement_count?: number;
1144
+ feedback?: string | null;
1145
+ final_response?: string | null;
1146
+ fully_reviewed?: boolean;
1147
+ id?: string;
1148
+ initial_draft?: string | null;
1149
+ matched_keywords?: string[];
1150
+ matched_query?: string | null;
1151
+ metadata?: Json;
1152
+ organization_id: string;
1153
+ platform: string;
1154
+ platform_post_id: string;
1155
+ post_text: string;
1156
+ post_title: string;
1157
+ post_url: string;
1158
+ posted_at: string;
1159
+ relevance_score?: number;
1160
+ responded_at?: string | null;
1161
+ reviewed_at?: string | null;
1162
+ skip_reason?: string | null;
1163
+ source_category?: string | null;
1164
+ status?: string;
1165
+ updated_at?: string;
1166
+ };
1167
+ Update: {
1168
+ author_name?: string;
1169
+ author_url?: string | null;
1170
+ comments_count?: number;
1171
+ created_at?: string;
1172
+ discovered_at?: string;
1173
+ engagement_count?: number;
1174
+ feedback?: string | null;
1175
+ final_response?: string | null;
1176
+ fully_reviewed?: boolean;
1177
+ id?: string;
1178
+ initial_draft?: string | null;
1179
+ matched_keywords?: string[];
1180
+ matched_query?: string | null;
1181
+ metadata?: Json;
1182
+ organization_id?: string;
1183
+ platform?: string;
1184
+ platform_post_id?: string;
1185
+ post_text?: string;
1186
+ post_title?: string;
1187
+ post_url?: string;
1188
+ posted_at?: string;
1189
+ relevance_score?: number;
1190
+ responded_at?: string | null;
1191
+ reviewed_at?: string | null;
1192
+ skip_reason?: string | null;
1193
+ source_category?: string | null;
1194
+ status?: string;
1195
+ updated_at?: string;
1196
+ };
1197
+ Relationships: [
1198
+ {
1199
+ foreignKeyName: "acq_social_posts_organization_id_fkey";
1200
+ columns: ["organization_id"];
1201
+ isOneToOne: false;
1202
+ referencedRelation: "organizations";
1203
+ referencedColumns: ["id"];
1204
+ }
1205
+ ];
1206
+ };
1207
+ activities: {
1208
+ Row: {
1209
+ activity_type: string;
1210
+ actor_id: string | null;
1211
+ actor_type: string | null;
1212
+ created_at: string;
1213
+ description: string | null;
1214
+ entity_id: string;
1215
+ entity_name: string | null;
1216
+ entity_type: string;
1217
+ id: string;
1218
+ metadata: Json | null;
1219
+ occurred_at: string;
1220
+ organization_id: string;
1221
+ status: string;
1222
+ title: string;
1223
+ };
1224
+ Insert: {
1225
+ activity_type: string;
1226
+ actor_id?: string | null;
1227
+ actor_type?: string | null;
1228
+ created_at?: string;
1229
+ description?: string | null;
1230
+ entity_id: string;
1231
+ entity_name?: string | null;
1232
+ entity_type: string;
1233
+ id?: string;
1234
+ metadata?: Json | null;
1235
+ occurred_at?: string;
1236
+ organization_id: string;
1237
+ status: string;
1238
+ title: string;
1239
+ };
1240
+ Update: {
1241
+ activity_type?: string;
1242
+ actor_id?: string | null;
1243
+ actor_type?: string | null;
1244
+ created_at?: string;
1245
+ description?: string | null;
1246
+ entity_id?: string;
1247
+ entity_name?: string | null;
1248
+ entity_type?: string;
1249
+ id?: string;
1250
+ metadata?: Json | null;
1251
+ occurred_at?: string;
1252
+ organization_id?: string;
1253
+ status?: string;
1254
+ title?: string;
1255
+ };
1256
+ Relationships: [
1257
+ {
1258
+ foreignKeyName: "activities_organization_id_fkey";
1259
+ columns: ["organization_id"];
1260
+ isOneToOne: false;
1261
+ referencedRelation: "organizations";
1262
+ referencedColumns: ["id"];
1263
+ }
1264
+ ];
1265
+ };
1266
+ api_keys: {
1267
+ Row: {
1268
+ created_at: string | null;
1269
+ id: string;
1270
+ key_hash: string;
1271
+ last_used_at: string | null;
1272
+ name: string;
1273
+ organization_id: string;
1274
+ };
1275
+ Insert: {
1276
+ created_at?: string | null;
1277
+ id?: string;
1278
+ key_hash: string;
1279
+ last_used_at?: string | null;
1280
+ name: string;
1281
+ organization_id: string;
1282
+ };
1283
+ Update: {
1284
+ created_at?: string | null;
1285
+ id?: string;
1286
+ key_hash?: string;
1287
+ last_used_at?: string | null;
1288
+ name?: string;
1289
+ organization_id?: string;
1290
+ };
1291
+ Relationships: [
1292
+ {
1293
+ foreignKeyName: "api_keys_organization_id_fkey";
1294
+ columns: ["organization_id"];
1295
+ isOneToOne: false;
1296
+ referencedRelation: "organizations";
1297
+ referencedColumns: ["id"];
1298
+ }
1299
+ ];
1300
+ };
1301
+ calibration_projects: {
1302
+ Row: {
1303
+ created_at: string | null;
1304
+ description: string | null;
1305
+ id: string;
1306
+ name: string;
1307
+ organization_id: string;
1308
+ resource_id: string;
1309
+ resource_type: string;
1310
+ updated_at: string | null;
1311
+ };
1312
+ Insert: {
1313
+ created_at?: string | null;
1314
+ description?: string | null;
1315
+ id?: string;
1316
+ name: string;
1317
+ organization_id: string;
1318
+ resource_id: string;
1319
+ resource_type: string;
1320
+ updated_at?: string | null;
1321
+ };
1322
+ Update: {
1323
+ created_at?: string | null;
1324
+ description?: string | null;
1325
+ id?: string;
1326
+ name?: string;
1327
+ organization_id?: string;
1328
+ resource_id?: string;
1329
+ resource_type?: string;
1330
+ updated_at?: string | null;
1331
+ };
1332
+ Relationships: [
1333
+ {
1334
+ foreignKeyName: "calibration_projects_organization_id_fkey";
1335
+ columns: ["organization_id"];
1336
+ isOneToOne: false;
1337
+ referencedRelation: "organizations";
1338
+ referencedColumns: ["id"];
1339
+ }
1340
+ ];
1341
+ };
1342
+ calibration_runs: {
1343
+ Row: {
1344
+ completed_at: string | null;
1345
+ config_variants: Json;
1346
+ created_at: string | null;
1347
+ description: string | null;
1348
+ execution_mode: string;
1349
+ grader_model: string | null;
1350
+ grading_rubric: Json | null;
1351
+ id: string;
1352
+ name: string;
1353
+ organization_id: string;
1354
+ project_id: string;
1355
+ results: Json;
1356
+ status: string;
1357
+ test_inputs: Json;
1358
+ };
1359
+ Insert: {
1360
+ completed_at?: string | null;
1361
+ config_variants: Json;
1362
+ created_at?: string | null;
1363
+ description?: string | null;
1364
+ execution_mode?: string;
1365
+ grader_model?: string | null;
1366
+ grading_rubric?: Json | null;
1367
+ id?: string;
1368
+ name: string;
1369
+ organization_id: string;
1370
+ project_id: string;
1371
+ results?: Json;
1372
+ status?: string;
1373
+ test_inputs: Json;
1374
+ };
1375
+ Update: {
1376
+ completed_at?: string | null;
1377
+ config_variants?: Json;
1378
+ created_at?: string | null;
1379
+ description?: string | null;
1380
+ execution_mode?: string;
1381
+ grader_model?: string | null;
1382
+ grading_rubric?: Json | null;
1383
+ id?: string;
1384
+ name?: string;
1385
+ organization_id?: string;
1386
+ project_id?: string;
1387
+ results?: Json;
1388
+ status?: string;
1389
+ test_inputs?: Json;
1390
+ };
1391
+ Relationships: [
1392
+ {
1393
+ foreignKeyName: "calibration_runs_organization_id_fkey";
1394
+ columns: ["organization_id"];
1395
+ isOneToOne: false;
1396
+ referencedRelation: "organizations";
1397
+ referencedColumns: ["id"];
1398
+ },
1399
+ {
1400
+ foreignKeyName: "calibration_runs_project_id_fkey";
1401
+ columns: ["project_id"];
1402
+ isOneToOne: false;
1403
+ referencedRelation: "calibration_projects";
1404
+ referencedColumns: ["id"];
1405
+ }
1406
+ ];
1407
+ };
1408
+ command_queue: {
1409
+ Row: {
1410
+ action_payload: Json | null;
1411
+ actions: Json;
1412
+ completed_at: string | null;
1413
+ completed_by: string | null;
1414
+ context: Json;
1415
+ created_at: string;
1416
+ description: string | null;
1417
+ expires_at: string | null;
1418
+ human_checkpoint: string | null;
1419
+ id: string;
1420
+ idempotency_key: string | null;
1421
+ metadata: Json | null;
1422
+ organization_id: string;
1423
+ origin_execution_id: string;
1424
+ origin_resource_id: string;
1425
+ origin_resource_type: string;
1426
+ priority: number;
1427
+ selected_action: string | null;
1428
+ status: string;
1429
+ target_execution_id: string | null;
1430
+ target_resource_id: string | null;
1431
+ target_resource_type: string | null;
1432
+ };
1433
+ Insert: {
1434
+ action_payload?: Json | null;
1435
+ actions: Json;
1436
+ completed_at?: string | null;
1437
+ completed_by?: string | null;
1438
+ context: Json;
1439
+ created_at?: string;
1440
+ description?: string | null;
1441
+ expires_at?: string | null;
1442
+ human_checkpoint?: string | null;
1443
+ id?: string;
1444
+ idempotency_key?: string | null;
1445
+ metadata?: Json | null;
1446
+ organization_id: string;
1447
+ origin_execution_id: string;
1448
+ origin_resource_id: string;
1449
+ origin_resource_type: string;
1450
+ priority?: number;
1451
+ selected_action?: string | null;
1452
+ status?: string;
1453
+ target_execution_id?: string | null;
1454
+ target_resource_id?: string | null;
1455
+ target_resource_type?: string | null;
1456
+ };
1457
+ Update: {
1458
+ action_payload?: Json | null;
1459
+ actions?: Json;
1460
+ completed_at?: string | null;
1461
+ completed_by?: string | null;
1462
+ context?: Json;
1463
+ created_at?: string;
1464
+ description?: string | null;
1465
+ expires_at?: string | null;
1466
+ human_checkpoint?: string | null;
1467
+ id?: string;
1468
+ idempotency_key?: string | null;
1469
+ metadata?: Json | null;
1470
+ organization_id?: string;
1471
+ origin_execution_id?: string;
1472
+ origin_resource_id?: string;
1473
+ origin_resource_type?: string;
1474
+ priority?: number;
1475
+ selected_action?: string | null;
1476
+ status?: string;
1477
+ target_execution_id?: string | null;
1478
+ target_resource_id?: string | null;
1479
+ target_resource_type?: string | null;
1480
+ };
1481
+ Relationships: [
1482
+ {
1483
+ foreignKeyName: "command_queue_completed_by_fkey";
1484
+ columns: ["completed_by"];
1485
+ isOneToOne: false;
1486
+ referencedRelation: "users";
1487
+ referencedColumns: ["id"];
1488
+ },
1489
+ {
1490
+ foreignKeyName: "command_queue_organization_id_fkey";
1491
+ columns: ["organization_id"];
1492
+ isOneToOne: false;
1493
+ referencedRelation: "organizations";
1494
+ referencedColumns: ["id"];
1495
+ },
1496
+ {
1497
+ foreignKeyName: "command_queue_target_execution_id_fkey";
1498
+ columns: ["target_execution_id"];
1499
+ isOneToOne: false;
1500
+ referencedRelation: "execution_logs";
1501
+ referencedColumns: ["execution_id"];
1502
+ }
1503
+ ];
1504
+ };
1505
+ credentials: {
1506
+ Row: {
1507
+ created_at: string;
1508
+ created_by: string | null;
1509
+ encrypted_value: string;
1510
+ id: string;
1511
+ name: string;
1512
+ organization_id: string;
1513
+ provider: string | null;
1514
+ type: string;
1515
+ updated_at: string;
1516
+ };
1517
+ Insert: {
1518
+ created_at?: string;
1519
+ created_by?: string | null;
1520
+ encrypted_value: string;
1521
+ id?: string;
1522
+ name: string;
1523
+ organization_id: string;
1524
+ provider?: string | null;
1525
+ type?: string;
1526
+ updated_at?: string;
1527
+ };
1528
+ Update: {
1529
+ created_at?: string;
1530
+ created_by?: string | null;
1531
+ encrypted_value?: string;
1532
+ id?: string;
1533
+ name?: string;
1534
+ organization_id?: string;
1535
+ provider?: string | null;
1536
+ type?: string;
1537
+ updated_at?: string;
1538
+ };
1539
+ Relationships: [
1540
+ {
1541
+ foreignKeyName: "credentials_created_by_fkey";
1542
+ columns: ["created_by"];
1543
+ isOneToOne: false;
1544
+ referencedRelation: "users";
1545
+ referencedColumns: ["id"];
1546
+ },
1547
+ {
1548
+ foreignKeyName: "credentials_organization_id_fkey";
1549
+ columns: ["organization_id"];
1550
+ isOneToOne: false;
1551
+ referencedRelation: "organizations";
1552
+ referencedColumns: ["id"];
1553
+ }
1554
+ ];
1555
+ };
1556
+ deployments: {
1557
+ Row: {
1558
+ compiled_docs: Json | null;
1559
+ created_at: string;
1560
+ deployment_version: string | null;
1561
+ documentation: Json | null;
1562
+ error_message: string | null;
1563
+ id: string;
1564
+ organization_id: string;
1565
+ pid: number | null;
1566
+ port: number | null;
1567
+ sdk_version: string;
1568
+ status: string;
1569
+ tarball_path: string | null;
1570
+ updated_at: string;
1571
+ };
1572
+ Insert: {
1573
+ compiled_docs?: Json | null;
1574
+ created_at?: string;
1575
+ deployment_version?: string | null;
1576
+ documentation?: Json | null;
1577
+ error_message?: string | null;
1578
+ id?: string;
1579
+ organization_id: string;
1580
+ pid?: number | null;
1581
+ port?: number | null;
1582
+ sdk_version: string;
1583
+ status?: string;
1584
+ tarball_path?: string | null;
1585
+ updated_at?: string;
1586
+ };
1587
+ Update: {
1588
+ compiled_docs?: Json | null;
1589
+ created_at?: string;
1590
+ deployment_version?: string | null;
1591
+ documentation?: Json | null;
1592
+ error_message?: string | null;
1593
+ id?: string;
1594
+ organization_id?: string;
1595
+ pid?: number | null;
1596
+ port?: number | null;
1597
+ sdk_version?: string;
1598
+ status?: string;
1599
+ tarball_path?: string | null;
1600
+ updated_at?: string;
1601
+ };
1602
+ Relationships: [
1603
+ {
1604
+ foreignKeyName: "deployments_organization_id_fkey";
1605
+ columns: ["organization_id"];
1606
+ isOneToOne: false;
1607
+ referencedRelation: "organizations";
1608
+ referencedColumns: ["id"];
1609
+ }
1610
+ ];
1611
+ };
1612
+ execution_errors: {
1613
+ Row: {
1614
+ created_at: string | null;
1615
+ error_category: string;
1616
+ error_message: string;
1617
+ error_severity: string;
1618
+ error_stack_trace: string | null;
1619
+ error_type: string;
1620
+ execution_id: string;
1621
+ id: string;
1622
+ metadata: Json | null;
1623
+ occurred_at: string;
1624
+ organization_id: string;
1625
+ resolved: boolean;
1626
+ resolved_at: string | null;
1627
+ resolved_by: string | null;
1628
+ };
1629
+ Insert: {
1630
+ created_at?: string | null;
1631
+ error_category: string;
1632
+ error_message: string;
1633
+ error_severity: string;
1634
+ error_stack_trace?: string | null;
1635
+ error_type: string;
1636
+ execution_id: string;
1637
+ id?: string;
1638
+ metadata?: Json | null;
1639
+ occurred_at?: string;
1640
+ organization_id: string;
1641
+ resolved?: boolean;
1642
+ resolved_at?: string | null;
1643
+ resolved_by?: string | null;
1644
+ };
1645
+ Update: {
1646
+ created_at?: string | null;
1647
+ error_category?: string;
1648
+ error_message?: string;
1649
+ error_severity?: string;
1650
+ error_stack_trace?: string | null;
1651
+ error_type?: string;
1652
+ execution_id?: string;
1653
+ id?: string;
1654
+ metadata?: Json | null;
1655
+ occurred_at?: string;
1656
+ organization_id?: string;
1657
+ resolved?: boolean;
1658
+ resolved_at?: string | null;
1659
+ resolved_by?: string | null;
1660
+ };
1661
+ Relationships: [
1662
+ {
1663
+ foreignKeyName: "execution_errors_execution_id_fkey";
1664
+ columns: ["execution_id"];
1665
+ isOneToOne: false;
1666
+ referencedRelation: "execution_logs";
1667
+ referencedColumns: ["execution_id"];
1668
+ },
1669
+ {
1670
+ foreignKeyName: "execution_errors_organization_id_fkey";
1671
+ columns: ["organization_id"];
1672
+ isOneToOne: false;
1673
+ referencedRelation: "organizations";
1674
+ referencedColumns: ["id"];
1675
+ },
1676
+ {
1677
+ foreignKeyName: "execution_errors_resolved_by_fkey";
1678
+ columns: ["resolved_by"];
1679
+ isOneToOne: false;
1680
+ referencedRelation: "users";
1681
+ referencedColumns: ["id"];
1682
+ }
1683
+ ];
1684
+ };
1685
+ execution_logs: {
1686
+ Row: {
1687
+ api_version: string | null;
1688
+ completed_at: string | null;
1689
+ created_at: string | null;
1690
+ error: string | null;
1691
+ execution_id: string;
1692
+ input: Json | null;
1693
+ last_heartbeat_at: string | null;
1694
+ logs: Json | null;
1695
+ organization_id: string;
1696
+ origin_execution_id: string | null;
1697
+ output: Json | null;
1698
+ resource_id: string;
1699
+ resource_status: string;
1700
+ resource_type: string;
1701
+ resource_version: string | null;
1702
+ sdk_version: string | null;
1703
+ session_id: string | null;
1704
+ session_turn_number: number | null;
1705
+ started_at: string;
1706
+ status: string;
1707
+ trigger_type: string | null;
1708
+ updated_at: string | null;
1709
+ user_id: string | null;
1710
+ };
1711
+ Insert: {
1712
+ api_version?: string | null;
1713
+ completed_at?: string | null;
1714
+ created_at?: string | null;
1715
+ error?: string | null;
1716
+ execution_id?: string;
1717
+ input?: Json | null;
1718
+ last_heartbeat_at?: string | null;
1719
+ logs?: Json | null;
1720
+ organization_id: string;
1721
+ origin_execution_id?: string | null;
1722
+ output?: Json | null;
1723
+ resource_id: string;
1724
+ resource_status?: string;
1725
+ resource_type?: string;
1726
+ resource_version?: string | null;
1727
+ sdk_version?: string | null;
1728
+ session_id?: string | null;
1729
+ session_turn_number?: number | null;
1730
+ started_at?: string;
1731
+ status: string;
1732
+ trigger_type?: string | null;
1733
+ updated_at?: string | null;
1734
+ user_id?: string | null;
1735
+ };
1736
+ Update: {
1737
+ api_version?: string | null;
1738
+ completed_at?: string | null;
1739
+ created_at?: string | null;
1740
+ error?: string | null;
1741
+ execution_id?: string;
1742
+ input?: Json | null;
1743
+ last_heartbeat_at?: string | null;
1744
+ logs?: Json | null;
1745
+ organization_id?: string;
1746
+ origin_execution_id?: string | null;
1747
+ output?: Json | null;
1748
+ resource_id?: string;
1749
+ resource_status?: string;
1750
+ resource_type?: string;
1751
+ resource_version?: string | null;
1752
+ sdk_version?: string | null;
1753
+ session_id?: string | null;
1754
+ session_turn_number?: number | null;
1755
+ started_at?: string;
1756
+ status?: string;
1757
+ trigger_type?: string | null;
1758
+ updated_at?: string | null;
1759
+ user_id?: string | null;
1760
+ };
1761
+ Relationships: [
1762
+ {
1763
+ foreignKeyName: "execution_history_organization_id_fkey";
1764
+ columns: ["organization_id"];
1765
+ isOneToOne: false;
1766
+ referencedRelation: "organizations";
1767
+ referencedColumns: ["id"];
1768
+ },
1769
+ {
1770
+ foreignKeyName: "execution_logs_origin_execution_id_fkey";
1771
+ columns: ["origin_execution_id"];
1772
+ isOneToOne: false;
1773
+ referencedRelation: "execution_logs";
1774
+ referencedColumns: ["execution_id"];
1775
+ },
1776
+ {
1777
+ foreignKeyName: "execution_logs_session_id_fkey";
1778
+ columns: ["session_id"];
1779
+ isOneToOne: false;
1780
+ referencedRelation: "sessions";
1781
+ referencedColumns: ["session_id"];
1782
+ },
1783
+ {
1784
+ foreignKeyName: "execution_logs_user_id_fkey";
1785
+ columns: ["user_id"];
1786
+ isOneToOne: false;
1787
+ referencedRelation: "users";
1788
+ referencedColumns: ["id"];
1789
+ }
1790
+ ];
1791
+ };
1792
+ execution_metrics: {
1793
+ Row: {
1794
+ ai_call_count: number;
1795
+ ai_calls: Json | null;
1796
+ automation_savings_usd: number | null;
1797
+ created_at: string | null;
1798
+ duration_ms: number | null;
1799
+ execution_id: string;
1800
+ organization_id: string;
1801
+ resource_id: string;
1802
+ total_cost_usd: number;
1803
+ total_input_tokens: number;
1804
+ total_output_tokens: number;
1805
+ };
1806
+ Insert: {
1807
+ ai_call_count: number;
1808
+ ai_calls?: Json | null;
1809
+ automation_savings_usd?: number | null;
1810
+ created_at?: string | null;
1811
+ duration_ms?: number | null;
1812
+ execution_id: string;
1813
+ organization_id: string;
1814
+ resource_id: string;
1815
+ total_cost_usd: number;
1816
+ total_input_tokens: number;
1817
+ total_output_tokens: number;
1818
+ };
1819
+ Update: {
1820
+ ai_call_count?: number;
1821
+ ai_calls?: Json | null;
1822
+ automation_savings_usd?: number | null;
1823
+ created_at?: string | null;
1824
+ duration_ms?: number | null;
1825
+ execution_id?: string;
1826
+ organization_id?: string;
1827
+ resource_id?: string;
1828
+ total_cost_usd?: number;
1829
+ total_input_tokens?: number;
1830
+ total_output_tokens?: number;
1831
+ };
1832
+ Relationships: [
1833
+ {
1834
+ foreignKeyName: "execution_metrics_execution_id_fkey";
1835
+ columns: ["execution_id"];
1836
+ isOneToOne: true;
1837
+ referencedRelation: "execution_logs";
1838
+ referencedColumns: ["execution_id"];
1839
+ },
1840
+ {
1841
+ foreignKeyName: "execution_metrics_organization_id_fkey";
1842
+ columns: ["organization_id"];
1843
+ isOneToOne: false;
1844
+ referencedRelation: "organizations";
1845
+ referencedColumns: ["id"];
1846
+ }
1847
+ ];
1848
+ };
1849
+ notifications: {
1850
+ Row: {
1851
+ action_url: string | null;
1852
+ category: string;
1853
+ created_at: string | null;
1854
+ id: string;
1855
+ message: string;
1856
+ organization_id: string;
1857
+ read: boolean | null;
1858
+ read_at: string | null;
1859
+ title: string;
1860
+ user_id: string;
1861
+ };
1862
+ Insert: {
1863
+ action_url?: string | null;
1864
+ category: string;
1865
+ created_at?: string | null;
1866
+ id?: string;
1867
+ message: string;
1868
+ organization_id: string;
1869
+ read?: boolean | null;
1870
+ read_at?: string | null;
1871
+ title: string;
1872
+ user_id: string;
1873
+ };
1874
+ Update: {
1875
+ action_url?: string | null;
1876
+ category?: string;
1877
+ created_at?: string | null;
1878
+ id?: string;
1879
+ message?: string;
1880
+ organization_id?: string;
1881
+ read?: boolean | null;
1882
+ read_at?: string | null;
1883
+ title?: string;
1884
+ user_id?: string;
1885
+ };
1886
+ Relationships: [
1887
+ {
1888
+ foreignKeyName: "notifications_organization_id_fkey";
1889
+ columns: ["organization_id"];
1890
+ isOneToOne: false;
1891
+ referencedRelation: "organizations";
1892
+ referencedColumns: ["id"];
1893
+ },
1894
+ {
1895
+ foreignKeyName: "notifications_user_id_fkey";
1896
+ columns: ["user_id"];
1897
+ isOneToOne: false;
1898
+ referencedRelation: "users";
1899
+ referencedColumns: ["id"];
1900
+ }
1901
+ ];
1902
+ };
1903
+ org_invitations: {
1904
+ Row: {
1905
+ accept_invitation_url: string | null;
1906
+ accepted_at: string | null;
1907
+ created_at: string | null;
1908
+ email: string;
1909
+ expires_at: string;
1910
+ id: string;
1911
+ invitation_state: string | null;
1912
+ invitation_token: string | null;
1913
+ inviter_user_id: string | null;
1914
+ organization_id: string | null;
1915
+ revoked_at: string | null;
1916
+ role_slug: string | null;
1917
+ updated_at: string | null;
1918
+ workos_invitation_id: string;
1919
+ };
1920
+ Insert: {
1921
+ accept_invitation_url?: string | null;
1922
+ accepted_at?: string | null;
1923
+ created_at?: string | null;
1924
+ email: string;
1925
+ expires_at: string;
1926
+ id?: string;
1927
+ invitation_state?: string | null;
1928
+ invitation_token?: string | null;
1929
+ inviter_user_id?: string | null;
1930
+ organization_id?: string | null;
1931
+ revoked_at?: string | null;
1932
+ role_slug?: string | null;
1933
+ updated_at?: string | null;
1934
+ workos_invitation_id: string;
1935
+ };
1936
+ Update: {
1937
+ accept_invitation_url?: string | null;
1938
+ accepted_at?: string | null;
1939
+ created_at?: string | null;
1940
+ email?: string;
1941
+ expires_at?: string;
1942
+ id?: string;
1943
+ invitation_state?: string | null;
1944
+ invitation_token?: string | null;
1945
+ inviter_user_id?: string | null;
1946
+ organization_id?: string | null;
1947
+ revoked_at?: string | null;
1948
+ role_slug?: string | null;
1949
+ updated_at?: string | null;
1950
+ workos_invitation_id?: string;
1951
+ };
1952
+ Relationships: [
1953
+ {
1954
+ foreignKeyName: "org_invitations_inviter_user_id_fkey";
1955
+ columns: ["inviter_user_id"];
1956
+ isOneToOne: false;
1957
+ referencedRelation: "users";
1958
+ referencedColumns: ["id"];
1959
+ },
1960
+ {
1961
+ foreignKeyName: "org_invitations_organization_id_fkey";
1962
+ columns: ["organization_id"];
1963
+ isOneToOne: false;
1964
+ referencedRelation: "organizations";
1965
+ referencedColumns: ["id"];
1966
+ }
1967
+ ];
1968
+ };
1969
+ org_memberships: {
1970
+ Row: {
1971
+ config: Json;
1972
+ created_at: string | null;
1973
+ id: string;
1974
+ membership_status: string | null;
1975
+ organization_id: string;
1976
+ role_slug: string | null;
1977
+ updated_at: string | null;
1978
+ user_id: string;
1979
+ workos_membership_id: string | null;
1980
+ };
1981
+ Insert: {
1982
+ config?: Json;
1983
+ created_at?: string | null;
1984
+ id?: string;
1985
+ membership_status?: string | null;
1986
+ organization_id: string;
1987
+ role_slug?: string | null;
1988
+ updated_at?: string | null;
1989
+ user_id: string;
1990
+ workos_membership_id?: string | null;
1991
+ };
1992
+ Update: {
1993
+ config?: Json;
1994
+ created_at?: string | null;
1995
+ id?: string;
1996
+ membership_status?: string | null;
1997
+ organization_id?: string;
1998
+ role_slug?: string | null;
1999
+ updated_at?: string | null;
2000
+ user_id?: string;
2001
+ workos_membership_id?: string | null;
2002
+ };
2003
+ Relationships: [
2004
+ {
2005
+ foreignKeyName: "org_memberships_organization_id_fkey";
2006
+ columns: ["organization_id"];
2007
+ isOneToOne: false;
2008
+ referencedRelation: "organizations";
2009
+ referencedColumns: ["id"];
2010
+ },
2011
+ {
2012
+ foreignKeyName: "org_memberships_user_id_fkey";
2013
+ columns: ["user_id"];
2014
+ isOneToOne: false;
2015
+ referencedRelation: "users";
2016
+ referencedColumns: ["id"];
2017
+ }
2018
+ ];
2019
+ };
2020
+ organizations: {
2021
+ Row: {
2022
+ config: Json;
2023
+ created_at: string;
2024
+ id: string;
2025
+ is_test: boolean;
2026
+ metadata: Json;
2027
+ name: string;
2028
+ status: string;
2029
+ updated_at: string;
2030
+ workos_org_id: string;
2031
+ };
2032
+ Insert: {
2033
+ config?: Json;
2034
+ created_at?: string;
2035
+ id?: string;
2036
+ is_test?: boolean;
2037
+ metadata?: Json;
2038
+ name: string;
2039
+ status?: string;
2040
+ updated_at?: string;
2041
+ workos_org_id: string;
2042
+ };
2043
+ Update: {
2044
+ config?: Json;
2045
+ created_at?: string;
2046
+ id?: string;
2047
+ is_test?: boolean;
2048
+ metadata?: Json;
2049
+ name?: string;
2050
+ status?: string;
2051
+ updated_at?: string;
2052
+ workos_org_id?: string;
2053
+ };
2054
+ Relationships: [];
2055
+ };
2056
+ session_messages: {
2057
+ Row: {
2058
+ created_at: string | null;
2059
+ id: string;
2060
+ message: string;
2061
+ message_index: number | null;
2062
+ message_type: string | null;
2063
+ metadata: Json | null;
2064
+ role: string;
2065
+ session_id: string;
2066
+ session_turn_number: number;
2067
+ };
2068
+ Insert: {
2069
+ created_at?: string | null;
2070
+ id: string;
2071
+ message: string;
2072
+ message_index?: number | null;
2073
+ message_type?: string | null;
2074
+ metadata?: Json | null;
2075
+ role: string;
2076
+ session_id: string;
2077
+ session_turn_number: number;
2078
+ };
2079
+ Update: {
2080
+ created_at?: string | null;
2081
+ id?: string;
2082
+ message?: string;
2083
+ message_index?: number | null;
2084
+ message_type?: string | null;
2085
+ metadata?: Json | null;
2086
+ role?: string;
2087
+ session_id?: string;
2088
+ session_turn_number?: number;
2089
+ };
2090
+ Relationships: [
2091
+ {
2092
+ foreignKeyName: "session_messages_session_id_fkey";
2093
+ columns: ["session_id"];
2094
+ isOneToOne: false;
2095
+ referencedRelation: "sessions";
2096
+ referencedColumns: ["session_id"];
2097
+ }
2098
+ ];
2099
+ };
2100
+ sessions: {
2101
+ Row: {
2102
+ context_window_size: number;
2103
+ created_at: string | null;
2104
+ cumulative_input_tokens: number;
2105
+ cumulative_output_tokens: number;
2106
+ deleted_at: string | null;
2107
+ ended_at: string | null;
2108
+ memory_snapshot: Json;
2109
+ metadata: Json | null;
2110
+ organization_id: string;
2111
+ resource_id: string;
2112
+ session_id: string;
2113
+ session_total_turns: number | null;
2114
+ updated_at: string | null;
2115
+ user_id: string | null;
2116
+ };
2117
+ Insert: {
2118
+ context_window_size?: number;
2119
+ created_at?: string | null;
2120
+ cumulative_input_tokens?: number;
2121
+ cumulative_output_tokens?: number;
2122
+ deleted_at?: string | null;
2123
+ ended_at?: string | null;
2124
+ memory_snapshot: Json;
2125
+ metadata?: Json | null;
2126
+ organization_id: string;
2127
+ resource_id: string;
2128
+ session_id?: string;
2129
+ session_total_turns?: number | null;
2130
+ updated_at?: string | null;
2131
+ user_id?: string | null;
2132
+ };
2133
+ Update: {
2134
+ context_window_size?: number;
2135
+ created_at?: string | null;
2136
+ cumulative_input_tokens?: number;
2137
+ cumulative_output_tokens?: number;
2138
+ deleted_at?: string | null;
2139
+ ended_at?: string | null;
2140
+ memory_snapshot?: Json;
2141
+ metadata?: Json | null;
2142
+ organization_id?: string;
2143
+ resource_id?: string;
2144
+ session_id?: string;
2145
+ session_total_turns?: number | null;
2146
+ updated_at?: string | null;
2147
+ user_id?: string | null;
2148
+ };
2149
+ Relationships: [
2150
+ {
2151
+ foreignKeyName: "fk_organization";
2152
+ columns: ["organization_id"];
2153
+ isOneToOne: false;
2154
+ referencedRelation: "organizations";
2155
+ referencedColumns: ["id"];
2156
+ },
2157
+ {
2158
+ foreignKeyName: "fk_user";
2159
+ columns: ["user_id"];
2160
+ isOneToOne: false;
2161
+ referencedRelation: "users";
2162
+ referencedColumns: ["id"];
2163
+ }
2164
+ ];
2165
+ };
2166
+ task_schedules: {
2167
+ Row: {
2168
+ created_at: string;
2169
+ current_step: number;
2170
+ description: string | null;
2171
+ id: string;
2172
+ idempotency_key: string | null;
2173
+ last_execution_id: string | null;
2174
+ last_run_at: string | null;
2175
+ max_retries: number;
2176
+ metadata: Json | null;
2177
+ name: string;
2178
+ next_run_at: string | null;
2179
+ organization_id: string;
2180
+ origin_execution_id: string | null;
2181
+ origin_resource_id: string | null;
2182
+ origin_resource_type: string | null;
2183
+ retry_count: number;
2184
+ schedule_config: Json;
2185
+ status: string;
2186
+ target_resource_id: string;
2187
+ target_resource_type: string;
2188
+ updated_at: string;
2189
+ };
2190
+ Insert: {
2191
+ created_at?: string;
2192
+ current_step?: number;
2193
+ description?: string | null;
2194
+ id?: string;
2195
+ idempotency_key?: string | null;
2196
+ last_execution_id?: string | null;
2197
+ last_run_at?: string | null;
2198
+ max_retries?: number;
2199
+ metadata?: Json | null;
2200
+ name: string;
2201
+ next_run_at?: string | null;
2202
+ organization_id: string;
2203
+ origin_execution_id?: string | null;
2204
+ origin_resource_id?: string | null;
2205
+ origin_resource_type?: string | null;
2206
+ retry_count?: number;
2207
+ schedule_config: Json;
2208
+ status?: string;
2209
+ target_resource_id: string;
2210
+ target_resource_type: string;
2211
+ updated_at?: string;
2212
+ };
2213
+ Update: {
2214
+ created_at?: string;
2215
+ current_step?: number;
2216
+ description?: string | null;
2217
+ id?: string;
2218
+ idempotency_key?: string | null;
2219
+ last_execution_id?: string | null;
2220
+ last_run_at?: string | null;
2221
+ max_retries?: number;
2222
+ metadata?: Json | null;
2223
+ name?: string;
2224
+ next_run_at?: string | null;
2225
+ organization_id?: string;
2226
+ origin_execution_id?: string | null;
2227
+ origin_resource_id?: string | null;
2228
+ origin_resource_type?: string | null;
2229
+ retry_count?: number;
2230
+ schedule_config?: Json;
2231
+ status?: string;
2232
+ target_resource_id?: string;
2233
+ target_resource_type?: string;
2234
+ updated_at?: string;
2235
+ };
2236
+ Relationships: [
2237
+ {
2238
+ foreignKeyName: "task_schedules_organization_id_fkey";
2239
+ columns: ["organization_id"];
2240
+ isOneToOne: false;
2241
+ referencedRelation: "organizations";
2242
+ referencedColumns: ["id"];
2243
+ }
2244
+ ];
2245
+ };
2246
+ users: {
2247
+ Row: {
2248
+ config: Json;
2249
+ created_at: string;
2250
+ display_name: string | null;
2251
+ email: string;
2252
+ first_name: string | null;
2253
+ id: string;
2254
+ is_active: boolean;
2255
+ is_platform_admin: boolean | null;
2256
+ last_login_at: string | null;
2257
+ last_name: string | null;
2258
+ last_visited_org: string | null;
2259
+ profile_picture_url: string | null;
2260
+ updated_at: string;
2261
+ workos_user_id: string | null;
2262
+ };
2263
+ Insert: {
2264
+ config?: Json;
2265
+ created_at?: string;
2266
+ display_name?: string | null;
2267
+ email: string;
2268
+ first_name?: string | null;
2269
+ id?: string;
2270
+ is_active?: boolean;
2271
+ is_platform_admin?: boolean | null;
2272
+ last_login_at?: string | null;
2273
+ last_name?: string | null;
2274
+ last_visited_org?: string | null;
2275
+ profile_picture_url?: string | null;
2276
+ updated_at?: string;
2277
+ workos_user_id?: string | null;
2278
+ };
2279
+ Update: {
2280
+ config?: Json;
2281
+ created_at?: string;
2282
+ display_name?: string | null;
2283
+ email?: string;
2284
+ first_name?: string | null;
2285
+ id?: string;
2286
+ is_active?: boolean;
2287
+ is_platform_admin?: boolean | null;
2288
+ last_login_at?: string | null;
2289
+ last_name?: string | null;
2290
+ last_visited_org?: string | null;
2291
+ profile_picture_url?: string | null;
2292
+ updated_at?: string;
2293
+ workos_user_id?: string | null;
2294
+ };
2295
+ Relationships: [
2296
+ {
2297
+ foreignKeyName: "user_profiles_last_visited_org_fkey";
2298
+ columns: ["last_visited_org"];
2299
+ isOneToOne: false;
2300
+ referencedRelation: "organizations";
2301
+ referencedColumns: ["id"];
2302
+ }
2303
+ ];
2304
+ };
2305
+ webhook_endpoints: {
2306
+ Row: {
2307
+ created_at: string;
2308
+ description: string | null;
2309
+ id: string;
2310
+ key: string;
2311
+ last_triggered_at: string | null;
2312
+ name: string;
2313
+ organization_id: string;
2314
+ request_count: number;
2315
+ resource_id: string | null;
2316
+ status: string;
2317
+ updated_at: string;
2318
+ };
2319
+ Insert: {
2320
+ created_at?: string;
2321
+ description?: string | null;
2322
+ id?: string;
2323
+ key: string;
2324
+ last_triggered_at?: string | null;
2325
+ name: string;
2326
+ organization_id: string;
2327
+ request_count?: number;
2328
+ resource_id?: string | null;
2329
+ status?: string;
2330
+ updated_at?: string;
2331
+ };
2332
+ Update: {
2333
+ created_at?: string;
2334
+ description?: string | null;
2335
+ id?: string;
2336
+ key?: string;
2337
+ last_triggered_at?: string | null;
2338
+ name?: string;
2339
+ organization_id?: string;
2340
+ request_count?: number;
2341
+ resource_id?: string | null;
2342
+ status?: string;
2343
+ updated_at?: string;
2344
+ };
2345
+ Relationships: [
2346
+ {
2347
+ foreignKeyName: "webhook_endpoints_organization_id_fkey";
2348
+ columns: ["organization_id"];
2349
+ isOneToOne: false;
2350
+ referencedRelation: "organizations";
2351
+ referencedColumns: ["id"];
2352
+ }
2353
+ ];
2354
+ };
2355
+ };
2356
+ Views: {
2357
+ [_ in never]: never;
2358
+ };
2359
+ Functions: {
2360
+ acq_default_checklist: {
2361
+ Args: {
2362
+ p_platform: string;
2363
+ };
2364
+ Returns: Json;
2365
+ };
2366
+ append_deal_activity: {
2367
+ Args: {
2368
+ p_activity: Json;
2369
+ p_deal_id: string;
2370
+ p_organization_id: string;
2371
+ };
2372
+ Returns: undefined;
2373
+ };
2374
+ auth_jwt_claims: {
2375
+ Args: never;
2376
+ Returns: Json;
2377
+ };
2378
+ auth_uid_safe: {
2379
+ Args: never;
2380
+ Returns: string;
2381
+ };
2382
+ current_user_is_platform_admin: {
2383
+ Args: never;
2384
+ Returns: boolean;
2385
+ };
2386
+ current_user_supabase_id: {
2387
+ Args: never;
2388
+ Returns: string;
2389
+ };
2390
+ detect_stalled_executions: {
2391
+ Args: never;
2392
+ Returns: undefined;
2393
+ };
2394
+ execute_session_turn: {
2395
+ Args: {
2396
+ p_session_id: string;
2397
+ };
2398
+ Returns: {
2399
+ created_at: string;
2400
+ ended_at: string;
2401
+ memory_snapshot: Json;
2402
+ metadata: Json;
2403
+ organization_id: string;
2404
+ resource_id: string;
2405
+ session_id: string;
2406
+ session_total_turns: number;
2407
+ updated_at: string;
2408
+ user_id: string;
2409
+ }[];
2410
+ };
2411
+ get_storage_org_id: {
2412
+ Args: {
2413
+ file_path: string;
2414
+ };
2415
+ Returns: string;
2416
+ };
2417
+ get_workos_user_id: {
2418
+ Args: never;
2419
+ Returns: string;
2420
+ };
2421
+ is_org_admin: {
2422
+ Args: {
2423
+ org_id: string;
2424
+ };
2425
+ Returns: boolean;
2426
+ };
2427
+ is_org_member: {
2428
+ Args: {
2429
+ org_id: string;
2430
+ };
2431
+ Returns: boolean;
2432
+ };
2433
+ link_workos_membership_on_accept: {
2434
+ Args: {
2435
+ p_email: string;
2436
+ p_organization_id: string;
2437
+ p_workos_membership_id: string;
2438
+ };
2439
+ Returns: boolean;
2440
+ };
2441
+ pre_provision_invited_user: {
2442
+ Args: {
2443
+ p_email: string;
2444
+ p_organization_id: string;
2445
+ p_role_slug?: string;
2446
+ };
2447
+ Returns: Json;
2448
+ };
2449
+ process_due_schedules: {
2450
+ Args: never;
2451
+ Returns: Json;
2452
+ };
2453
+ upsert_user_profile: {
2454
+ Args: never;
2455
+ Returns: {
2456
+ profile_display_name: string;
2457
+ profile_email: string;
2458
+ profile_id: string;
2459
+ profile_workos_user_id: string;
2460
+ }[];
2461
+ };
2462
+ };
2463
+ Enums: {
2464
+ [_ in never]: never;
2465
+ };
2466
+ CompositeTypes: {
2467
+ [_ in never]: never;
2468
+ };
2469
+ };
2470
+ };
2471
+ type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">;
2472
+ type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">];
2473
+ type Tables<DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | {
2474
+ schema: keyof DatabaseWithoutInternals;
2475
+ }, TableName extends DefaultSchemaTableNameOrOptions extends {
2476
+ schema: keyof DatabaseWithoutInternals;
2477
+ } ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) : never = never> = DefaultSchemaTableNameOrOptions extends {
2478
+ schema: keyof DatabaseWithoutInternals;
2479
+ } ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
2480
+ Row: infer R;
2481
+ } ? R : never : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) ? (DefaultSchema["Tables"] & DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
2482
+ Row: infer R;
2483
+ } ? R : never : never;
2484
+
2485
+ type SupabaseUserProfile = Tables<'users'>;
2486
+
2487
+ /**
2488
+ * Origin resource type - where an execution/task originated from.
2489
+ * Used for audit trails and tracking execution lineage.
2490
+ */
2491
+ type OriginResourceType$1 = 'agent' | 'workflow' | 'scheduler' | 'api';
2492
+
2493
+ /**
2494
+ * Target for schedule execution - identifies what resource to execute.
2495
+ * Unlike ExecutionTarget, payload is NOT included here because schedules
2496
+ * store payload in the scheduleConfig (varies per step/item).
2497
+ */
2498
+ interface ScheduleTarget {
2499
+ resourceType: 'agent' | 'workflow';
2500
+ resourceId: string;
2501
+ }
2502
+ /**
2503
+ * Optional origin tracking for schedules.
2504
+ * Unlike OriginTracking (which is required), these fields are all optional
2505
+ * for schedules created directly via API (not triggered by another resource).
2506
+ */
2507
+ interface ScheduleOriginTracking {
2508
+ originExecutionId?: string;
2509
+ originResourceType?: OriginResourceType$1;
2510
+ originResourceId?: string;
2511
+ }
2512
+ type TaskScheduleConfig = RecurringScheduleConfig | RelativeScheduleConfig | AbsoluteScheduleConfig;
2513
+ interface RecurringScheduleConfig {
2514
+ type: 'recurring';
2515
+ cron?: string;
2516
+ interval?: 'daily' | 'weekly' | 'monthly';
2517
+ time?: string;
2518
+ timezone: string;
2519
+ payload: Record<string, unknown>;
2520
+ endAt?: string | null;
2521
+ overduePolicy?: 'skip' | 'execute';
2522
+ }
2523
+ interface RelativeScheduleConfig {
2524
+ type: 'relative';
2525
+ anchorAt: string;
2526
+ anchorLabel?: string;
2527
+ items: RelativeScheduleItem[];
2528
+ overduePolicy?: 'skip' | 'execute';
2529
+ }
2530
+ interface RelativeScheduleItem {
2531
+ offset: string;
2532
+ payload: Record<string, unknown>;
2533
+ label?: string;
2534
+ }
2535
+ interface AbsoluteScheduleConfig {
2536
+ type: 'absolute';
2537
+ items: AbsoluteScheduleItem[];
2538
+ overduePolicy?: 'skip' | 'execute';
2539
+ }
2540
+ interface AbsoluteScheduleItem {
2541
+ runAt: string;
2542
+ payload: Record<string, unknown>;
2543
+ label?: string;
2544
+ }
2545
+ interface TaskSchedule extends ScheduleOriginTracking {
2546
+ id: string;
2547
+ organizationId: string;
2548
+ name: string;
2549
+ description?: string;
2550
+ target: ScheduleTarget;
2551
+ scheduleConfig: TaskScheduleConfig;
2552
+ nextRunAt?: Date;
2553
+ currentStep: number;
2554
+ status: 'active' | 'paused' | 'completed' | 'cancelled';
2555
+ lastRunAt?: Date;
2556
+ lastExecutionId?: string;
2557
+ maxRetries: number;
2558
+ idempotencyKey?: string;
2559
+ createdAt: Date;
2560
+ updatedAt: Date;
2561
+ }
2562
+
2563
+ type MessageType = MessageEvent['type'];
2564
+ /**
2565
+ * Session Data Transfer Object (DTO)
2566
+ * Transform type for API responses (snake_case DB → camelCase frontend)
2567
+ * Used by frontend apps to display session data
2568
+ */
2569
+ interface SessionDTO {
2570
+ sessionId: string;
2571
+ resourceId: string;
2572
+ organizationId: string;
2573
+ userId?: string | null;
2574
+ turnCount: number;
2575
+ isEnded: boolean;
2576
+ title?: string | null;
2577
+ memorySnapshot?: AgentMemory;
2578
+ metadata?: Record<string, unknown> | null;
2579
+ createdAt: Date;
2580
+ updatedAt: Date;
2581
+ endedAt?: Date | null;
2582
+ }
2583
+ interface ChatMessage {
2584
+ id: string;
2585
+ role: 'user' | 'assistant';
2586
+ messageType: MessageType;
2587
+ text: string;
2588
+ metadata?: MessageEvent;
2589
+ turnNumber: number;
2590
+ messageIndex?: number;
2591
+ createdAt: Date;
2592
+ }
2593
+ /** Token usage data sent with turn:complete WebSocket events */
2594
+ interface SessionTokenUsage {
2595
+ /** Tokens consumed by this turn's input */
2596
+ turnInputTokens: number;
2597
+ /** Tokens generated by this turn's output */
2598
+ turnOutputTokens: number;
2599
+ /** Total tokens for this turn (turnInputTokens + turnOutputTokens) */
2600
+ turnTotalTokens: number;
2601
+ /** Cumulative input tokens across all turns in this session */
2602
+ cumulativeInputTokens: number;
2603
+ /** Cumulative output tokens across all turns in this session */
2604
+ cumulativeOutputTokens: number;
2605
+ /** The model's context window size for this session (e.g., 200K) */
2606
+ contextWindowSize: number;
2607
+ }
2608
+
2609
+ /**
2610
+ * Multi-tenancy configuration types
2611
+ *
2612
+ * Config is stored in dedicated `config` columns (NOT nested in metadata):
2613
+ * - organizations.config: Org-level feature config
2614
+ * - org_memberships.config: Per-user-per-org feature overrides
2615
+ * - users.config: User-global config
2616
+ */
2617
+ /**
2618
+ * Org-level feature config (stored in organizations.config)
2619
+ * Controls which features are available to all org members
2620
+ * Valid feature keys: operations, monitoring, acquisition, calibration, seo
2621
+ */
2622
+ interface OrgFeatureConfig {
2623
+ features?: {
2624
+ operations?: boolean;
2625
+ monitoring?: boolean;
2626
+ acquisition?: boolean;
2627
+ calibration?: boolean;
2628
+ seo?: boolean;
2629
+ };
2630
+ }
2631
+ /**
2632
+ * Per-user-per-org config (stored in org_memberships.config)
2633
+ * Overrides org-level feature config for specific users
2634
+ */
2635
+ type MembershipFeatureConfig = OrgFeatureConfig;
2636
+ /**
2637
+ * User-global config (stored in users.config)
2638
+ * Theme and onboarding are user-specific, NOT org-specific
2639
+ */
2640
+ interface UserConfig {
2641
+ theme?: {
2642
+ preset?: 'default' | 'tactical' | 'regal' | 'cyber-volt' | 'aurora' | 'rose-gold' | 'midnight' | 'ember' | 'obsidian' | 'honey' | 'abyss' | 'canopy' | 'slate' | 'cyber-strike' | 'cyber-flux' | 'cyber-void';
2643
+ colorScheme?: 'light' | 'dark' | 'auto';
2644
+ };
2645
+ onboarding?: {
2646
+ completed?: boolean;
2647
+ completedAt?: string;
2648
+ role?: string;
2649
+ primaryUseCase?: string[];
2650
+ experienceLevel?: string;
2651
+ /** Onboarding guide system state (set by checklist/tour system) */
2652
+ guides?: {
2653
+ completedIds?: string[];
2654
+ dismissed?: boolean;
2655
+ completedAt?: string;
2656
+ };
2657
+ };
2658
+ }
2659
+
2660
+ /**
2661
+ * Organization Membership types based on WorkOS API
2662
+ */
2663
+ interface OrganizationMembership {
2664
+ object: 'organization_membership';
2665
+ id: string;
2666
+ userId: string;
2667
+ organizationId: string;
2668
+ role: {
2669
+ slug: string;
2670
+ };
2671
+ status: 'active' | 'inactive';
2672
+ createdAt: string;
2673
+ updatedAt: string;
2674
+ }
2675
+ /**
2676
+ * Extended membership with user and organization details for UI
2677
+ */
2678
+ interface MembershipWithDetails extends OrganizationMembership {
2679
+ user?: {
2680
+ id: string;
2681
+ email: string;
2682
+ firstName?: string;
2683
+ lastName?: string;
2684
+ profilePictureUrl?: string;
2685
+ };
2686
+ organization?: {
2687
+ id: string;
2688
+ name: string;
2689
+ workos_org_id: string;
2690
+ primaryDomain?: string;
2691
+ is_test?: boolean;
2692
+ status?: string;
2693
+ metadata?: Record<string, unknown>;
2694
+ config?: OrgFeatureConfig;
2695
+ };
2696
+ config?: MembershipFeatureConfig;
2697
+ }
2698
+
2699
+ /**
2700
+ * Base Execution Engine type definitions
2701
+ * Core types shared across all Execution Engine resources
2702
+ */
2703
+
2704
+ /**
2705
+ * Unified message event type - covers all message types in sessions
2706
+ * Replaces separate SessionTurnMessages and AgentActivityEvent mechanisms
2707
+ */
2708
+ /**
2709
+ * Structured action metadata attached to assistant messages.
2710
+ * Frontend reads this instead of parsing text prefixes.
2711
+ */
2712
+ type AssistantAction = {
2713
+ kind: 'navigate';
2714
+ path: string;
2715
+ reason: string;
2716
+ } | {
2717
+ kind: 'update_filters';
2718
+ timeRange: string | null;
2719
+ statusFilter: string | null;
2720
+ searchQuery: string | null;
2721
+ };
2722
+ type MessageEvent = {
2723
+ type: 'user_message';
2724
+ text: string;
2725
+ } | {
2726
+ type: 'assistant_message';
2727
+ text: string;
2728
+ _action?: AssistantAction;
2729
+ } | {
2730
+ type: 'agent:started';
2731
+ } | {
2732
+ type: 'agent:completed';
2733
+ } | {
2734
+ type: 'agent:error';
2735
+ error: string;
2736
+ } | {
2737
+ type: 'agent:reasoning';
2738
+ iteration: number;
2739
+ reasoning: string;
2740
+ } | {
2741
+ type: 'agent:tool_call';
2742
+ toolName: string;
2743
+ args: Record<string, unknown>;
2744
+ } | {
2745
+ type: 'agent:tool_result';
2746
+ toolName: string;
2747
+ success: boolean;
2748
+ result?: unknown;
2749
+ error?: string;
2750
+ };
2751
+ /**
2752
+ * NOTE: AIResource interface has been removed and replaced with ResourceDefinition
2753
+ * from registry/types.ts. All resources (executable and non-executable) now extend
2754
+ * the unified ResourceDefinition base interface.
2755
+ *
2756
+ * AgentConfig and WorkflowConfig now extend ResourceDefinition directly.
2757
+ * See packages/core/src/registry/types.ts for the base interface definition.
2758
+ */
2759
+ type AIResourceDefinition = SerializedWorkflowDefinition | SerializedAgentDefinition;
2760
+
2761
+ /**
2762
+ * Resource Registry type definitions
2763
+ */
2764
+
2765
+ /**
2766
+ * Environment/deployment status for resources
2767
+ */
2768
+ type ResourceStatus = 'dev' | 'prod';
2769
+ /**
2770
+ * All resource types in the platform
2771
+ * Used as the discriminator field in ResourceDefinition
2772
+ */
2773
+ type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human';
2774
+ /**
2775
+ * Base interface for ALL platform resources
2776
+ * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
2777
+ */
2778
+ interface ResourceDefinition {
2779
+ /** Unique resource identifier */
2780
+ resourceId: string;
2781
+ /** Display name */
2782
+ name: string;
2783
+ /** Purpose and functionality description */
2784
+ description: string;
2785
+ /** Version for change tracking and evolution */
2786
+ version: string;
2787
+ /** Resource type discriminator */
2788
+ type: ResourceType;
2789
+ /** Environment/deployment status */
2790
+ status: ResourceStatus;
2791
+ /** Domain tags for filtering and organization */
2792
+ domains?: ResourceDomain[];
2793
+ /** Whether the agent supports multi-turn sessions (agents only) */
2794
+ sessionCapable?: boolean;
2795
+ /** Whether the resource is local (monorepo) or remote (externally deployed) */
2796
+ origin?: 'local' | 'remote';
2797
+ /** Whether this resource is archived and should be excluded from registration and deployment */
2798
+ archived?: boolean;
2799
+ }
2800
+
2801
+ /**
2802
+ * Standard Domain Definitions
2803
+ * Centralized domain constants and definitions for all organization resources.
2804
+ */
2805
+
2806
+ declare const DOMAINS: {
2807
+ readonly INBOUND_PIPELINE: "inbound-pipeline";
2808
+ readonly LEAD_GEN_PIPELINE: "lead-gen-pipeline";
2809
+ readonly SUPPORT: "support";
2810
+ readonly CLIENT_SUPPORT: "client-support";
2811
+ readonly DELIVERY: "delivery";
2812
+ readonly OPERATIONS: "operations";
2813
+ readonly FINANCE: "finance";
2814
+ readonly EXECUTIVE: "executive";
2815
+ readonly INSTANTLY: "instantly";
2816
+ readonly TESTING: "testing";
2817
+ readonly INTERNAL: "internal";
2818
+ readonly INTEGRATION: "integration";
2819
+ readonly UTILITY: "utility";
2820
+ readonly DIAGNOSTIC: "diagnostic";
2821
+ };
2822
+ /**
2823
+ * ResourceDomain - Strongly typed domain identifier
2824
+ * Use this type for all domain references to ensure compile-time validation.
2825
+ */
2826
+ type ResourceDomain = (typeof DOMAINS)[keyof typeof DOMAINS];
2827
+
2828
+ type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'warning';
2829
+ interface APIExecutionSummary {
2830
+ id: string;
2831
+ status: ExecutionStatus;
2832
+ startTime: number;
2833
+ endTime?: number;
2834
+ resourceStatus?: ResourceStatus;
2835
+ }
2836
+ interface APIExecutionDetail extends APIExecutionSummary {
2837
+ executionLogs: ExecutionLogMessage[];
2838
+ input?: unknown;
2839
+ result?: unknown;
2840
+ error?: string;
2841
+ resourceStatus: ResourceStatus;
2842
+ apiVersion?: string | null;
2843
+ resourceVersion?: string | null;
2844
+ sdkVersion?: string | null;
2845
+ }
2846
+ interface APIExecutionListResponse {
2847
+ executions: APIExecutionSummary[];
2848
+ }
2849
+
2850
+ /**
2851
+ * Shared form field types for dynamic form generation
2852
+ * Used by: Command Queue, Execution Runner UI, future form-based features
2853
+ */
2854
+
2855
+ /**
2856
+ * Supported form field types for action payloads
2857
+ * Maps to Mantine form components
2858
+ */
2859
+ type FormFieldType =
2860
+ | 'text' // TextInput
2861
+ | 'textarea' // Textarea
2862
+ | 'number' // NumberInput
2863
+ | 'select' // Select dropdown
2864
+ | 'checkbox' // Checkbox
2865
+ | 'radio' // Radio group
2866
+ | 'richtext' // Rich text editor (TipTap)
2867
+
2868
+ /**
2869
+ * Form field definition
2870
+ */
2871
+ interface FormField {
2872
+ /** Field key in payload object */
2873
+ name: string
2874
+
2875
+ /** Field label for UI */
2876
+ label: string
2877
+
2878
+ /** Field type (determines UI component) */
2879
+ type: FormFieldType
2880
+
2881
+ /** Default value */
2882
+ defaultValue?: unknown
2883
+
2884
+ /** Required field */
2885
+ required?: boolean
2886
+
2887
+ /** Placeholder text */
2888
+ placeholder?: string
2889
+
2890
+ /** Help text */
2891
+ description?: string
2892
+
2893
+ /** Options for select/radio */
2894
+ options?: Array<{
2895
+ label: string
2896
+ value: string | number
2897
+ }>
2898
+
2899
+ /** Min/max for number */
2900
+ min?: number
2901
+ max?: number
2902
+
2903
+ /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
2904
+ defaultValueFromContext?: string
2905
+ }
2906
+
2907
+ /**
2908
+ * Form schema for action payload collection
2909
+ */
2910
+ interface FormSchema {
2911
+ /** Form title */
2912
+ title?: string
2913
+
2914
+ /** Form description */
2915
+ description?: string
2916
+
2917
+ /** Form fields */
2918
+ fields: FormField[]
2919
+ }
2920
+
2921
+ /**
2922
+ * Action configuration for HITL tasks
2923
+ * Defines available user actions and their behavior
2924
+ */
2925
+ interface ActionConfig {
2926
+ /** Unique action identifier (e.g., 'approve', 'retry', 'escalate') */
2927
+ id: string
2928
+
2929
+ /** Display label for UI button */
2930
+ label: string
2931
+
2932
+ /** Button variant/style */
2933
+ type: 'primary' | 'secondary' | 'danger' | 'outline'
2934
+
2935
+ /** Tabler icon name (e.g., 'IconCheck', 'IconRefresh') */
2936
+ icon?: string
2937
+
2938
+ /** Button color (Mantine theme colors) */
2939
+ color?: string
2940
+
2941
+ /** Button variant (Mantine button variant, e.g., 'light', 'filled', 'outline') */
2942
+ variant?: string
2943
+
2944
+ /** Execution target (agent/workflow to invoke) */
2945
+ target?: {
2946
+ resourceType: 'agent' | 'workflow'
2947
+ resourceId: string
2948
+ /**
2949
+ * Optional session ID for agent continuation.
2950
+ * If provided, invokes a new turn on the existing session instead of standalone execution.
2951
+ * Only valid when resourceType is 'agent'.
2952
+ */
2953
+ sessionId?: string
2954
+ }
2955
+
2956
+ /** Form schema for collecting action-specific data */
2957
+ form?: FormSchema
2958
+
2959
+ /** Payload template for pre-filling forms */
2960
+ payloadTemplate?: unknown
2961
+
2962
+ /** Requires confirmation dialog */
2963
+ requiresConfirmation?: boolean
2964
+
2965
+ /** Confirmation message */
2966
+ confirmationMessage?: string
2967
+
2968
+ /** Help text / tooltip */
2969
+ description?: string
2970
+ }
2971
+
2972
+ /**
2973
+ * Origin resource type - where an execution/task originated from.
2974
+ * Used for audit trails and tracking execution lineage.
2975
+ */
2976
+ type OriginResourceType = 'agent' | 'workflow' | 'scheduler' | 'api'
2977
+
2978
+ /**
2979
+ * Origin tracking metadata - who/what created this execution/task.
2980
+ * Used by both TaskScheduler and CommandQueue for complete audit trails.
2981
+ */
2982
+ interface OriginTracking {
2983
+ originExecutionId: string
2984
+ originResourceType: OriginResourceType
2985
+ originResourceId: string
2986
+ }
2987
+
2988
+ /**
2989
+ * Error categories for observability grouping and classification.
2990
+ * Used to categorize errors in the execution_errors table metadata.
2991
+ */
2992
+ type ExecutionErrorCategory = 'llm' | 'tool' | 'workflow' | 'agent' | 'validation' | 'system'
2993
+
2994
+ /**
2995
+ * Wire-format DTO for notification API responses.
2996
+ * Dates are ISO 8601 strings (not Date objects like the domain Notification type).
2997
+ * Used by frontend hooks that consume /api/notifications.
2998
+ */
2999
+ interface NotificationDTO {
3000
+ id: string
3001
+ userId: string
3002
+ organizationId: string
3003
+ category: string
3004
+ title: string
3005
+ message: string
3006
+ actionUrl: string | null
3007
+ read: boolean
3008
+ readAt: string | null
3009
+ createdAt: string
3010
+ }
3011
+
3012
+ // ============================================================================
3013
+ // API Request/Response Types (Dashboard Observability)
3014
+ // ============================================================================
3015
+
3016
+ /**
3017
+ * Time range selector for dashboard metrics
3018
+ */
3019
+ type TimeRange = '1h' | '24h' | '7d' | '30d'
3020
+
3021
+ /**
3022
+ * Execution health metrics response
3023
+ * Success rate, P95 duration, execution counts, and trend data
3024
+ * trendData includes executionCount for throughput visualization (eliminates separate API call)
3025
+ */
3026
+ interface ExecutionHealthMetrics {
3027
+ successRate: number
3028
+ p95Duration: number
3029
+ totalExecutions: number
3030
+ trendData: Array<{
3031
+ time: string
3032
+ rate: number
3033
+ successCount: number
3034
+ errorCount: number
3035
+ warningCount: number
3036
+ executionCount: number
3037
+ }>
3038
+ statusCounts: { success: number; failed: number; pending: number; warning: number }
3039
+ peakPeriod: string
3040
+ granularity: 'hour' | 'day'
3041
+ }
3042
+
3043
+ /**
3044
+ * Error analysis metrics response
3045
+ * Error categories and top failing resources
3046
+ */
3047
+ interface ErrorAnalysisMetrics {
3048
+ totalErrors: number
3049
+ errorsByCategory: Array<{
3050
+ category: string
3051
+ count: number
3052
+ percentage: number
3053
+ }>
3054
+ topFailingResources: Array<{
3055
+ resourceId: string
3056
+ name: string
3057
+ errorCount: number
3058
+ failureRate: number
3059
+ }>
3060
+ }
3061
+
3062
+ /**
3063
+ * Business impact metrics response
3064
+ * ROI, labor savings, and cost analysis
3065
+ */
3066
+ interface BusinessImpactMetrics {
3067
+ totalSavingsUsd: number
3068
+ totalCostUsd: number
3069
+ netSavingsUsd: number
3070
+ roi: number
3071
+ }
3072
+
3073
+ /**
3074
+ * Cost breakdown metrics response
3075
+ * Per-resource cost analysis
3076
+ */
3077
+ interface CostBreakdownMetrics {
3078
+ resources: Array<{
3079
+ resourceId: string
3080
+ totalCostUsd: number
3081
+ executionCount: number
3082
+ avgCostUsd: number
3083
+ }>
3084
+ }
3085
+
3086
+ /**
3087
+ * Dashboard metrics response
3088
+ * Aggregates core observability metrics in a single response
3089
+ * Note: Throughput data is now included in executionHealth.trendData.executionCount
3090
+ */
3091
+ interface DashboardMetrics {
3092
+ executionHealth: ExecutionHealthMetrics
3093
+ costBreakdown: CostBreakdownMetrics
3094
+ businessImpact: BusinessImpactMetrics
3095
+ /** ISO timestamp of the currently active deployment, or null if none */
3096
+ activeDeploymentDate: string | null
3097
+ /** Deployment version of the active deployment, or null if none */
3098
+ activeDeploymentVersion: string | null
3099
+ }
3100
+
3101
+ // ============================================================================
3102
+ // Error Tracking Types
3103
+ // ============================================================================
3104
+
3105
+ /**
3106
+ * Error record for list view (ErrorBreakdownTable)
3107
+ */
3108
+ interface ErrorRecord {
3109
+ id: string // execution_errors.id
3110
+ timestamp: string // occurred_at
3111
+ errorType: string // error_type
3112
+ message: string // error_message
3113
+ executionId: string // execution_id
3114
+ resourceId: string // execution_logs.resource_id (via JOIN)
3115
+ resourceName: string // execution_logs.resource_id (TODO: resolve via registry)
3116
+ severity: 'critical' | 'warning' | 'info'
3117
+ category: ExecutionErrorCategory // error_category (moved from metadata to dedicated column)
3118
+ resolved: boolean // resolved flag (human acknowledgment, does not affect execution status)
3119
+ resolvedAt: string | null // timestamp when resolved
3120
+ resolvedBy: string | null // user ID who resolved
3121
+ }
3122
+
3123
+ /**
3124
+ * Full error detail for modal view (ErrorDetailsModal)
3125
+ */
3126
+ interface ErrorDetailFull extends ErrorRecord {
3127
+ stackTrace?: string // error_stack_trace
3128
+ retryAttempt?: number // metadata.retryAttempt
3129
+ stepName?: string // metadata.stepName
3130
+ stepSequence?: number // metadata.stepSequence
3131
+ errorContext?: Record<string, unknown> // metadata.errorContext
3132
+ executionContext?: Record<string, unknown> // metadata.executionContext
3133
+ }
3134
+
3135
+ /**
3136
+ * Error details API response (paginated)
3137
+ */
3138
+ interface ErrorDetailResponse {
3139
+ errors: ErrorRecord[]
3140
+ total: number
3141
+ page: number
3142
+ limit: number
3143
+ }
3144
+
3145
+ /**
3146
+ * Error trend data for time-series charts
3147
+ */
3148
+ interface ErrorTrend {
3149
+ time: string // Time bucket (ISO timestamp)
3150
+ errorCount: number // Total errors in bucket
3151
+ criticalCount: number // Critical errors in bucket
3152
+ warningCount: number // Warning errors in bucket
3153
+ infoCount: number // Info errors in bucket
3154
+ }
3155
+
3156
+ // ============================================================================
3157
+ // Cost Analytics Types (Time-Series)
3158
+ // ============================================================================
3159
+
3160
+ /**
3161
+ * Cost trend data point for time-series charts
3162
+ * Represents a single time bucket (hour or day)
3163
+ */
3164
+ interface CostTrendDataPoint {
3165
+ time: string // ISO timestamp (bucket start)
3166
+ totalCostUsd: number
3167
+ executionCount: number
3168
+ avgCostPerExecution: number
3169
+ }
3170
+
3171
+ /**
3172
+ * Cost trends response (time-series data)
3173
+ */
3174
+ interface CostTrendsResponse {
3175
+ trendData: CostTrendDataPoint[]
3176
+ granularity: 'hour' | 'day'
3177
+ totalCostUsd: number
3178
+ totalExecutions: number
3179
+ }
3180
+
3181
+ /**
3182
+ * Cost summary response with MTD and projections
3183
+ */
3184
+ interface CostSummaryResponse {
3185
+ current: {
3186
+ totalCostUsd: number
3187
+ executionCount: number
3188
+ }
3189
+ previous: {
3190
+ totalCostUsd: number
3191
+ executionCount: number
3192
+ }
3193
+ mtd: {
3194
+ totalCostUsd: number
3195
+ daysElapsed: number
3196
+ }
3197
+ projection: {
3198
+ monthlyCostUsd: number
3199
+ confidence: 'low' | 'medium' | 'high'
3200
+ }
3201
+ trend: {
3202
+ changePercent: number
3203
+ direction: 'up' | 'down' | 'flat'
3204
+ }
3205
+ }
3206
+
3207
+ /**
3208
+ * Cost by model data for model-level breakdown
3209
+ */
3210
+ interface CostByModelData {
3211
+ model: string
3212
+ totalCostUsd: number
3213
+ callCount: number
3214
+ totalInputTokens: number
3215
+ totalOutputTokens: number
3216
+ avgCostPerCall: number
3217
+ }
3218
+
3219
+ /**
3220
+ * Cost by model response
3221
+ */
3222
+ interface CostByModelResponse {
3223
+ models: CostByModelData[]
3224
+ totalCostUsd: number
3225
+ totalCallCount: number
3226
+ }
3227
+
3228
+ /**
3229
+ * Command queue task with flexible action system
3230
+ */
3231
+ interface Task extends OriginTracking {
3232
+ id: string
3233
+ organizationId: string
3234
+
3235
+ // NEW: Flexible action system
3236
+ actions: ActionConfig[]
3237
+ context: unknown
3238
+ selectedAction?: string
3239
+ actionPayload?: unknown
3240
+
3241
+ // Task metadata
3242
+ description?: string
3243
+ priority: number
3244
+
3245
+ /** Optional checkpoint identifier for grouping related human approval tasks */
3246
+ humanCheckpoint?: string
3247
+
3248
+ // Status (updated to include 'completed')
3249
+ status: TaskStatus
3250
+
3251
+ /**
3252
+ * Target resource tracking — mirrors origin columns.
3253
+ * Set when task is created; patchable to redirect execution to a different resource.
3254
+ */
3255
+ targetResourceId?: string
3256
+ targetResourceType?: 'agent' | 'workflow'
3257
+
3258
+ /**
3259
+ * Execution ID for the action that runs AFTER user approval.
3260
+ * NULL until execution starts.
3261
+ *
3262
+ * Naming distinction:
3263
+ * - originExecutionId = Parent execution that CREATED the HITL task
3264
+ * - targetExecutionId = Child execution that RUNS AFTER user approval
3265
+ */
3266
+ targetExecutionId?: string
3267
+
3268
+ createdAt: Date
3269
+ completedAt?: Date
3270
+ completedBy?: string
3271
+ expiresAt?: Date
3272
+ idempotencyKey?: string | null
3273
+ }
3274
+
3275
+ /**
3276
+ * Task status values
3277
+ * - pending: awaiting action
3278
+ * - processing: execution in progress after user approval
3279
+ * - completed: action was taken and execution succeeded
3280
+ * - failed: execution failed, task can be retried
3281
+ * - expired: timed out before action
3282
+ */
3283
+ type TaskStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'expired'
3284
+
3285
+ /**
3286
+ * Parameters for patching mutable metadata on a task
3287
+ */
3288
+ interface PatchTaskParams {
3289
+ humanCheckpoint?: string | null
3290
+ description?: string
3291
+ priority?: number
3292
+ context?: Record<string, unknown>
3293
+ actions?: unknown[]
3294
+ targetResourceId?: string | null
3295
+ targetResourceType?: 'agent' | 'workflow' | null
3296
+ targetExecutionId?: string
3297
+ status?: 'pending' | 'failed' | 'completed'
3298
+ }
3299
+
3300
+ /**
3301
+ * Checkpoint list item for sidebar grouping
3302
+ * The id field contains the resourceId of the human checkpoint
3303
+ */
3304
+ interface CheckpointListItem {
3305
+ /** Human checkpoint resourceId (or 'ungrouped' for tasks without checkpoint) */
3306
+ id: string
3307
+ /** Display name (same as id, or "Ungrouped" for null) */
3308
+ name: string
3309
+ /** Task count for this checkpoint */
3310
+ count: number
3311
+ }
3312
+
3313
+ /**
3314
+ * Status counts for pie chart display
3315
+ */
3316
+ interface StatusCounts {
3317
+ pending: number
3318
+ completed: number
3319
+ expired: number
3320
+ }
3321
+
3322
+ /**
3323
+ * Priority counts for donut chart display
3324
+ */
3325
+ interface PriorityCounts {
3326
+ critical: number
3327
+ high: number
3328
+ medium: number
3329
+ low: number
3330
+ }
3331
+
3332
+ /**
3333
+ * Response from GET /command-queue/checkpoints endpoint
3334
+ */
3335
+ interface CheckpointListResponse {
3336
+ checkpoints: CheckpointListItem[]
3337
+ /** Total tasks across all checkpoints */
3338
+ total: number
3339
+ /** Breakdown by status for donut chart */
3340
+ statusCounts: StatusCounts
3341
+ /** Breakdown by priority for donut chart */
3342
+ priorityCounts: PriorityCounts
3343
+ }
3344
+
3345
+ /**
3346
+ * Execution history item.
3347
+ * Represents a single execution triggered by a schedule.
3348
+ */
3349
+ declare const ExecutionHistoryItemSchema = z.object({
3350
+ id: z.string().uuid(),
3351
+ createdAt: z.string().datetime(),
3352
+ status: z.enum(['running', 'completed', 'failed', 'cancelled']),
3353
+ step: z.number().int().nullable(),
3354
+ itemLabel: z.string().nullable(),
3355
+ duration: z.number().nullable(), // milliseconds
3356
+ error: z.string().nullable()
3357
+ })
3358
+
3359
+ /**
3360
+ * Execution history response.
3361
+ * Returned by GET /schedules/:id/executions with pagination.
3362
+ */
3363
+ declare const ExecutionHistoryResponseSchema = z.object({
3364
+ executions: z.array(ExecutionHistoryItemSchema),
3365
+ total: z.number().int(),
3366
+ limit: z.number().int(),
3367
+ offset: z.number().int()
3368
+ })
3369
+ type ExecutionHistoryItem = z.infer<typeof ExecutionHistoryItemSchema>
3370
+ type ExecutionHistoryResponse = z.infer<typeof ExecutionHistoryResponseSchema>
3371
+
3372
+ type ActivityType =
3373
+ | 'workflow_execution'
3374
+ | 'agent_run'
3375
+ | 'hitl_action'
3376
+ | 'webhook_received'
3377
+ | 'webhook_executed'
3378
+ | 'webhook_failed'
3379
+ | 'credential_change'
3380
+ | 'api_key_change'
3381
+ | 'deployment_change'
3382
+ | 'membership_change'
3383
+
3384
+ type ActivityStatus = 'success' | 'failure' | 'pending' | 'approved' | 'rejected' | 'completed'
3385
+
3386
+ interface Activity {
3387
+ id: string
3388
+ organizationId: string
3389
+ activityType: ActivityType
3390
+ status: ActivityStatus
3391
+ title: string
3392
+ description: string | null
3393
+ entityType: string
3394
+ entityId: string
3395
+ entityName: string | null
3396
+ metadata: Record<string, unknown> | null
3397
+ actorId: string | null
3398
+ actorType: string | null
3399
+ occurredAt: Date
3400
+ createdAt: Date
3401
+ }
3402
+
3403
+ export type { AIResourceDefinition, APIExecutionDetail, APIExecutionListResponse, Activity, ActivityType, ChatMessage, CheckpointListResponse, CostByModelResponse, CostSummaryResponse, CostTrendsResponse, DashboardMetrics, ErrorAnalysisMetrics, ErrorDetailFull, ErrorDetailResponse, ErrorTrend, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionStatus, MembershipFeatureConfig, MembershipWithDetails, MessageEvent, NotificationDTO, OrgFeatureConfig, PatchTaskParams, ResourceDefinition, ResourceStatus, ResourceType, SessionDTO, SessionTokenUsage, SupabaseUserProfile, Task, TaskSchedule, TaskScheduleConfig, TaskStatus, TimeRange, UserConfig };