@elevasis/ui 1.3.5 → 1.3.7

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,3800 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Workflow-specific logging types and utilities
5
+ */
6
+
7
+ interface WorkflowExecutionContext$1 {
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$1 {
17
+ type: 'workflow';
18
+ contextType: 'workflow-failure';
19
+ executionId: string;
20
+ workflowId: string;
21
+ error: string;
22
+ }
23
+ interface StepStartedContext$1 {
24
+ type: 'workflow';
25
+ contextType: 'step-started';
26
+ stepId: string;
27
+ stepStatus: 'started';
28
+ input: unknown;
29
+ startTime: number;
30
+ }
31
+ interface StepCompletedContext$1 {
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$1 {
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$1 {
53
+ type: 'workflow';
54
+ contextType: 'conditional-route';
55
+ stepId: string;
56
+ target: string;
57
+ error?: string;
58
+ }
59
+ interface ExecutionPathContext$1 {
60
+ type: 'workflow';
61
+ contextType: 'execution-path';
62
+ executionPath: string[];
63
+ }
64
+ type WorkflowLogContext$1 = WorkflowExecutionContext$1 | WorkflowFailureContext$1 | StepStartedContext$1 | StepCompletedContext$1 | StepFailedContext$1 | ConditionalRouteContext$1 | ExecutionPathContext$1;
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$1 = 'initialization' | 'iteration' | 'completion';
80
+ /**
81
+ * Iteration event types
82
+ * Activities that occur during agent iterations
83
+ */
84
+ type IterationEventType$1 = 'reasoning' | 'action' | 'tool-call';
85
+ /**
86
+ * Base fields shared by all lifecycle events
87
+ */
88
+ interface AgentLifecycleEventBase$1 {
89
+ type: 'agent';
90
+ agentId: string;
91
+ lifecycle: AgentLifecycle$1;
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$1 extends AgentLifecycleEventBase$1 {
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$1 extends AgentLifecycleEventBase$1 {
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$1 extends AgentLifecycleEventBase$1 {
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$1 = AgentLifecycleStartedEvent$1 | AgentLifecycleCompletedEvent$1 | AgentLifecycleFailedEvent$1;
136
+ /**
137
+ * Placeholder data for MVP
138
+ * Will be typed per actionType in future
139
+ */
140
+ interface ActionPlaceholderData$1 {
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$1 {
148
+ type: 'agent';
149
+ agentId: string;
150
+ lifecycle: 'iteration';
151
+ eventType: IterationEventType$1;
152
+ iteration: number;
153
+ sessionId?: string;
154
+ startTime: number;
155
+ endTime: number;
156
+ duration: number;
157
+ output?: string;
158
+ actionType?: string;
159
+ data?: ActionPlaceholderData$1;
160
+ }
161
+ /**
162
+ * Tool call event - captures individual tool executions during iterations
163
+ * Provides granular timing for each tool invocation
164
+ */
165
+ interface AgentToolCallEvent$1 {
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$1 = AgentLifecycleEvent$1 | AgentIterationEvent$1 | AgentToolCallEvent$1;
186
+
187
+ /**
188
+ * Base execution logger for Execution Engine
189
+ */
190
+ type ExecutionLogLevel$1 = 'debug' | 'info' | 'warn' | 'error';
191
+
192
+ type LogContext$1 = WorkflowLogContext$1 | AgentLogContext$1;
193
+ interface ExecutionLogMessage$1 {
194
+ level: ExecutionLogLevel$1;
195
+ message: string;
196
+ timestamp: number;
197
+ context?: LogContext$1;
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$1 = 'pending' | 'running' | 'completed' | 'failed' | 'warning';
2829
+ interface APIExecutionSummary {
2830
+ id: string;
2831
+ status: ExecutionStatus$1;
2832
+ startTime: number;
2833
+ endTime?: number;
2834
+ resourceStatus?: ResourceStatus;
2835
+ }
2836
+ interface APIExecutionDetail extends APIExecutionSummary {
2837
+ executionLogs: ExecutionLogMessage$1[];
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
+ * Workflow-specific logging types and utilities
2852
+ */
2853
+
2854
+
2855
+
2856
+ // Workflow start/end log context
2857
+ interface WorkflowExecutionContext {
2858
+ type: 'workflow'
2859
+ contextType: 'workflow-execution'
2860
+ executionId: string
2861
+ workflowId: string
2862
+ workflowName?: string
2863
+ organizationId: string
2864
+ executionPath?: string[]
2865
+ }
2866
+
2867
+ // Workflow failure log context
2868
+ interface WorkflowFailureContext {
2869
+ type: 'workflow'
2870
+ contextType: 'workflow-failure'
2871
+ executionId: string
2872
+ workflowId: string
2873
+ error: string
2874
+ }
2875
+
2876
+ // Step started log context
2877
+ interface StepStartedContext {
2878
+ type: 'workflow'
2879
+ contextType: 'step-started'
2880
+ stepId: string
2881
+ stepStatus: 'started'
2882
+ input: unknown
2883
+ startTime: number // Explicit start timestamp for timeline
2884
+ }
2885
+
2886
+ // Step completed log context
2887
+ interface StepCompletedContext {
2888
+ type: 'workflow'
2889
+ contextType: 'step-completed'
2890
+ stepId: string
2891
+ stepStatus: 'completed'
2892
+ output: unknown
2893
+ duration: number
2894
+ isTerminal: boolean
2895
+ startTime: number // Explicit start timestamp for timeline
2896
+ endTime: number // Explicit end timestamp for timeline
2897
+ }
2898
+
2899
+ // Step failed log context
2900
+ interface StepFailedContext {
2901
+ type: 'workflow'
2902
+ contextType: 'step-failed'
2903
+ stepId: string
2904
+ stepStatus: 'failed'
2905
+ error: string
2906
+ duration: number
2907
+ startTime: number // Explicit start timestamp for timeline
2908
+ endTime: number // Explicit end timestamp for timeline
2909
+ }
2910
+
2911
+ // Conditional routing log context
2912
+ interface ConditionalRouteContext {
2913
+ type: 'workflow'
2914
+ contextType: 'conditional-route'
2915
+ stepId: string
2916
+ target: string
2917
+ error?: string
2918
+ }
2919
+
2920
+ // Execution path log context
2921
+ interface ExecutionPathContext {
2922
+ type: 'workflow'
2923
+ contextType: 'execution-path'
2924
+ executionPath: string[]
2925
+ }
2926
+
2927
+ // Union of all workflow log contexts
2928
+ type WorkflowLogContext =
2929
+ | WorkflowExecutionContext
2930
+ | WorkflowFailureContext
2931
+ | StepStartedContext
2932
+ | StepCompletedContext
2933
+ | StepFailedContext
2934
+ | ConditionalRouteContext
2935
+ | ExecutionPathContext
2936
+
2937
+ /**
2938
+ * Agent-specific logging types
2939
+ * Simplified 2-event model: lifecycle, iteration
2940
+ *
2941
+ * Design Philosophy:
2942
+ * - LIFECYCLE EVENTS: Structural checkpoints (initialization, iteration, completion)
2943
+ * - ITERATION EVENTS: Execution activities (reasoning, actions during iterations)
2944
+ */
2945
+
2946
+
2947
+
2948
+ // ============================================================================
2949
+ // FORMAL TYPES
2950
+ // ============================================================================
2951
+
2952
+ /**
2953
+ * Agent lifecycle stages
2954
+ * Universal checkpoints that apply to all agent executions
2955
+ */
2956
+ type AgentLifecycle = 'initialization' | 'iteration' | 'completion'
2957
+
2958
+ /**
2959
+ * Iteration event types
2960
+ * Activities that occur during agent iterations
2961
+ */
2962
+ type IterationEventType = 'reasoning' | 'action' | 'tool-call'
2963
+
2964
+ // ============================================================================
2965
+ // LIFECYCLE EVENTS (Structural Checkpoints)
2966
+ // ============================================================================
2967
+
2968
+ /**
2969
+ * Base fields shared by all lifecycle events
2970
+ */
2971
+ interface AgentLifecycleEventBase {
2972
+ type: 'agent'
2973
+ agentId: string
2974
+ lifecycle: AgentLifecycle
2975
+ sessionId?: string // Optional: only present when agent runs in session context
2976
+ }
2977
+
2978
+ /**
2979
+ * Lifecycle started event - emitted when a phase begins
2980
+ * REQUIRED: startTime (phase has started, no end yet)
2981
+ */
2982
+ interface AgentLifecycleStartedEvent extends AgentLifecycleEventBase {
2983
+ stage: 'started'
2984
+ startTime: number // REQUIRED: Phase start timestamp
2985
+ iteration?: number // Only for 'iteration' lifecycle
2986
+ }
2987
+
2988
+ /**
2989
+ * Lifecycle completed event - emitted when a phase succeeds
2990
+ * REQUIRED: startTime, endTime, duration (phase has finished successfully)
2991
+ */
2992
+ interface AgentLifecycleCompletedEvent extends AgentLifecycleEventBase {
2993
+ stage: 'completed'
2994
+ startTime: number // REQUIRED: Phase start timestamp
2995
+ endTime: number // REQUIRED: Phase end timestamp
2996
+ duration: number // REQUIRED: Calculated duration (endTime - startTime)
2997
+ iteration?: number // Only for 'iteration' lifecycle
2998
+
2999
+ // Optional fields specific to certain lifecycles
3000
+ attempts?: number // Only for 'completion' lifecycle (tracks output generation attempts: 1 or 2)
3001
+ memorySize?: {
3002
+ sessionMemoryKeys: number
3003
+ historyEntries: number
3004
+ } // Only for 'completion' lifecycle (memory snapshot metadata)
3005
+ }
3006
+
3007
+ /**
3008
+ * Lifecycle failed event - emitted when a phase fails
3009
+ * REQUIRED: startTime, endTime, duration, error (phase has finished with error)
3010
+ */
3011
+ interface AgentLifecycleFailedEvent extends AgentLifecycleEventBase {
3012
+ stage: 'failed'
3013
+ startTime: number // REQUIRED: Phase start timestamp
3014
+ endTime: number // REQUIRED: Phase end timestamp
3015
+ duration: number // REQUIRED: Calculated duration (endTime - startTime)
3016
+ error: string // REQUIRED: Error message
3017
+ iteration?: number // Only for 'iteration' lifecycle
3018
+ }
3019
+
3020
+ /**
3021
+ * Union type for all lifecycle events
3022
+ * Discriminated by 'stage' field for type narrowing
3023
+ */
3024
+ type AgentLifecycleEvent = AgentLifecycleStartedEvent | AgentLifecycleCompletedEvent | AgentLifecycleFailedEvent
3025
+
3026
+ // ============================================================================
3027
+ // ITERATION EVENTS (Execution Activities)
3028
+ // ============================================================================
3029
+
3030
+ /**
3031
+ * Placeholder data for MVP
3032
+ * Will be typed per actionType in future
3033
+ */
3034
+ interface ActionPlaceholderData {
3035
+ message: string
3036
+ }
3037
+
3038
+ /**
3039
+ * Iteration event - captures activities during agent iterations
3040
+ * Consolidates reasoning (LLM thought process) and actions (tool use, memory ops, etc.)
3041
+ */
3042
+ interface AgentIterationEvent {
3043
+ type: 'agent'
3044
+ agentId: string
3045
+ lifecycle: 'iteration' // Always iteration
3046
+ eventType: IterationEventType
3047
+ iteration: number
3048
+ sessionId?: string // Optional: only present when agent runs in session context
3049
+
3050
+ // Timeline timing fields (v2 - Clean Break)
3051
+ startTime: number // Activity start timestamp
3052
+ endTime: number // Activity end timestamp
3053
+ duration: number // Calculated duration (endTime - startTime)
3054
+
3055
+ // Conditional fields based on eventType
3056
+ output?: string // For reasoning events
3057
+ actionType?: string // For action events (tool-use, delegate, memory-write, etc.)
3058
+ data?: ActionPlaceholderData // For action events
3059
+ }
3060
+
3061
+ /**
3062
+ * Tool call event - captures individual tool executions during iterations
3063
+ * Provides granular timing for each tool invocation
3064
+ */
3065
+ interface AgentToolCallEvent {
3066
+ type: 'agent'
3067
+ agentId: string
3068
+ lifecycle: 'iteration' // Always iteration
3069
+ eventType: 'tool-call' // Specific event type for tool calls
3070
+ iteration: number
3071
+ sessionId?: string // Optional: only present when agent runs in session context
3072
+
3073
+ // Tool identification and timing
3074
+ toolName: string // Tool identifier
3075
+ startTime: number // Tool call start timestamp
3076
+ endTime: number // Tool call end timestamp
3077
+ duration: number // Calculated duration
3078
+
3079
+ // Execution results
3080
+ success: boolean // Whether tool execution succeeded
3081
+ error?: string // Error message if failed
3082
+ input?: Record<string, unknown> // Tool input parameters
3083
+ output?: unknown // Tool output result
3084
+ }
3085
+
3086
+ // ============================================================================
3087
+ // UNION TYPES
3088
+ // ============================================================================
3089
+
3090
+ /**
3091
+ * Union type for all agent log contexts
3092
+ * 3 event types total (lifecycle, iteration, tool-call)
3093
+ */
3094
+ type AgentLogContext = AgentLifecycleEvent | AgentIterationEvent | AgentToolCallEvent
3095
+
3096
+ /**
3097
+ * Base execution logger for Execution Engine
3098
+ */
3099
+ type ExecutionLogLevel = 'debug' | 'info' | 'warn' | 'error'
3100
+
3101
+
3102
+ // Union type for all contexts
3103
+ type LogContext = WorkflowLogContext | AgentLogContext
3104
+
3105
+ // Updated interface with consolidated context
3106
+ interface ExecutionLogMessage {
3107
+ level: ExecutionLogLevel
3108
+ message: string
3109
+ timestamp: number
3110
+ context?: LogContext
3111
+ }
3112
+
3113
+ /**
3114
+ * Shared form field types for dynamic form generation
3115
+ * Used by: Command Queue, Execution Runner UI, future form-based features
3116
+ */
3117
+
3118
+ /**
3119
+ * Supported form field types for action payloads
3120
+ * Maps to Mantine form components
3121
+ */
3122
+ type FormFieldType =
3123
+ | 'text' // TextInput
3124
+ | 'textarea' // Textarea
3125
+ | 'number' // NumberInput
3126
+ | 'select' // Select dropdown
3127
+ | 'checkbox' // Checkbox
3128
+ | 'radio' // Radio group
3129
+ | 'richtext' // Rich text editor (TipTap)
3130
+
3131
+ /**
3132
+ * Form field definition
3133
+ */
3134
+ interface FormField {
3135
+ /** Field key in payload object */
3136
+ name: string
3137
+
3138
+ /** Field label for UI */
3139
+ label: string
3140
+
3141
+ /** Field type (determines UI component) */
3142
+ type: FormFieldType
3143
+
3144
+ /** Default value */
3145
+ defaultValue?: unknown
3146
+
3147
+ /** Required field */
3148
+ required?: boolean
3149
+
3150
+ /** Placeholder text */
3151
+ placeholder?: string
3152
+
3153
+ /** Help text */
3154
+ description?: string
3155
+
3156
+ /** Options for select/radio */
3157
+ options?: Array<{
3158
+ label: string
3159
+ value: string | number
3160
+ }>
3161
+
3162
+ /** Min/max for number */
3163
+ min?: number
3164
+ max?: number
3165
+
3166
+ /** Path to context value for pre-filling (dot notation, e.g., 'proposal.summary') */
3167
+ defaultValueFromContext?: string
3168
+ }
3169
+
3170
+ /**
3171
+ * Form schema for action payload collection
3172
+ */
3173
+ interface FormSchema {
3174
+ /** Form title */
3175
+ title?: string
3176
+
3177
+ /** Form description */
3178
+ description?: string
3179
+
3180
+ /** Form fields */
3181
+ fields: FormField[]
3182
+ }
3183
+
3184
+ /**
3185
+ * Error categories for observability grouping and classification.
3186
+ * Used to categorize errors in the execution_errors table metadata.
3187
+ */
3188
+ type ExecutionErrorCategory = 'llm' | 'tool' | 'workflow' | 'agent' | 'validation' | 'system'
3189
+
3190
+ // ============================================================================
3191
+ // API Request/Response Types (Dashboard Observability)
3192
+ // ============================================================================
3193
+
3194
+ /**
3195
+ * Time range selector for dashboard metrics
3196
+ */
3197
+ type TimeRange = '1h' | '24h' | '7d' | '30d'
3198
+
3199
+ /**
3200
+ * Execution health metrics response
3201
+ * Success rate, P95 duration, execution counts, and trend data
3202
+ * trendData includes executionCount for throughput visualization (eliminates separate API call)
3203
+ */
3204
+ interface ExecutionHealthMetrics {
3205
+ successRate: number
3206
+ p95Duration: number
3207
+ totalExecutions: number
3208
+ trendData: Array<{
3209
+ time: string
3210
+ rate: number
3211
+ successCount: number
3212
+ errorCount: number
3213
+ warningCount: number
3214
+ executionCount: number
3215
+ }>
3216
+ statusCounts: { success: number; failed: number; pending: number; warning: number }
3217
+ peakPeriod: string
3218
+ granularity: 'hour' | 'day'
3219
+ }
3220
+
3221
+ /**
3222
+ * Error analysis metrics response
3223
+ * Error categories and top failing resources
3224
+ */
3225
+ interface ErrorAnalysisMetrics {
3226
+ totalErrors: number
3227
+ errorsByCategory: Array<{
3228
+ category: string
3229
+ count: number
3230
+ percentage: number
3231
+ }>
3232
+ topFailingResources: Array<{
3233
+ resourceId: string
3234
+ name: string
3235
+ errorCount: number
3236
+ failureRate: number
3237
+ }>
3238
+ }
3239
+
3240
+ /**
3241
+ * Business impact metrics response
3242
+ * ROI, labor savings, and cost analysis
3243
+ */
3244
+ interface BusinessImpactMetrics {
3245
+ totalSavingsUsd: number
3246
+ totalCostUsd: number
3247
+ netSavingsUsd: number
3248
+ roi: number
3249
+ }
3250
+
3251
+ /**
3252
+ * Cost breakdown metrics response
3253
+ * Per-resource cost analysis
3254
+ */
3255
+ interface CostBreakdownMetrics {
3256
+ resources: Array<{
3257
+ resourceId: string
3258
+ totalCostUsd: number
3259
+ executionCount: number
3260
+ avgCostUsd: number
3261
+ }>
3262
+ }
3263
+
3264
+ /**
3265
+ * Dashboard metrics response
3266
+ * Aggregates core observability metrics in a single response
3267
+ * Note: Throughput data is now included in executionHealth.trendData.executionCount
3268
+ */
3269
+ interface DashboardMetrics {
3270
+ executionHealth: ExecutionHealthMetrics
3271
+ costBreakdown: CostBreakdownMetrics
3272
+ businessImpact: BusinessImpactMetrics
3273
+ /** ISO timestamp of the currently active deployment, or null if none */
3274
+ activeDeploymentDate: string | null
3275
+ /** Deployment version of the active deployment, or null if none */
3276
+ activeDeploymentVersion: string | null
3277
+ }
3278
+
3279
+ // ============================================================================
3280
+ // Error Tracking Types
3281
+ // ============================================================================
3282
+
3283
+ /**
3284
+ * Error record for list view (ErrorBreakdownTable)
3285
+ */
3286
+ interface ErrorRecord {
3287
+ id: string // execution_errors.id
3288
+ timestamp: string // occurred_at
3289
+ errorType: string // error_type
3290
+ message: string // error_message
3291
+ executionId: string // execution_id
3292
+ resourceId: string // execution_logs.resource_id (via JOIN)
3293
+ resourceName: string // execution_logs.resource_id (TODO: resolve via registry)
3294
+ severity: 'critical' | 'warning' | 'info'
3295
+ category: ExecutionErrorCategory // error_category (moved from metadata to dedicated column)
3296
+ resolved: boolean // resolved flag (human acknowledgment, does not affect execution status)
3297
+ resolvedAt: string | null // timestamp when resolved
3298
+ resolvedBy: string | null // user ID who resolved
3299
+ }
3300
+
3301
+ /**
3302
+ * Full error detail for modal view (ErrorDetailsModal)
3303
+ */
3304
+ interface ErrorDetailFull extends ErrorRecord {
3305
+ stackTrace?: string // error_stack_trace
3306
+ retryAttempt?: number // metadata.retryAttempt
3307
+ stepName?: string // metadata.stepName
3308
+ stepSequence?: number // metadata.stepSequence
3309
+ errorContext?: Record<string, unknown> // metadata.errorContext
3310
+ executionContext?: Record<string, unknown> // metadata.executionContext
3311
+ }
3312
+
3313
+ /**
3314
+ * Error details API response (paginated)
3315
+ */
3316
+ interface ErrorDetailResponse {
3317
+ errors: ErrorRecord[]
3318
+ total: number
3319
+ page: number
3320
+ limit: number
3321
+ }
3322
+
3323
+ /**
3324
+ * Error trend data for time-series charts
3325
+ */
3326
+ interface ErrorTrend {
3327
+ time: string // Time bucket (ISO timestamp)
3328
+ errorCount: number // Total errors in bucket
3329
+ criticalCount: number // Critical errors in bucket
3330
+ warningCount: number // Warning errors in bucket
3331
+ infoCount: number // Info errors in bucket
3332
+ }
3333
+
3334
+ // ============================================================================
3335
+ // Cost Analytics Types (Time-Series)
3336
+ // ============================================================================
3337
+
3338
+ /**
3339
+ * Cost trend data point for time-series charts
3340
+ * Represents a single time bucket (hour or day)
3341
+ */
3342
+ interface CostTrendDataPoint {
3343
+ time: string // ISO timestamp (bucket start)
3344
+ totalCostUsd: number
3345
+ executionCount: number
3346
+ avgCostPerExecution: number
3347
+ }
3348
+
3349
+ /**
3350
+ * Cost trends response (time-series data)
3351
+ */
3352
+ interface CostTrendsResponse {
3353
+ trendData: CostTrendDataPoint[]
3354
+ granularity: 'hour' | 'day'
3355
+ totalCostUsd: number
3356
+ totalExecutions: number
3357
+ }
3358
+
3359
+ /**
3360
+ * Cost summary response with MTD and projections
3361
+ */
3362
+ interface CostSummaryResponse {
3363
+ current: {
3364
+ totalCostUsd: number
3365
+ executionCount: number
3366
+ }
3367
+ previous: {
3368
+ totalCostUsd: number
3369
+ executionCount: number
3370
+ }
3371
+ mtd: {
3372
+ totalCostUsd: number
3373
+ daysElapsed: number
3374
+ }
3375
+ projection: {
3376
+ monthlyCostUsd: number
3377
+ confidence: 'low' | 'medium' | 'high'
3378
+ }
3379
+ trend: {
3380
+ changePercent: number
3381
+ direction: 'up' | 'down' | 'flat'
3382
+ }
3383
+ }
3384
+
3385
+ /**
3386
+ * Cost by model data for model-level breakdown
3387
+ */
3388
+ interface CostByModelData {
3389
+ model: string
3390
+ totalCostUsd: number
3391
+ callCount: number
3392
+ totalInputTokens: number
3393
+ totalOutputTokens: number
3394
+ avgCostPerCall: number
3395
+ }
3396
+
3397
+ /**
3398
+ * Cost by model response
3399
+ */
3400
+ interface CostByModelResponse {
3401
+ models: CostByModelData[]
3402
+ totalCostUsd: number
3403
+ totalCallCount: number
3404
+ }
3405
+
3406
+ /**
3407
+ * Action configuration for HITL tasks
3408
+ * Defines available user actions and their behavior
3409
+ */
3410
+ interface ActionConfig {
3411
+ /** Unique action identifier (e.g., 'approve', 'retry', 'escalate') */
3412
+ id: string
3413
+
3414
+ /** Display label for UI button */
3415
+ label: string
3416
+
3417
+ /** Button variant/style */
3418
+ type: 'primary' | 'secondary' | 'danger' | 'outline'
3419
+
3420
+ /** Tabler icon name (e.g., 'IconCheck', 'IconRefresh') */
3421
+ icon?: string
3422
+
3423
+ /** Button color (Mantine theme colors) */
3424
+ color?: string
3425
+
3426
+ /** Button variant (Mantine button variant, e.g., 'light', 'filled', 'outline') */
3427
+ variant?: string
3428
+
3429
+ /** Execution target (agent/workflow to invoke) */
3430
+ target?: {
3431
+ resourceType: 'agent' | 'workflow'
3432
+ resourceId: string
3433
+ /**
3434
+ * Optional session ID for agent continuation.
3435
+ * If provided, invokes a new turn on the existing session instead of standalone execution.
3436
+ * Only valid when resourceType is 'agent'.
3437
+ */
3438
+ sessionId?: string
3439
+ }
3440
+
3441
+ /** Form schema for collecting action-specific data */
3442
+ form?: FormSchema
3443
+
3444
+ /** Payload template for pre-filling forms */
3445
+ payloadTemplate?: unknown
3446
+
3447
+ /** Requires confirmation dialog */
3448
+ requiresConfirmation?: boolean
3449
+
3450
+ /** Confirmation message */
3451
+ confirmationMessage?: string
3452
+
3453
+ /** Help text / tooltip */
3454
+ description?: string
3455
+ }
3456
+
3457
+ /**
3458
+ * Origin resource type - where an execution/task originated from.
3459
+ * Used for audit trails and tracking execution lineage.
3460
+ */
3461
+ type OriginResourceType = 'agent' | 'workflow' | 'scheduler' | 'api'
3462
+
3463
+ /**
3464
+ * Origin tracking metadata - who/what created this execution/task.
3465
+ * Used by both TaskScheduler and CommandQueue for complete audit trails.
3466
+ */
3467
+ interface OriginTracking {
3468
+ originExecutionId: string
3469
+ originResourceType: OriginResourceType
3470
+ originResourceId: string
3471
+ }
3472
+
3473
+ /**
3474
+ * Command queue task with flexible action system
3475
+ */
3476
+ interface Task extends OriginTracking {
3477
+ id: string
3478
+ organizationId: string
3479
+
3480
+ // NEW: Flexible action system
3481
+ actions: ActionConfig[]
3482
+ context: unknown
3483
+ selectedAction?: string
3484
+ actionPayload?: unknown
3485
+
3486
+ // Task metadata
3487
+ description?: string
3488
+ priority: number
3489
+
3490
+ /** Optional checkpoint identifier for grouping related human approval tasks */
3491
+ humanCheckpoint?: string
3492
+
3493
+ // Status (updated to include 'completed')
3494
+ status: TaskStatus
3495
+
3496
+ /**
3497
+ * Target resource tracking — mirrors origin columns.
3498
+ * Set when task is created; patchable to redirect execution to a different resource.
3499
+ */
3500
+ targetResourceId?: string
3501
+ targetResourceType?: 'agent' | 'workflow'
3502
+
3503
+ /**
3504
+ * Execution ID for the action that runs AFTER user approval.
3505
+ * NULL until execution starts.
3506
+ *
3507
+ * Naming distinction:
3508
+ * - originExecutionId = Parent execution that CREATED the HITL task
3509
+ * - targetExecutionId = Child execution that RUNS AFTER user approval
3510
+ */
3511
+ targetExecutionId?: string
3512
+
3513
+ createdAt: Date
3514
+ completedAt?: Date
3515
+ completedBy?: string
3516
+ expiresAt?: Date
3517
+ idempotencyKey?: string | null
3518
+ }
3519
+
3520
+ /**
3521
+ * Task status values
3522
+ * - pending: awaiting action
3523
+ * - processing: execution in progress after user approval
3524
+ * - completed: action was taken and execution succeeded
3525
+ * - failed: execution failed, task can be retried
3526
+ * - expired: timed out before action
3527
+ */
3528
+ type TaskStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'expired'
3529
+
3530
+ /**
3531
+ * Parameters for patching mutable metadata on a task
3532
+ */
3533
+ interface PatchTaskParams {
3534
+ humanCheckpoint?: string | null
3535
+ description?: string
3536
+ priority?: number
3537
+ context?: Record<string, unknown>
3538
+ actions?: unknown[]
3539
+ targetResourceId?: string | null
3540
+ targetResourceType?: 'agent' | 'workflow' | null
3541
+ targetExecutionId?: string
3542
+ status?: 'pending' | 'failed' | 'completed'
3543
+ }
3544
+
3545
+ /**
3546
+ * Checkpoint list item for sidebar grouping
3547
+ * The id field contains the resourceId of the human checkpoint
3548
+ */
3549
+ interface CheckpointListItem {
3550
+ /** Human checkpoint resourceId (or 'ungrouped' for tasks without checkpoint) */
3551
+ id: string
3552
+ /** Display name (same as id, or "Ungrouped" for null) */
3553
+ name: string
3554
+ /** Task count for this checkpoint */
3555
+ count: number
3556
+ }
3557
+
3558
+ /**
3559
+ * Status counts for pie chart display
3560
+ */
3561
+ interface StatusCounts {
3562
+ pending: number
3563
+ completed: number
3564
+ expired: number
3565
+ }
3566
+
3567
+ /**
3568
+ * Priority counts for donut chart display
3569
+ */
3570
+ interface PriorityCounts {
3571
+ critical: number
3572
+ high: number
3573
+ medium: number
3574
+ low: number
3575
+ }
3576
+
3577
+ /**
3578
+ * Response from GET /command-queue/checkpoints endpoint
3579
+ */
3580
+ interface CheckpointListResponse {
3581
+ checkpoints: CheckpointListItem[]
3582
+ /** Total tasks across all checkpoints */
3583
+ total: number
3584
+ /** Breakdown by status for donut chart */
3585
+ statusCounts: StatusCounts
3586
+ /** Breakdown by priority for donut chart */
3587
+ priorityCounts: PriorityCounts
3588
+ }
3589
+
3590
+ /**
3591
+ * Wire-format DTO for notification API responses.
3592
+ * Dates are ISO 8601 strings (not Date objects like the domain Notification type).
3593
+ * Used by frontend hooks that consume /api/notifications.
3594
+ */
3595
+ interface NotificationDTO {
3596
+ id: string
3597
+ userId: string
3598
+ organizationId: string
3599
+ category: string
3600
+ title: string
3601
+ message: string
3602
+ actionUrl: string | null
3603
+ read: boolean
3604
+ readAt: string | null
3605
+ createdAt: string
3606
+ }
3607
+
3608
+ // Execution status type shared between API and UI
3609
+ type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'warning'
3610
+
3611
+ /**
3612
+ * Execution Runner Types
3613
+ *
3614
+ * Shared types for the Execution Runner UI feature.
3615
+ * Used by both API (apps/api) and frontend (apps/command-center).
3616
+ */
3617
+
3618
+
3619
+
3620
+ // ============================================================================
3621
+ // EXECUTION METRICS
3622
+ // ============================================================================
3623
+
3624
+ interface ExecutionMetrics {
3625
+ tokenCount?: number
3626
+ stepCount?: number
3627
+ toolCallCount?: number
3628
+ }
3629
+
3630
+ // ============================================================================
3631
+ // EXECUTION HISTORY TYPES
3632
+ // ============================================================================
3633
+
3634
+ interface ExecutionSummary {
3635
+ id: string
3636
+ resourceId: string
3637
+ resourceName: string
3638
+ status: ExecutionStatus
3639
+ startedAt: string
3640
+ completedAt?: string
3641
+ durationMs?: number
3642
+ metrics?: ExecutionMetrics
3643
+ input?: unknown
3644
+ output?: unknown
3645
+ error?: { message: string }
3646
+ }
3647
+
3648
+ /**
3649
+ * Execution history item.
3650
+ * Represents a single execution triggered by a schedule.
3651
+ */
3652
+ declare const ExecutionHistoryItemSchema = z.object({
3653
+ id: z.string().uuid(),
3654
+ createdAt: z.string().datetime(),
3655
+ status: z.enum(['running', 'completed', 'failed', 'cancelled']),
3656
+ step: z.number().int().nullable(),
3657
+ itemLabel: z.string().nullable(),
3658
+ duration: z.number().nullable(), // milliseconds
3659
+ error: z.string().nullable()
3660
+ })
3661
+
3662
+ /**
3663
+ * Execution history response.
3664
+ * Returned by GET /schedules/:id/executions with pagination.
3665
+ */
3666
+ declare const ExecutionHistoryResponseSchema = z.object({
3667
+ executions: z.array(ExecutionHistoryItemSchema),
3668
+ total: z.number().int(),
3669
+ limit: z.number().int(),
3670
+ offset: z.number().int()
3671
+ })
3672
+ type ExecutionHistoryItem = z.infer<typeof ExecutionHistoryItemSchema>
3673
+ type ExecutionHistoryResponse = z.infer<typeof ExecutionHistoryResponseSchema>
3674
+
3675
+ type ActivityType =
3676
+ | 'workflow_execution'
3677
+ | 'agent_run'
3678
+ | 'hitl_action'
3679
+ | 'webhook_received'
3680
+ | 'webhook_executed'
3681
+ | 'webhook_failed'
3682
+ | 'credential_change'
3683
+ | 'api_key_change'
3684
+ | 'deployment_change'
3685
+ | 'membership_change'
3686
+
3687
+ type ActivityStatus = 'success' | 'failure' | 'pending' | 'approved' | 'rejected' | 'completed'
3688
+
3689
+ interface Activity {
3690
+ id: string
3691
+ organizationId: string
3692
+ activityType: ActivityType
3693
+ status: ActivityStatus
3694
+ title: string
3695
+ description: string | null
3696
+ entityType: string
3697
+ entityId: string
3698
+ entityName: string | null
3699
+ metadata: Record<string, unknown> | null
3700
+ actorId: string | null
3701
+ actorType: string | null
3702
+ occurredAt: Date
3703
+ createdAt: Date
3704
+ }
3705
+
3706
+ /**
3707
+ * Webhook Endpoint Domain Types
3708
+ *
3709
+ * Browser-safe domain types for generic inbound webhook endpoints.
3710
+ * These are camelCase representations of the `webhook_endpoints` DB table.
3711
+ *
3712
+ * Transform from snake_case DB rows happens in the API service layer,
3713
+ * not here (per core-package.md conventions).
3714
+ */
3715
+
3716
+ /**
3717
+ * Lifecycle status of a webhook endpoint.
3718
+ * - `active`: Endpoint accepts inbound requests and triggers the target workflow
3719
+ * - `paused`: Endpoint exists but rejects inbound requests with 404
3720
+ */
3721
+ type WebhookEndpointStatus = 'active' | 'paused'
3722
+
3723
+ /**
3724
+ * Generic inbound webhook endpoint domain type.
3725
+ *
3726
+ * Each endpoint gets a unique opaque URL (`/api/webhooks/inbound/:key`)
3727
+ * that maps to a target workflow resource within an organization.
3728
+ */
3729
+ interface WebhookEndpoint {
3730
+ /** UUID primary key */
3731
+ id: string
3732
+ /** Organization this endpoint belongs to */
3733
+ organizationId: string
3734
+ /**
3735
+ * Unique opaque key used in the inbound URL.
3736
+ * Format: `wh_` + 32 crypto-random hex chars (128 bits of entropy).
3737
+ * This key IS the credential — it must be kept secret.
3738
+ */
3739
+ key: string
3740
+ /** User-facing label (e.g., "Zapier → Lead Intake") */
3741
+ name: string
3742
+ /** Optional description for the endpoint */
3743
+ description: string | null
3744
+ /** Target workflow resourceId to invoke on inbound request, or null if not yet assigned */
3745
+ resourceId: string | null
3746
+ /** Whether the endpoint is accepting requests */
3747
+ status: WebhookEndpointStatus
3748
+ /** Timestamp of the most recent successful inbound request, or null */
3749
+ lastTriggeredAt: string | null
3750
+ /** Running total of inbound requests received */
3751
+ requestCount: number
3752
+ /** ISO 8601 creation timestamp */
3753
+ createdAt: string
3754
+ /** ISO 8601 last-updated timestamp */
3755
+ updatedAt: string
3756
+ }
3757
+
3758
+ /**
3759
+ * POST /api/webhook-endpoints - Create a new webhook endpoint
3760
+ *
3761
+ * The `key` and `id` are generated server-side and not accepted in the request.
3762
+ */
3763
+ declare const CreateWebhookEndpointRequestSchema = z
3764
+ .object({
3765
+ /** User-facing label for the endpoint */
3766
+ name: NonEmptyStringSchema,
3767
+ /** Target workflow resourceId to invoke on inbound requests (can be set later) */
3768
+ resourceId: NonEmptyStringSchema.optional(),
3769
+ /** Optional description */
3770
+ description: z.string().optional()
3771
+ })
3772
+ .strict()
3773
+
3774
+ type CreateWebhookEndpointRequest = z.infer<typeof CreateWebhookEndpointRequestSchema>
3775
+
3776
+ /**
3777
+ * PATCH /api/webhook-endpoints/:id - Update an existing webhook endpoint
3778
+ *
3779
+ * At least one field must be provided.
3780
+ */
3781
+ declare const UpdateWebhookEndpointRequestSchema = z
3782
+ .object({
3783
+ name: NonEmptyStringSchema.optional(),
3784
+ description: z.string().optional(),
3785
+ resourceId: NonEmptyStringSchema.optional(),
3786
+ status: WebhookEndpointStatusSchema.optional()
3787
+ })
3788
+ .strict()
3789
+ .refine(
3790
+ (data) =>
3791
+ data.name !== undefined ||
3792
+ data.description !== undefined ||
3793
+ data.resourceId !== undefined ||
3794
+ data.status !== undefined,
3795
+ { message: 'At least one field (name, description, resourceId, or status) must be provided' }
3796
+ )
3797
+
3798
+ type UpdateWebhookEndpointRequest = z.infer<typeof UpdateWebhookEndpointRequestSchema>
3799
+
3800
+ export type { AIResourceDefinition, APIExecutionDetail, APIExecutionListResponse, Activity, ActivityType, ChatMessage, CheckpointListResponse, CostByModelResponse, CostSummaryResponse, CostTrendsResponse, CreateWebhookEndpointRequest, DashboardMetrics, ErrorAnalysisMetrics, ErrorDetailFull, ErrorDetailResponse, ErrorTrend, ExecutionHistoryItem, ExecutionHistoryResponse, ExecutionLogMessage, ExecutionStatus$1 as ExecutionStatus, ExecutionSummary, MembershipFeatureConfig, MembershipWithDetails, MessageEvent, NotificationDTO, OrgFeatureConfig, PatchTaskParams, ResourceDefinition, ResourceStatus, ResourceType, SessionDTO, SessionTokenUsage, SupabaseUserProfile, Task, TaskSchedule, TaskScheduleConfig, TaskStatus, TimeRange, UpdateWebhookEndpointRequest, UserConfig, WebhookEndpoint };