@elevasis/core 0.6.0 → 0.7.1

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,1131 @@
1
+ <!-- Auto-generated on 2026-04-21T07:07:41.380Z by scripts/monorepo/generate-scaffold-contracts.js -->
2
+ ---
3
+ title: Reference Contracts
4
+ description: Auto-generated TypeScript contracts for SDK consumers. Do not edit manually.
5
+ ---
6
+
7
+ > **Auto-generated** from source types. Do not edit manually. Run `node scripts/monorepo/generate-scaffold-contracts.js` to regenerate.
8
+
9
+ ## Organization Model
10
+
11
+ ### `OrganizationModel`
12
+
13
+ ```typescript
14
+ export type OrganizationModel = z.infer<typeof OrganizationModelSchema>
15
+ ```
16
+
17
+ ### `OrganizationModelBranding`
18
+
19
+ ```typescript
20
+ export type OrganizationModelBranding = z.infer<typeof OrganizationModelBrandingSchema>
21
+ ```
22
+
23
+ ### `OrganizationModelSales`
24
+
25
+ ```typescript
26
+ export type OrganizationModelSales = z.infer<typeof OrganizationModelSalesSchema>
27
+ ```
28
+
29
+ ### `OrganizationModelProspecting`
30
+
31
+ ```typescript
32
+ export type OrganizationModelProspecting = z.infer<typeof OrganizationModelProspectingSchema>
33
+ ```
34
+
35
+ ### `OrganizationModelProjects`
36
+
37
+ ```typescript
38
+ export type OrganizationModelProjects = z.infer<typeof OrganizationModelProjectsSchema>
39
+ ```
40
+
41
+ ### `OrganizationModelFeature`
42
+
43
+ ```typescript
44
+ export type OrganizationModelFeature = z.infer<typeof FeatureSchema>
45
+ ```
46
+
47
+ ### `OrganizationModelNavigation`
48
+
49
+ ```typescript
50
+ export type OrganizationModelNavigation = z.infer<typeof OrganizationModelNavigationSchema>
51
+ ```
52
+
53
+ ### `OrganizationModelSurface`
54
+
55
+ ```typescript
56
+ export type OrganizationModelSurface = z.infer<typeof SurfaceDefinitionSchema>
57
+ ```
58
+
59
+ ### `OrganizationModelResourceMapping`
60
+
61
+ ```typescript
62
+ export type OrganizationModelResourceMapping = z.infer<typeof ResourceMappingSchema>
63
+ ```
64
+
65
+ ### `OrganizationModelTechStackEntry`
66
+
67
+ ```typescript
68
+ export type OrganizationModelTechStackEntry = z.infer<typeof TechStackEntrySchema>
69
+ ```
70
+
71
+ ### `OrganizationModelStatuses`
72
+
73
+ ```typescript
74
+ export type OrganizationModelStatuses = z.infer<typeof StatusesDomainSchema>
75
+ ```
76
+
77
+ ### `OrganizationModelStatusEntry`
78
+
79
+ ```typescript
80
+ export type OrganizationModelStatusEntry = z.infer<typeof StatusEntrySchema>
81
+ ```
82
+
83
+ ### `OrganizationModelStatusSemanticClass`
84
+
85
+ ```typescript
86
+ export type OrganizationModelStatusSemanticClass = z.infer<typeof StatusSemanticClassSchema>
87
+ ```
88
+
89
+ ### `OrganizationModelOperations`
90
+
91
+ ```typescript
92
+ export type OrganizationModelOperations = z.infer<typeof OperationsDomainSchema>
93
+ ```
94
+
95
+ ### `OrganizationModelOperationEntry`
96
+
97
+ ```typescript
98
+ export type OrganizationModelOperationEntry = z.infer<typeof OperationEntrySchema>
99
+ ```
100
+
101
+ ### `OrganizationModelOperationSemanticClass`
102
+
103
+ ```typescript
104
+ export type OrganizationModelOperationSemanticClass = z.infer<typeof OperationSemanticClassSchema>
105
+ ```
106
+
107
+ ### `OrganizationModelCustomers`
108
+
109
+ ```typescript
110
+ export type OrganizationModelCustomers = z.infer<typeof CustomersDomainSchema>
111
+ ```
112
+
113
+ ### `OrganizationModelCustomerSegment`
114
+
115
+ ```typescript
116
+ export type OrganizationModelCustomerSegment = z.infer<typeof CustomerSegmentSchema>
117
+ ```
118
+
119
+ ### `OrganizationModelCustomerFirmographics`
120
+
121
+ ```typescript
122
+ export type OrganizationModelCustomerFirmographics = z.infer<typeof FirmographicsSchema>
123
+ ```
124
+
125
+ ### `OrganizationModelOfferings`
126
+
127
+ ```typescript
128
+ export type OrganizationModelOfferings = z.infer<typeof OfferingsDomainSchema>
129
+ ```
130
+
131
+ ### `OrganizationModelProduct`
132
+
133
+ ```typescript
134
+ export type OrganizationModelProduct = z.infer<typeof ProductSchema>
135
+ ```
136
+
137
+ ### `OrganizationModelPricingModel`
138
+
139
+ ```typescript
140
+ export type OrganizationModelPricingModel = z.infer<typeof PricingModelSchema>
141
+ ```
142
+
143
+ ### `OrganizationModelRoles`
144
+
145
+ ```typescript
146
+ export type OrganizationModelRoles = z.infer<typeof RolesDomainSchema>
147
+ ```
148
+
149
+ ### `OrganizationModelRole`
150
+
151
+ ```typescript
152
+ export type OrganizationModelRole = z.infer<typeof RoleSchema>
153
+ ```
154
+
155
+ ### `OrganizationModelGoals`
156
+
157
+ ```typescript
158
+ export type OrganizationModelGoals = z.infer<typeof GoalsDomainSchema>
159
+ ```
160
+
161
+ ### `OrganizationModelObjective`
162
+
163
+ ```typescript
164
+ export type OrganizationModelObjective = z.infer<typeof ObjectiveSchema>
165
+ ```
166
+
167
+ ### `OrganizationModelKeyResult`
168
+
169
+ ```typescript
170
+ export type OrganizationModelKeyResult = z.infer<typeof KeyResultSchema>
171
+ ```
172
+
173
+ ### `DeepPartial`
174
+
175
+ ```typescript
176
+ export type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T
177
+ ```
178
+
179
+ ## Feature System
180
+
181
+ ### `FeatureNavLink`
182
+
183
+ ```typescript
184
+ export interface FeatureNavLink {
185
+ label: string
186
+ link: string
187
+ featureKey?: string
188
+ onClick?: () => void
189
+ links?: FeatureNavLink[]
190
+ }
191
+ ```
192
+
193
+ ### `FeatureNavEntry`
194
+
195
+ ```typescript
196
+ export interface FeatureNavEntry {
197
+ label: string
198
+ icon: ComponentType
199
+ link?: string
200
+ featureKey?: string
201
+ requiresAdmin?: boolean
202
+ dataOnboardingTourId?: string
203
+ links?: FeatureNavLink[]
204
+ }
205
+ ```
206
+
207
+ ### `FeatureSidebarComponent`
208
+
209
+ ```typescript
210
+ export type FeatureSidebarComponent = ComponentType
211
+ ```
212
+
213
+ ### `FeatureModule`
214
+
215
+ ```typescript
216
+ export interface FeatureModule {
217
+ /** Unique stable identifier for this feature (e.g. `'crm'`, `'projects'`). */
218
+ key: string
219
+ /** Feature ID used for access-flag gating — must match the `id` of a feature in the organization model. */
220
+ featureId: string
221
+ /**
222
+ * Capability identifiers contributed by this feature.
223
+ * Merged into `ResolvedFeatureSemantics.capabilityIds` at resolution time.
224
+ * Not queried at runtime — kept for semantic graph completeness so that
225
+ * capability membership is fully represented in the resolved model even when
226
+ * a surface does not declare it directly.
227
+ */
228
+ capabilityIds?: string[]
229
+ /** Top-level navigation entry rendered in the app shell when this feature is enabled. */
230
+ navEntry?: FeatureNavEntry
231
+ /** Sidebar component rendered when a matching subshell route is active. */
232
+ sidebar?: FeatureSidebarComponent
233
+ /** Route path prefixes that activate this feature's sidebar and subshell context. */
234
+ subshellRoutes?: string[]
235
+ /**
236
+ * Operations-only bridge surface connecting this feature to the organization graph.
237
+ * Ignored by all other features. Only one manifest in the registry should set this.
238
+ */
239
+ organizationGraph?: OrganizationGraphFeatureBridge
240
+ }
241
+ ```
242
+
243
+ ### `ResolvedFeatureAccess`
244
+
245
+ ```typescript
246
+ export interface ResolvedFeatureAccess {
247
+ featureId: string
248
+ enabled: boolean
249
+ }
250
+ ```
251
+
252
+ ### `ResolvedFeatureSemantics`
253
+
254
+ ```typescript
255
+ export interface ResolvedFeatureSemantics {
256
+ capabilityIds: string[]
257
+ surfaceIds: string[]
258
+ surfaces: OrganizationModelSurface[]
259
+ }
260
+ ```
261
+
262
+ ### `ResolvedFeatureModule`
263
+
264
+ ```typescript
265
+ export interface ResolvedFeatureModule extends FeatureModule {
266
+ access: ResolvedFeatureAccess
267
+ semantics: ResolvedFeatureSemantics
268
+ }
269
+ ```
270
+
271
+ ### `ShellNavPlacement`
272
+
273
+ ```typescript
274
+ export type ShellNavPlacement = 'primary' | 'bottom'
275
+ ```
276
+
277
+ ### `ShellNavSource`
278
+
279
+ ```typescript
280
+ export type ShellNavSource = 'app' | 'feature'
281
+ ```
282
+
283
+ ### `ResolvedShellNavItem`
284
+
285
+ ```typescript
286
+ export interface ResolvedShellNavItem extends FeatureNavEntry {
287
+ placement: ShellNavPlacement
288
+ source: ShellNavSource
289
+ featureId?: string
290
+ }
291
+ ```
292
+
293
+ ### `ResolvedShellModel`
294
+
295
+ ```typescript
296
+ export interface ResolvedShellModel {
297
+ navItems: ResolvedShellNavItem[]
298
+ }
299
+ ```
300
+
301
+ ### `AppShellOverrides`
302
+
303
+ ```typescript
304
+ export interface AppShellOverrides {
305
+ primaryNavItems?: FeatureNavEntry[]
306
+ bottomNavItems?: FeatureNavEntry[]
307
+ }
308
+ ```
309
+
310
+ ### `ShellRouteMatchStatus`
311
+
312
+ ```typescript
313
+ export type ShellRouteMatchStatus = 'matched' | 'hidden' | 'unmatched'
314
+ ```
315
+
316
+ ### `ResolvedShellRouteMatch`
317
+
318
+ ```typescript
319
+ export interface ResolvedShellRouteMatch {
320
+ status: ShellRouteMatchStatus
321
+ path: string
322
+ feature?: ResolvedFeatureModule
323
+ navItem?: ResolvedShellNavItem
324
+ navLink?: FeatureNavLink
325
+ }
326
+ ```
327
+
328
+ ### `ShellRuntime`
329
+
330
+ ```typescript
331
+ export interface ShellRuntime {
332
+ resolveRoute: (path: string) => ResolvedShellRouteMatch
333
+ }
334
+ ```
335
+
336
+ ### `OrganizationGraphFeatureBridge`
337
+
338
+ ```typescript
339
+ export interface OrganizationGraphFeatureBridge {
340
+ surfaceId: string
341
+ }
342
+ ```
343
+
344
+ ### `OrganizationGraphContextValue`
345
+
346
+ ```typescript
347
+ export interface OrganizationGraphContextValue {
348
+ available: boolean
349
+ surfaceId?: string
350
+ surfacePath?: string
351
+ surfaceType?: OrganizationModelSurface['surfaceType']
352
+ featureId?: string
353
+ }
354
+ ```
355
+
356
+ ### `ElevasisFeaturesProviderProps`
357
+
358
+ ```typescript
359
+ export interface ElevasisFeaturesProviderProps {
360
+ features: FeatureModule[]
361
+ organizationModel?: OrganizationModel
362
+ appShellOverrides?: AppShellOverrides
363
+ timeRange?: TimeRange
364
+ operationsApiUrl?: string
365
+ operationsSSEManager?: SSEConnectionManagerLike
366
+ disabledSubsectionPaths?: string[]
367
+ children: ReactNode
368
+ }
369
+ ```
370
+
371
+ ### `ElevasisFeaturesContextValue`
372
+
373
+ ```typescript
374
+ export interface ElevasisFeaturesContextValue {
375
+ shellModel: ResolvedShellModel
376
+ shellRuntime: ShellRuntime
377
+ enabledResolvedFeatures: ResolvedFeatureModule[]
378
+ resolvedFeatures: ResolvedFeatureModule[]
379
+ organizationGraph: OrganizationGraphContextValue
380
+ organizationModel?: OrganizationModel
381
+ timeRange?: TimeRange
382
+ operationsApiUrl?: string
383
+ operationsSSEManager?: SSEConnectionManagerLike
384
+ disabledSubsectionPaths: string[]
385
+ isFeatureEnabled: (key: string) => boolean
386
+ getResolvedFeature: (key: string) => ResolvedFeatureModule | undefined
387
+ }
388
+ ```
389
+
390
+ ## Resource Registry
391
+
392
+ ### `ResourceStatus`
393
+
394
+ ```typescript
395
+ /**
396
+ * Resource Registry type definitions
397
+ */
398
+
399
+ import type { IntegrationType } from '../../execution/engine/tools/integration'
400
+ import type { ResourceDomain } from './domains'
401
+
402
+ // ============================================================================
403
+ // Core Resource Type Definitions
404
+ // ============================================================================
405
+
406
+ /**
407
+ * Environment/deployment status for resources
408
+ */
409
+ export type ResourceStatus = 'dev' | 'prod'
410
+
411
+ /**
412
+ * All resource types in the platform
413
+ * Used as the discriminator field in ResourceDefinition
414
+ */
415
+ ```
416
+
417
+ ### `ResourceType`
418
+
419
+ ```typescript
420
+ /**
421
+ * All resource types in the platform
422
+ * Used as the discriminator field in ResourceDefinition
423
+ */
424
+ export type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human'
425
+
426
+ /**
427
+ * Executable resource types (subset of ResourceType)
428
+ * These resources can be directly executed by the execution engine
429
+ */
430
+ ```
431
+
432
+ ### `ExecutableResourceType`
433
+
434
+ ```typescript
435
+ /**
436
+ * Executable resource types (subset of ResourceType)
437
+ * These resources can be directly executed by the execution engine
438
+ */
439
+ export type ExecutableResourceType = 'workflow' | 'agent'
440
+
441
+ // ============================================================================
442
+ // Base Resource Interface
443
+ // ============================================================================
444
+
445
+ /**
446
+ * Base interface for ALL platform resources
447
+ * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
448
+ */
449
+ ```
450
+
451
+ ### `ResourceDefinition`
452
+
453
+ ```typescript
454
+ /**
455
+ * Base interface for ALL platform resources
456
+ * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
457
+ */
458
+ export interface ResourceDefinition {
459
+ /** Unique resource identifier */
460
+ resourceId: string
461
+
462
+ /** Display name */
463
+ name: string
464
+
465
+ /** Purpose and functionality description */
466
+ description: string
467
+
468
+ /** Version for change tracking and evolution */
469
+ version: string
470
+
471
+ /** Resource type discriminator */
472
+ type: ResourceType
473
+
474
+ /** Environment/deployment status */
475
+ status: ResourceStatus
476
+
477
+ /** Domain tags for filtering and organization */
478
+ domains?: ResourceDomain[]
479
+
480
+ /** Whether the agent supports multi-turn sessions (agents only) */
481
+ sessionCapable?: boolean
482
+
483
+ /** Whether the resource is local (monorepo) or remote (externally deployed) */
484
+ origin?: 'local' | 'remote'
485
+
486
+ /** Whether this resource is archived and should be excluded from registration and deployment */
487
+ archived?: boolean
488
+ }
489
+ ```
490
+
491
+ ### `DomainDefinition`
492
+
493
+ ```typescript
494
+ /** Unique resource identifier */
495
+ resourceId: string
496
+
497
+ /** Display name */
498
+ name: string
499
+
500
+ /** Purpose and functionality description */
501
+ description: string
502
+
503
+ /** Version for change tracking and evolution */
504
+ version: string
505
+
506
+ /** Resource type discriminator */
507
+ type: ResourceType
508
+
509
+ /** Environment/deployment status */
510
+ status: ResourceStatus
511
+
512
+ /** Domain tags for filtering and organization */
513
+ domains?: ResourceDomain[]
514
+
515
+ /** Whether the agent supports multi-turn sessions (agents only) */
516
+ sessionCapable?: boolean
517
+
518
+ /** Whether the resource is local (monorepo) or remote (externally deployed) */
519
+ origin?: 'local' | 'remote'
520
+
521
+ /** Whether this resource is archived and should be excluded from registration and deployment */
522
+ archived?: boolean
523
+ }
524
+
525
+ // ============================================================================
526
+ // Domain Definition Types
527
+ // ============================================================================
528
+
529
+ /**
530
+ * Domain definition for Command View filtering
531
+ *
532
+ * Domains are organizational metadata for UI filtering/grouping.
533
+ * No execution impact - purely for visualization.
534
+ *
535
+ * @example
536
+ * {
537
+ * id: 'support',
538
+ * name: 'Customer Support',
539
+ * description: 'Ticket triage, knowledge base, escalations',
540
+ * color: 'green',
541
+ * icon: 'IconHeadset'
542
+ * }
543
+ */
544
+ export interface DomainDefinition {
545
+ /** Unique identifier (e.g., 'support') */
546
+ id: string
547
+ /** Display name (e.g., 'Customer Support') */
548
+ name: string
549
+ /** Purpose description */
550
+ description: string
551
+ /** Optional Mantine color for UI (e.g., 'blue', 'green', 'orange') */
552
+ color?: string
553
+ /** Optional Tabler icon name (e.g., 'IconHeadset') */
554
+ icon?: string
555
+ }
556
+ ```
557
+
558
+ ### `ResourceList`
559
+
560
+ ```typescript
561
+ /** Unique identifier (e.g., 'support') */
562
+ id: string
563
+ /** Display name (e.g., 'Customer Support') */
564
+ name: string
565
+ /** Purpose description */
566
+ description: string
567
+ /** Optional Mantine color for UI (e.g., 'blue', 'green', 'orange') */
568
+ color?: string
569
+ /** Optional Tabler icon name (e.g., 'IconHeadset') */
570
+ icon?: string
571
+ }
572
+
573
+ /**
574
+ * Resource list for organization
575
+ * Returns ResourceDefinition metadata (not full definitions)
576
+ */
577
+ export interface ResourceList {
578
+ workflows: ResourceDefinition[]
579
+ agents: ResourceDefinition[]
580
+ total: number
581
+ organizationName: string
582
+ environment?: 'dev' | 'prod'
583
+ }
584
+ ```
585
+
586
+ ### `WebhookProviderType`
587
+
588
+ ```typescript
589
+ /** Webhook provider identifiers */
590
+ export type WebhookProviderType = 'cal-com' | 'stripe' | 'signature-api' | 'instantly' | 'apify' | 'test'
591
+
592
+ /** Webhook trigger configuration */
593
+ ```
594
+
595
+ ### `WebhookTriggerConfig`
596
+
597
+ ```typescript
598
+ /** Webhook trigger configuration */
599
+ export interface WebhookTriggerConfig {
600
+ /** Provider identifier */
601
+ provider: WebhookProviderType
602
+ /** Event type for documentation (not used for matching - workflow handles routing) */
603
+ event?: string
604
+ /** Optional filtering (e.g., specific form ID for Fillout) */
605
+ filter?: Record<string, string>
606
+ /** References credential in credentials table for per-org webhook secrets */
607
+ credentialName?: string
608
+ }
609
+ ```
610
+
611
+ ### `ScheduleTriggerConfig`
612
+
613
+ ```typescript
614
+ /** Provider identifier */
615
+ provider: WebhookProviderType
616
+ /** Event type for documentation (not used for matching - workflow handles routing) */
617
+ event?: string
618
+ /** Optional filtering (e.g., specific form ID for Fillout) */
619
+ filter?: Record<string, string>
620
+ /** References credential in credentials table for per-org webhook secrets */
621
+ credentialName?: string
622
+ }
623
+
624
+ /** Schedule trigger configuration */
625
+ export interface ScheduleTriggerConfig {
626
+ /** Cron expression (e.g., '0 6 * * *') */
627
+ cron: string
628
+ /** Optional timezone (default: UTC) */
629
+ timezone?: string
630
+ }
631
+ ```
632
+
633
+ ### `EventTriggerConfig`
634
+
635
+ ```typescript
636
+ /** Cron expression (e.g., '0 6 * * *') */
637
+ cron: string
638
+ /** Optional timezone (default: UTC) */
639
+ timezone?: string
640
+ }
641
+
642
+ /** Event trigger configuration */
643
+ export interface EventTriggerConfig {
644
+ /** Internal event type */
645
+ eventType: string
646
+ /** Event source */
647
+ source?: string
648
+ }
649
+ ```
650
+
651
+ ### `TriggerConfig`
652
+
653
+ ```typescript
654
+ /** Internal event type */
655
+ eventType: string
656
+ /** Event source */
657
+ source?: string
658
+ }
659
+
660
+ /** Union of all trigger configs */
661
+ export type TriggerConfig = WebhookTriggerConfig | ScheduleTriggerConfig | EventTriggerConfig
662
+
663
+ // ============================================================================
664
+ // Trigger Definition
665
+ // ============================================================================
666
+
667
+ /**
668
+ * Trigger metadata - entry points that initiate resource execution
669
+ *
670
+ * Triggers represent how executions start: webhooks from external services,
671
+ * scheduled cron jobs, platform events, or manual user actions.
672
+ *
673
+ * BREAKING CHANGES (2025-11-30):
674
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
675
+ * - Field renames: `id` -> `resourceId` (inherited), `type` -> `triggerType`
676
+ * - Relationship rename: `invokes` -> `triggers` (unified vocabulary)
677
+ * - New required fields: `version` (inherited), `type: 'trigger'` (inherited)
678
+ * - triggers object now includes `externalResources` option
679
+ *
680
+ * @example
681
+ * // TriggerDefinition - metadata only
682
+ * {
683
+ * resourceId: 'trigger-new-order',
684
+ * type: 'trigger',
685
+ * triggerType: 'webhook',
686
+ * name: 'New Order',
687
+ * description: 'Webhook from Shopify on new orders',
688
+ * version: '1.0.0',
689
+ * status: 'prod',
690
+ * webhookPath: '/webhooks/shopify/orders'
691
+ * }
692
+ *
693
+ * // Relationships declared in ResourceRelationships (not on TriggerDefinition):
694
+ * // relationships: {
695
+ * // 'trigger-new-order': { triggers: { workflows: ['order-fulfillment-workflow'] } }
696
+ * // }
697
+ */
698
+ ```
699
+
700
+ ### `TriggerDefinition`
701
+
702
+ ```typescript
703
+ /**
704
+ * Trigger metadata - entry points that initiate resource execution
705
+ *
706
+ * Triggers represent how executions start: webhooks from external services,
707
+ * scheduled cron jobs, platform events, or manual user actions.
708
+ *
709
+ * BREAKING CHANGES (2025-11-30):
710
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
711
+ * - Field renames: `id` -> `resourceId` (inherited), `type` -> `triggerType`
712
+ * - Relationship rename: `invokes` -> `triggers` (unified vocabulary)
713
+ * - New required fields: `version` (inherited), `type: 'trigger'` (inherited)
714
+ * - triggers object now includes `externalResources` option
715
+ *
716
+ * @example
717
+ * // TriggerDefinition - metadata only
718
+ * {
719
+ * resourceId: 'trigger-new-order',
720
+ * type: 'trigger',
721
+ * triggerType: 'webhook',
722
+ * name: 'New Order',
723
+ * description: 'Webhook from Shopify on new orders',
724
+ * version: '1.0.0',
725
+ * status: 'prod',
726
+ * webhookPath: '/webhooks/shopify/orders'
727
+ * }
728
+ *
729
+ * // Relationships declared in ResourceRelationships (not on TriggerDefinition):
730
+ * // relationships: {
731
+ * // 'trigger-new-order': { triggers: { workflows: ['order-fulfillment-workflow'] } }
732
+ * // }
733
+ */
734
+ export interface TriggerDefinition extends ResourceDefinition {
735
+ /** Resource type discriminator (narrowed from base union) */
736
+ type: 'trigger'
737
+
738
+ /** Trigger mechanism type (renamed from 'type' to avoid collision with base type discriminator) */
739
+ triggerType: 'webhook' | 'schedule' | 'manual' | 'event'
740
+
741
+ /** Type-specific configuration */
742
+ config?: TriggerConfig
743
+
744
+ // Legacy fields (deprecated, use config instead)
745
+ /** For webhook triggers: path like '/webhooks/shopify/orders' */
746
+ webhookPath?: string
747
+ /** For schedule triggers: cron expression like '0 6 * * *' */
748
+ schedule?: string
749
+ /** For event triggers: event type like 'low-stock-alert' */
750
+ eventType?: string
751
+
752
+ // NOTE: What this trigger starts is declared in ResourceRelationships, not here
753
+ // This prevents duplication - triggers are forward-declared in relationships
754
+ }
755
+ ```
756
+
757
+ ### `IntegrationDefinition`
758
+
759
+ ```typescript
760
+ /** Resource type discriminator (narrowed from base union) */
761
+ type: 'trigger'
762
+
763
+ /** Trigger mechanism type (renamed from 'type' to avoid collision with base type discriminator) */
764
+ triggerType: 'webhook' | 'schedule' | 'manual' | 'event'
765
+
766
+ /** Type-specific configuration */
767
+ config?: TriggerConfig
768
+
769
+ // Legacy fields (deprecated, use config instead)
770
+ /** For webhook triggers: path like '/webhooks/shopify/orders' */
771
+ webhookPath?: string
772
+ /** For schedule triggers: cron expression like '0 6 * * *' */
773
+ schedule?: string
774
+ /** For event triggers: event type like 'low-stock-alert' */
775
+ eventType?: string
776
+
777
+ // NOTE: What this trigger starts is declared in ResourceRelationships, not here
778
+ // This prevents duplication - triggers are forward-declared in relationships
779
+ }
780
+
781
+ /**
782
+ * Integration metadata - external service connections
783
+ *
784
+ * References credentials table for actual connection. No connection status
785
+ * stored here (queried at runtime from credentials table).
786
+ *
787
+ * BREAKING CHANGES (2025-11-30):
788
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
789
+ * - Field renames: `id` -> `resourceId` (inherited)
790
+ * - New required field: `status` (inherited) - organizations must add status to all integrations
791
+ * - New required field: `version` (inherited) - organizations must add version to all integrations
792
+ * - New required field: `type: 'integration'` (inherited) - resource type discriminator
793
+ *
794
+ * @example
795
+ * {
796
+ * resourceId: 'integration-shopify-prod',
797
+ * type: 'integration',
798
+ * provider: 'shopify',
799
+ * credentialName: 'shopify-prod',
800
+ * name: 'Shopify Production',
801
+ * description: 'E-commerce platform',
802
+ * version: '1.0.0',
803
+ * status: 'prod'
804
+ * }
805
+ */
806
+ export interface IntegrationDefinition extends ResourceDefinition {
807
+ /** Resource type discriminator (narrowed from base union) */
808
+ type: 'integration'
809
+
810
+ /** Integration provider type */
811
+ provider: IntegrationType
812
+ /** References credentials table (e.g., 'shopify-prod', 'zendesk-api') */
813
+ credentialName: string
814
+ }
815
+ ```
816
+
817
+ ### `RelationshipDeclaration`
818
+
819
+ ```typescript
820
+ /** Resource type discriminator (narrowed from base union) */
821
+ type: 'integration'
822
+
823
+ /** Integration provider type */
824
+ provider: IntegrationType
825
+ /** References credentials table (e.g., 'shopify-prod', 'zendesk-api') */
826
+ credentialName: string
827
+ }
828
+
829
+ /**
830
+ * Explicit resource relationship declaration
831
+ *
832
+ * Single-direction only - Command View derives reverse relationships.
833
+ * Agents/workflows declare what they trigger and use.
834
+ *
835
+ * @example
836
+ * {
837
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
838
+ * uses: { integrations: ['integration-shopify-prod', 'integration-postgres'] }
839
+ * }
840
+ */
841
+ export interface RelationshipDeclaration {
842
+ /** Resources this resource triggers */
843
+ triggers?: {
844
+ /** Agent resourceIds this resource triggers */
845
+ agents?: string[]
846
+ /** Workflow resourceIds this resource triggers */
847
+ workflows?: string[]
848
+ }
849
+ /** Integrations this resource uses */
850
+ uses?: {
851
+ /** Integration IDs this resource uses */
852
+ integrations?: string[]
853
+ }
854
+ }
855
+ ```
856
+
857
+ ### `ResourceRelationships`
858
+
859
+ ```typescript
860
+ /** Resources this resource triggers */
861
+ triggers?: {
862
+ /** Agent resourceIds this resource triggers */
863
+ agents?: string[]
864
+ /** Workflow resourceIds this resource triggers */
865
+ workflows?: string[]
866
+ }
867
+ /** Integrations this resource uses */
868
+ uses?: {
869
+ /** Integration IDs this resource uses */
870
+ integrations?: string[]
871
+ }
872
+ }
873
+
874
+ /**
875
+ * Resource relationships map
876
+ * Maps resourceId to its relationship declarations
877
+ *
878
+ * @example
879
+ * {
880
+ * 'order-processor-agent': {
881
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
882
+ * uses: { integrations: ['integration-shopify-prod'] }
883
+ * }
884
+ * }
885
+ */
886
+ export type ResourceRelationships = Record<string, RelationshipDeclaration>
887
+
888
+ // ============================================================================
889
+ // External Resource Types
890
+ // ============================================================================
891
+
892
+ /**
893
+ * External platform type
894
+ * Supported third-party automation platforms
895
+ */
896
+ ```
897
+
898
+ ### `ExternalPlatform`
899
+
900
+ ```typescript
901
+ /**
902
+ * External platform type
903
+ * Supported third-party automation platforms
904
+ */
905
+ export type ExternalPlatform = 'n8n' | 'make' | 'zapier' | 'other'
906
+
907
+ /**
908
+ * External automation resource metadata
909
+ *
910
+ * Represents workflows/automations running on third-party platforms
911
+ * (n8n, Make, Zapier, etc.) for visualization in Command View.
912
+ *
913
+ * NOTE: This is metadata ONLY for visualization. No execution logic,
914
+ * no API integration with external platforms, no status syncing.
915
+ *
916
+ * BREAKING CHANGES (2025-11-30):
917
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
918
+ * - Field renames: `id` -> `resourceId` (inherited)
919
+ * - New required field: `version` (inherited) - organizations must add version to all external resources
920
+ * - New required field: `type: 'external'` (inherited) - resource type discriminator
921
+ * - REMOVED FIELD: `triggeredBy` - per relationship-consolidation design, all relationships are forward-only declarations
922
+ *
923
+ * @example
924
+ * {
925
+ * resourceId: 'external-n8n-order-sync',
926
+ * type: 'external',
927
+ * version: '1.0.0',
928
+ * platform: 'n8n',
929
+ * name: 'Shopify Order Sync',
930
+ * description: 'Legacy n8n workflow for syncing Shopify orders',
931
+ * status: 'prod',
932
+ * platformUrl: 'https://n8n.client.com/workflow/123',
933
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
934
+ * uses: { integrations: ['integration-shopify-prod'] }
935
+ * }
936
+ */
937
+ ```
938
+
939
+ ### `ExternalResourceDefinition`
940
+
941
+ ```typescript
942
+ /**
943
+ * External automation resource metadata
944
+ *
945
+ * Represents workflows/automations running on third-party platforms
946
+ * (n8n, Make, Zapier, etc.) for visualization in Command View.
947
+ *
948
+ * NOTE: This is metadata ONLY for visualization. No execution logic,
949
+ * no API integration with external platforms, no status syncing.
950
+ *
951
+ * BREAKING CHANGES (2025-11-30):
952
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
953
+ * - Field renames: `id` -> `resourceId` (inherited)
954
+ * - New required field: `version` (inherited) - organizations must add version to all external resources
955
+ * - New required field: `type: 'external'` (inherited) - resource type discriminator
956
+ * - REMOVED FIELD: `triggeredBy` - per relationship-consolidation design, all relationships are forward-only declarations
957
+ *
958
+ * @example
959
+ * {
960
+ * resourceId: 'external-n8n-order-sync',
961
+ * type: 'external',
962
+ * version: '1.0.0',
963
+ * platform: 'n8n',
964
+ * name: 'Shopify Order Sync',
965
+ * description: 'Legacy n8n workflow for syncing Shopify orders',
966
+ * status: 'prod',
967
+ * platformUrl: 'https://n8n.client.com/workflow/123',
968
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
969
+ * uses: { integrations: ['integration-shopify-prod'] }
970
+ * }
971
+ */
972
+ export interface ExternalResourceDefinition extends ResourceDefinition {
973
+ /** Resource type discriminator (narrowed from base union) */
974
+ type: 'external'
975
+
976
+ /** Platform type */
977
+ platform: ExternalPlatform
978
+
979
+ // Optional platform-specific metadata
980
+ /** Link to external platform (e.g., n8n workflow editor URL) */
981
+ platformUrl?: string
982
+ /** Platform's internal ID/reference */
983
+ externalId?: string
984
+
985
+ /** What this external resource triggers (external -> internal) */
986
+ triggers?: {
987
+ /** Elevasis workflow resourceIds this external automation triggers */
988
+ workflows?: string[]
989
+ /** Elevasis agent resourceIds this external automation triggers */
990
+ agents?: string[]
991
+ }
992
+
993
+ /** Integrations this external resource uses (shared credentials) */
994
+ uses?: {
995
+ /** Integration IDs this external automation uses */
996
+ integrations?: string[]
997
+ }
998
+
999
+ // NOTE: triggeredBy field removed - per relationship-consolidation design,
1000
+ // all relationships are forward-only declarations. Graph edges are built
1001
+ // from forward declarations only.
1002
+ }
1003
+ ```
1004
+
1005
+ ### `HumanCheckpointDefinition`
1006
+
1007
+ ```typescript
1008
+ /** Resource type discriminator (narrowed from base union) */
1009
+ type: 'external'
1010
+
1011
+ /** Platform type */
1012
+ platform: ExternalPlatform
1013
+
1014
+ // Optional platform-specific metadata
1015
+ /** Link to external platform (e.g., n8n workflow editor URL) */
1016
+ platformUrl?: string
1017
+ /** Platform's internal ID/reference */
1018
+ externalId?: string
1019
+
1020
+ /** What this external resource triggers (external -> internal) */
1021
+ triggers?: {
1022
+ /** Elevasis workflow resourceIds this external automation triggers */
1023
+ workflows?: string[]
1024
+ /** Elevasis agent resourceIds this external automation triggers */
1025
+ agents?: string[]
1026
+ }
1027
+
1028
+ /** Integrations this external resource uses (shared credentials) */
1029
+ uses?: {
1030
+ /** Integration IDs this external automation uses */
1031
+ integrations?: string[]
1032
+ }
1033
+
1034
+ // NOTE: triggeredBy field removed - per relationship-consolidation design,
1035
+ // all relationships are forward-only declarations. Graph edges are built
1036
+ // from forward declarations only.
1037
+ }
1038
+
1039
+ /**
1040
+ * Human Checkpoint definition - human decision points in automation
1041
+ *
1042
+ * Represents where human judgment is deployed in the automation landscape.
1043
+ * Tasks with matching command_queue_group are routed to this checkpoint.
1044
+ *
1045
+ * BREAKING CHANGES (2025-11-30):
1046
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
1047
+ * - Field renames: `id` -> `resourceId` (inherited)
1048
+ * - description is now REQUIRED (was optional) - organizations must add description to all human checkpoints
1049
+ * - New required field: `version` (inherited) - organizations must add version to all human checkpoints
1050
+ * - New required field: `type: 'human'` (inherited) - resource type discriminator
1051
+ *
1052
+ * @example
1053
+ * {
1054
+ * resourceId: 'sales-approval',
1055
+ * type: 'human',
1056
+ * name: 'Sales Approval Queue',
1057
+ * description: 'High-value order approvals for sales team',
1058
+ * version: '1.0.0',
1059
+ * status: 'prod',
1060
+ * requestedBy: { agents: ['order-processor-agent'] },
1061
+ * routesTo: { agents: ['order-fulfillment-agent'] }
1062
+ * }
1063
+ */
1064
+ export interface HumanCheckpointDefinition extends ResourceDefinition {
1065
+ /** Resource type discriminator (narrowed from base union) */
1066
+ type: 'human'
1067
+
1068
+ /** Resources that create tasks for this checkpoint */
1069
+ requestedBy?: {
1070
+ /** Agent resourceIds that request approval here */
1071
+ agents?: string[]
1072
+ /** Workflow resourceIds that request approval here */
1073
+ workflows?: string[]
1074
+ }
1075
+
1076
+ /** Resources that receive approved decisions */
1077
+ routesTo?: {
1078
+ /** Agent resourceIds that handle approved tasks */
1079
+ agents?: string[]
1080
+ /** Workflow resourceIds that handle approved tasks */
1081
+ workflows?: string[]
1082
+ }
1083
+ }
1084
+ ```
1085
+
1086
+ ## Deployment Spec
1087
+
1088
+ ### `DeploymentSpec`
1089
+
1090
+ ```typescript
1091
+ /** Supabase Storage path: "{orgId}/{deploymentId}/bundle.js" */
1092
+ storagePath: string
1093
+ /** Deployment record ID */
1094
+ deploymentId: string
1095
+ /** OS temp path to bundle -- set after first download, used by worker threads */
1096
+ cachedTempPath?: string
1097
+ /** Platform tool name -> credential name mapping */
1098
+ toolCredentials?: Record<string, string>
1099
+ /** SDK version used to deploy this bundle */
1100
+ sdkVersion?: string
1101
+ /** Deployment version (semver) of the deployed bundle */
1102
+ deploymentVersion?: string
1103
+ }
1104
+
1105
+ /**
1106
+ * Organization-specific resource collection
1107
+ *
1108
+ * Complete manifest of all automation resources for an organization.
1109
+ * Used by ResourceRegistry for discovery and Command View for visualization.
1110
+ */
1111
+ export interface DeploymentSpec {
1112
+ /** Deployment version (semver) */
1113
+ version: string
1114
+ /** Workflow definitions */
1115
+ workflows?: WorkflowDefinition[]
1116
+ /** Agent definitions */
1117
+ agents?: AgentDefinition[]
1118
+
1119
+ // Resource Manifest fields (optional for backwards compatibility)
1120
+ /** Trigger definitions - entry points that initiate executions */
1121
+ triggers?: TriggerDefinition[]
1122
+ /** Integration definitions - external service connections */
1123
+ integrations?: IntegrationDefinition[]
1124
+ /** Explicit relationship declarations between resources */
1125
+ relationships?: ResourceRelationships
1126
+ /** External automation resources (n8n, Make, Zapier, etc.) */
1127
+ externalResources?: ExternalResourceDefinition[]
1128
+ /** Human checkpoint definitions - human decision points in automation */
1129
+ humanCheckpoints?: HumanCheckpointDefinition[]
1130
+ }
1131
+ ```