@elevasis/core 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/index.d.ts +524 -6
  2. package/dist/index.js +417 -42
  3. package/dist/knowledge/index.d.ts +151 -1
  4. package/dist/organization-model/index.d.ts +524 -6
  5. package/dist/organization-model/index.js +417 -42
  6. package/dist/test-utils/index.d.ts +270 -1
  7. package/dist/test-utils/index.js +407 -41
  8. package/package.json +5 -5
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +501 -303
  10. package/src/auth/multi-tenancy/permissions.ts +20 -8
  11. package/src/business/README.md +2 -2
  12. package/src/business/acquisition/api-schemas.test.ts +198 -0
  13. package/src/business/acquisition/api-schemas.ts +250 -9
  14. package/src/business/acquisition/build-templates.test.ts +28 -0
  15. package/src/business/acquisition/build-templates.ts +20 -8
  16. package/src/business/acquisition/index.ts +12 -0
  17. package/src/business/acquisition/types.ts +6 -1
  18. package/src/business/clients/api-schemas.test.ts +115 -0
  19. package/src/business/clients/api-schemas.ts +158 -0
  20. package/src/business/clients/index.ts +1 -0
  21. package/src/business/deals/api-schemas.ts +8 -0
  22. package/src/business/index.ts +5 -2
  23. package/src/business/projects/types.ts +19 -0
  24. package/src/execution/engine/__tests__/fixtures/test-agents.ts +10 -8
  25. package/src/execution/engine/agent/core/__tests__/agent.test.ts +16 -12
  26. package/src/execution/engine/agent/core/__tests__/error-passthrough.test.ts +4 -3
  27. package/src/execution/engine/agent/core/types.ts +25 -15
  28. package/src/execution/engine/agent/index.ts +6 -4
  29. package/src/execution/engine/agent/reasoning/__tests__/request-builder.test.ts +24 -18
  30. package/src/execution/engine/index.ts +3 -0
  31. package/src/execution/engine/tools/integration/server/adapters/apify/apify-adapter.test.ts +55 -0
  32. package/src/execution/engine/tools/integration/server/adapters/apify/apify-adapter.ts +107 -41
  33. package/src/execution/engine/tools/integration/server/adapters/apollo/apollo-adapter.test.ts +48 -0
  34. package/src/execution/engine/tools/integration/server/adapters/apollo/apollo-adapter.ts +99 -0
  35. package/src/execution/engine/tools/integration/server/adapters/apollo/index.ts +1 -0
  36. package/src/execution/engine/tools/integration/server/adapters/clickup/clickup-adapter.test.ts +18 -0
  37. package/src/execution/engine/tools/integration/server/adapters/clickup/clickup-adapter.ts +194 -0
  38. package/src/execution/engine/tools/integration/server/adapters/clickup/index.ts +7 -0
  39. package/src/execution/engine/workflow/types.ts +7 -0
  40. package/src/integrations/credentials/api-schemas.ts +21 -2
  41. package/src/integrations/credentials/schemas.ts +200 -164
  42. package/src/organization-model/README.md +10 -3
  43. package/src/organization-model/__tests__/defaults.test.ts +6 -0
  44. package/src/organization-model/__tests__/domains/resources.test.ts +188 -0
  45. package/src/organization-model/__tests__/domains/roles.test.ts +402 -347
  46. package/src/organization-model/__tests__/domains/systems.test.ts +193 -0
  47. package/src/organization-model/__tests__/knowledge.test.ts +39 -0
  48. package/src/organization-model/__tests__/prospecting-ssot.test.ts +7 -4
  49. package/src/organization-model/__tests__/resolve.test.ts +1 -1
  50. package/src/organization-model/defaults.ts +24 -3
  51. package/src/organization-model/domains/knowledge.ts +3 -2
  52. package/src/organization-model/domains/prospecting.ts +182 -25
  53. package/src/organization-model/domains/resources.ts +88 -0
  54. package/src/organization-model/domains/roles.ts +93 -55
  55. package/src/organization-model/domains/sales.ts +24 -3
  56. package/src/organization-model/domains/systems.ts +46 -0
  57. package/src/organization-model/icons.ts +1 -0
  58. package/src/organization-model/index.ts +2 -0
  59. package/src/organization-model/organization-model.mdx +33 -14
  60. package/src/organization-model/published.ts +52 -1
  61. package/src/organization-model/schema.ts +121 -0
  62. package/src/organization-model/types.ts +46 -1
  63. package/src/platform/api/types.ts +38 -35
  64. package/src/platform/constants/versions.ts +1 -1
  65. package/src/platform/registry/__tests__/resource-registry.test.ts +2051 -2005
  66. package/src/platform/registry/__tests__/validation.test.ts +1343 -1086
  67. package/src/platform/registry/index.ts +14 -0
  68. package/src/platform/registry/resource-registry.ts +40 -2
  69. package/src/platform/registry/serialization.ts +241 -202
  70. package/src/platform/registry/serialized-types.ts +1 -0
  71. package/src/platform/registry/types.ts +411 -361
  72. package/src/platform/registry/validation.ts +743 -513
  73. package/src/projects/api-schemas.ts +290 -267
  74. package/src/reference/_generated/contracts.md +501 -303
  75. package/src/reference/glossary.md +8 -3
  76. package/src/server.ts +2 -0
  77. package/src/supabase/database.types.ts +121 -0
@@ -1,375 +1,425 @@
1
- /**
2
- * Resource Registry type definitions
3
- */
4
-
1
+ /**
2
+ * Resource Registry type definitions
3
+ */
4
+
5
5
  import type { IntegrationType } from '../../execution/engine/tools/integration'
6
+ import type { ResourceEntry, ResourceGovernanceStatus } from '../../organization-model/domains/resources'
7
+ import type { SystemEntry } from '../../organization-model/domains/systems'
6
8
  import type { ResourceCategory, ResourceLink } from './resource-link'
7
-
8
- // ============================================================================
9
- // Core Resource Type Definitions
10
- // ============================================================================
11
-
12
- /**
13
- * Environment/deployment status for resources
14
- */
15
- export type ResourceStatus = 'dev' | 'prod'
16
-
17
- /**
18
- * All resource types in the platform
19
- * Used as the discriminator field in ResourceDefinition
20
- */
21
- export type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human'
22
-
23
- /**
24
- * Executable resource types (subset of ResourceType)
25
- * These resources can be directly executed by the execution engine
26
- */
27
- export type ExecutableResourceType = 'workflow' | 'agent'
28
-
29
- // ============================================================================
30
- // Base Resource Interface
31
- // ============================================================================
32
-
33
- /**
34
- * Base interface for ALL platform resources
35
- * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
36
- */
37
- export interface ResourceDefinition {
38
- /** Unique resource identifier */
39
- resourceId: string
40
-
41
- /** Display name */
42
- name: string
43
-
44
- /** Purpose and functionality description */
45
- description: string
46
-
47
- /** Version for change tracking and evolution */
48
- version: string
49
-
50
- /** Resource type discriminator */
51
- type: ResourceType
52
-
53
- /** Environment/deployment status */
54
- status: ResourceStatus
55
-
9
+
10
+ // ============================================================================
11
+ // Core Resource Type Definitions
12
+ // ============================================================================
13
+
14
+ /**
15
+ * Environment/deployment status for resources
16
+ */
17
+ export type ResourceStatus = 'dev' | 'prod'
18
+
19
+ /**
20
+ * All resource types in the platform
21
+ * Used as the discriminator field in ResourceDefinition
22
+ */
23
+ export type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'external' | 'human'
24
+
25
+ /**
26
+ * Executable resource types (subset of ResourceType)
27
+ * These resources can be directly executed by the execution engine
28
+ */
29
+ export type ExecutableResourceType = 'workflow' | 'agent'
30
+
31
+ export type ResourceSystemSummary = Pick<SystemEntry, 'id' | 'title' | 'description' | 'kind' | 'status'>
32
+
33
+ // ============================================================================
34
+ // Base Resource Interface
35
+ // ============================================================================
36
+
37
+ /**
38
+ * Base interface for ALL platform resources
39
+ * Shared by both executable (agents, workflows) and non-executable (triggers, integrations, etc.) resources
40
+ */
41
+ export interface ResourceDefinition {
42
+ /** Unique resource identifier */
43
+ resourceId: string
44
+
45
+ /** Display name */
46
+ name: string
47
+
48
+ /** Purpose and functionality description */
49
+ description: string
50
+
51
+ /** Version for change tracking and evolution */
52
+ version: string
53
+
54
+ /** Resource type discriminator */
55
+ type: ResourceType
56
+
57
+ /** Environment/deployment status */
58
+ status: ResourceStatus
59
+
56
60
  /** Graph links to Organization Model nodes */
57
61
  links?: ResourceLink[]
58
62
 
59
63
  /** Infrastructure category for filtering */
60
64
  category?: ResourceCategory
61
-
62
- /** Whether the agent supports multi-turn sessions (agents only) */
63
- sessionCapable?: boolean
64
-
65
- /** Whether the resource is local (monorepo) or remote (externally deployed) */
66
- origin?: 'local' | 'remote'
67
-
68
- /** Whether this resource is archived and should be excluded from registration and deployment */
69
- archived?: boolean
70
- }
71
-
65
+
66
+ /** Whether the agent supports multi-turn sessions (agents only) */
67
+ sessionCapable?: boolean
68
+
69
+ /** Whether the resource is local (monorepo) or remote (externally deployed) */
70
+ origin?: 'local' | 'remote'
71
+
72
+ /** OM System membership, when backed by a Resource descriptor */
73
+ systemId?: string
74
+
75
+ /** Display metadata for the owning OM System */
76
+ system?: ResourceSystemSummary
77
+
78
+ /** Governance lifecycle status from the OM Resource descriptor */
79
+ governanceStatus?: ResourceGovernanceStatus
80
+
81
+ /** Whether this resource is archived and should be excluded from registration and deployment */
82
+ archived?: boolean
83
+ }
84
+
85
+ export type RuntimeResourceDescriptor = Extract<ResourceEntry, { kind: 'workflow' | 'agent' | 'integration' }>
86
+
87
+ export type DescriptorBackedResourceDefinition<
88
+ TResource extends RuntimeResourceDescriptor = RuntimeResourceDescriptor
89
+ > = Omit<ResourceDefinition, 'resourceId' | 'type'> & {
90
+ /** OM descriptor that owns canonical identity and governance metadata. */
91
+ resource: TResource
92
+ resourceId?: never
93
+ type?: never
94
+ }
95
+
96
+ export type BoundResourceDefinition<TResource extends RuntimeResourceDescriptor = RuntimeResourceDescriptor> = Omit<
97
+ DescriptorBackedResourceDefinition<TResource>,
98
+ 'resource'
99
+ > &
100
+ ResourceDefinition & {
101
+ resource: TResource
102
+ resourceId: TResource['id']
103
+ type: TResource['kind']
104
+ }
105
+
106
+ export function bindResourceDescriptor<TResource extends RuntimeResourceDescriptor>(
107
+ definition: DescriptorBackedResourceDefinition<TResource>
108
+ ): BoundResourceDefinition<TResource> {
109
+ const { resource, ...rest } = definition
110
+
111
+ return {
112
+ ...rest,
113
+ resource,
114
+ resourceId: resource.id,
115
+ type: resource.kind
116
+ } as BoundResourceDefinition<TResource>
117
+ }
118
+
72
119
  /**
73
120
  * Resource list for organization
74
121
  * Returns ResourceDefinition metadata (not full definitions)
75
- */
76
- export interface ResourceList {
77
- workflows: ResourceDefinition[]
78
- agents: ResourceDefinition[]
79
- total: number
80
- organizationName: string
81
- environment?: 'dev' | 'prod'
82
- }
83
-
84
- // ============================================================================
85
- // Resource Manifest Types
86
- // ============================================================================
87
-
88
- // ============================================================================
89
- // Trigger Configuration Types
90
- // ============================================================================
91
-
92
- /** Webhook provider identifiers */
93
- export type WebhookProviderType = 'cal-com' | 'stripe' | 'signature-api' | 'instantly' | 'apify' | 'test'
94
-
95
- /** Webhook trigger configuration */
96
- export interface WebhookTriggerConfig {
97
- /** Provider identifier */
98
- provider: WebhookProviderType
99
- /** Event type for documentation (not used for matching - workflow handles routing) */
100
- event?: string
101
- /** Optional filtering (e.g., specific form ID for Fillout) */
102
- filter?: Record<string, string>
103
- /** References credential in credentials table for per-org webhook secrets */
104
- credentialName?: string
105
- }
106
-
107
- /** Schedule trigger configuration */
108
- export interface ScheduleTriggerConfig {
109
- /** Cron expression (e.g., '0 6 * * *') */
110
- cron: string
111
- /** Optional timezone (default: UTC) */
112
- timezone?: string
113
- }
114
-
115
- /** Event trigger configuration */
116
- export interface EventTriggerConfig {
117
- /** Internal event type */
118
- eventType: string
119
- /** Event source */
120
- source?: string
121
- }
122
-
123
- /** Union of all trigger configs */
124
- export type TriggerConfig = WebhookTriggerConfig | ScheduleTriggerConfig | EventTriggerConfig
125
-
126
- // ============================================================================
127
- // Trigger Definition
128
- // ============================================================================
129
-
130
- /**
131
- * Trigger metadata - entry points that initiate resource execution
132
- *
133
- * Triggers represent how executions start: webhooks from external services,
134
- * scheduled cron jobs, platform events, or manual user actions.
135
- *
136
- * BREAKING CHANGES (2025-11-30):
122
+ */
123
+ export interface ResourceList {
124
+ workflows: ResourceDefinition[]
125
+ agents: ResourceDefinition[]
126
+ total: number
127
+ organizationName: string
128
+ environment?: 'dev' | 'prod'
129
+ }
130
+
131
+ // ============================================================================
132
+ // Resource Manifest Types
133
+ // ============================================================================
134
+
135
+ // ============================================================================
136
+ // Trigger Configuration Types
137
+ // ============================================================================
138
+
139
+ /** Webhook provider identifiers */
140
+ export type WebhookProviderType = 'cal-com' | 'stripe' | 'signature-api' | 'instantly' | 'apify' | 'test'
141
+
142
+ /** Webhook trigger configuration */
143
+ export interface WebhookTriggerConfig {
144
+ /** Provider identifier */
145
+ provider: WebhookProviderType
146
+ /** Event type for documentation (not used for matching - workflow handles routing) */
147
+ event?: string
148
+ /** Optional filtering (e.g., specific form ID for Fillout) */
149
+ filter?: Record<string, string>
150
+ /** References credential in credentials table for per-org webhook secrets */
151
+ credentialName?: string
152
+ }
153
+
154
+ /** Schedule trigger configuration */
155
+ export interface ScheduleTriggerConfig {
156
+ /** Cron expression (e.g., '0 6 * * *') */
157
+ cron: string
158
+ /** Optional timezone (default: UTC) */
159
+ timezone?: string
160
+ }
161
+
162
+ /** Event trigger configuration */
163
+ export interface EventTriggerConfig {
164
+ /** Internal event type */
165
+ eventType: string
166
+ /** Event source */
167
+ source?: string
168
+ }
169
+
170
+ /** Union of all trigger configs */
171
+ export type TriggerConfig = WebhookTriggerConfig | ScheduleTriggerConfig | EventTriggerConfig
172
+
173
+ // ============================================================================
174
+ // Trigger Definition
175
+ // ============================================================================
176
+
177
+ /**
178
+ * Trigger metadata - entry points that initiate resource execution
179
+ *
180
+ * Triggers represent how executions start: webhooks from external services,
181
+ * scheduled cron jobs, platform events, or manual user actions.
182
+ *
183
+ * BREAKING CHANGES (2025-11-30):
137
184
  * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
138
- * - Field renames: `id` -> `resourceId` (inherited), `type` -> `triggerType`
139
- * - Relationship rename: `invokes` -> `triggers` (unified vocabulary)
140
- * - New required fields: `version` (inherited), `type: 'trigger'` (inherited)
141
- * - triggers object now includes `externalResources` option
142
- *
143
- * @example
144
- * // TriggerDefinition - metadata only
145
- * {
146
- * resourceId: 'trigger-new-order',
147
- * type: 'trigger',
148
- * triggerType: 'webhook',
149
- * name: 'New Order',
150
- * description: 'Webhook from Shopify on new orders',
151
- * version: '1.0.0',
152
- * status: 'prod',
153
- * webhookPath: '/webhooks/shopify/orders'
154
- * }
155
- *
156
- * // Relationships declared in ResourceRelationships (not on TriggerDefinition):
157
- * // relationships: {
158
- * // 'trigger-new-order': { triggers: { workflows: ['order-fulfillment-workflow'] } }
159
- * // }
160
- */
161
- export interface TriggerDefinition extends ResourceDefinition {
162
- /** Resource type discriminator (narrowed from base union) */
163
- type: 'trigger'
164
-
165
- /** Trigger mechanism type (renamed from 'type' to avoid collision with base type discriminator) */
166
- triggerType: 'webhook' | 'schedule' | 'manual' | 'event'
167
-
168
- /** Type-specific configuration */
169
- config?: TriggerConfig
170
-
171
- // Legacy fields (deprecated, use config instead)
172
- /** For webhook triggers: path like '/webhooks/shopify/orders' */
173
- webhookPath?: string
174
- /** For schedule triggers: cron expression like '0 6 * * *' */
175
- schedule?: string
176
- /** For event triggers: event type like 'low-stock-alert' */
177
- eventType?: string
178
-
179
- // NOTE: What this trigger starts is declared in ResourceRelationships, not here
180
- // This prevents duplication - triggers are forward-declared in relationships
181
- }
182
-
183
- /**
184
- * Integration metadata - external service connections
185
- *
186
- * References credentials table for actual connection. No connection status
187
- * stored here (queried at runtime from credentials table).
188
- *
189
- * BREAKING CHANGES (2025-11-30):
185
+ * - Field renames: `id` -> `resourceId` (inherited), `type` -> `triggerType`
186
+ * - Relationship rename: `invokes` -> `triggers` (unified vocabulary)
187
+ * - New required fields: `version` (inherited), `type: 'trigger'` (inherited)
188
+ * - triggers object now includes `externalResources` option
189
+ *
190
+ * @example
191
+ * // TriggerDefinition - metadata only
192
+ * {
193
+ * resourceId: 'trigger-new-order',
194
+ * type: 'trigger',
195
+ * triggerType: 'webhook',
196
+ * name: 'New Order',
197
+ * description: 'Webhook from Shopify on new orders',
198
+ * version: '1.0.0',
199
+ * status: 'prod',
200
+ * webhookPath: '/webhooks/shopify/orders'
201
+ * }
202
+ *
203
+ * // Relationships declared in ResourceRelationships (not on TriggerDefinition):
204
+ * // relationships: {
205
+ * // 'trigger-new-order': { triggers: { workflows: ['order-fulfillment-workflow'] } }
206
+ * // }
207
+ */
208
+ export interface TriggerDefinition extends ResourceDefinition {
209
+ /** Resource type discriminator (narrowed from base union) */
210
+ type: 'trigger'
211
+
212
+ /** Trigger mechanism type (renamed from 'type' to avoid collision with base type discriminator) */
213
+ triggerType: 'webhook' | 'schedule' | 'manual' | 'event'
214
+
215
+ /** Type-specific configuration */
216
+ config?: TriggerConfig
217
+
218
+ // Legacy fields (deprecated, use config instead)
219
+ /** For webhook triggers: path like '/webhooks/shopify/orders' */
220
+ webhookPath?: string
221
+ /** For schedule triggers: cron expression like '0 6 * * *' */
222
+ schedule?: string
223
+ /** For event triggers: event type like 'low-stock-alert' */
224
+ eventType?: string
225
+
226
+ // NOTE: What this trigger starts is declared in ResourceRelationships, not here
227
+ // This prevents duplication - triggers are forward-declared in relationships
228
+ }
229
+
230
+ /**
231
+ * Integration metadata - external service connections
232
+ *
233
+ * References credentials table for actual connection. No connection status
234
+ * stored here (queried at runtime from credentials table).
235
+ *
236
+ * BREAKING CHANGES (2025-11-30):
190
237
  * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
191
- * - Field renames: `id` -> `resourceId` (inherited)
192
- * - New required field: `status` (inherited) - organizations must add status to all integrations
193
- * - New required field: `version` (inherited) - organizations must add version to all integrations
194
- * - New required field: `type: 'integration'` (inherited) - resource type discriminator
195
- *
196
- * @example
197
- * {
198
- * resourceId: 'integration-shopify-prod',
199
- * type: 'integration',
200
- * provider: 'shopify',
201
- * credentialName: 'shopify-prod',
202
- * name: 'Shopify Production',
203
- * description: 'E-commerce platform',
204
- * version: '1.0.0',
205
- * status: 'prod'
206
- * }
207
- */
208
- export interface IntegrationDefinition extends ResourceDefinition {
209
- /** Resource type discriminator (narrowed from base union) */
210
- type: 'integration'
211
-
212
- /** Integration provider type */
213
- provider: IntegrationType
214
- /** References credentials table (e.g., 'shopify-prod', 'zendesk-api') */
215
- credentialName: string
216
- }
217
-
218
- /**
219
- * Explicit resource relationship declaration
220
- *
221
- * Single-direction only - Command View derives reverse relationships.
222
- * Agents/workflows declare what they trigger and use.
223
- *
224
- * @example
225
- * {
226
- * triggers: { workflows: ['order-fulfillment-workflow'] },
227
- * uses: { integrations: ['integration-shopify-prod', 'integration-postgres'] }
228
- * }
229
- */
230
- export interface RelationshipDeclaration {
231
- /** Resources this resource triggers */
232
- triggers?: {
233
- /** Agent resourceIds this resource triggers */
234
- agents?: string[]
235
- /** Workflow resourceIds this resource triggers */
236
- workflows?: string[]
237
- }
238
- /** Integrations this resource uses */
239
- uses?: {
240
- /** Integration IDs this resource uses */
241
- integrations?: string[]
242
- }
243
- }
244
-
245
- /**
246
- * Resource relationships map
247
- * Maps resourceId to its relationship declarations
248
- *
249
- * @example
250
- * {
251
- * 'order-processor-agent': {
252
- * triggers: { workflows: ['order-fulfillment-workflow'] },
253
- * uses: { integrations: ['integration-shopify-prod'] }
254
- * }
255
- * }
256
- */
257
- export type ResourceRelationships = Record<string, RelationshipDeclaration>
258
-
259
- // ============================================================================
260
- // External Resource Types
261
- // ============================================================================
262
-
263
- /**
264
- * External platform type
265
- * Supported third-party automation platforms
266
- */
267
- export type ExternalPlatform = 'n8n' | 'make' | 'zapier' | 'other'
268
-
269
- /**
270
- * External automation resource metadata
271
- *
272
- * Represents workflows/automations running on third-party platforms
273
- * (n8n, Make, Zapier, etc.) for visualization in Command View.
274
- *
275
- * NOTE: This is metadata ONLY for visualization. No execution logic,
276
- * no API integration with external platforms, no status syncing.
277
- *
278
- * BREAKING CHANGES (2025-11-30):
238
+ * - Field renames: `id` -> `resourceId` (inherited)
239
+ * - New required field: `status` (inherited) - organizations must add status to all integrations
240
+ * - New required field: `version` (inherited) - organizations must add version to all integrations
241
+ * - New required field: `type: 'integration'` (inherited) - resource type discriminator
242
+ *
243
+ * @example
244
+ * {
245
+ * resourceId: 'integration-shopify-prod',
246
+ * type: 'integration',
247
+ * provider: 'shopify',
248
+ * credentialName: 'shopify-prod',
249
+ * name: 'Shopify Production',
250
+ * description: 'E-commerce platform',
251
+ * version: '1.0.0',
252
+ * status: 'prod'
253
+ * }
254
+ */
255
+ export interface IntegrationDefinition extends ResourceDefinition {
256
+ /** Resource type discriminator (narrowed from base union) */
257
+ type: 'integration'
258
+
259
+ /** OM descriptor that owns canonical identity and governance metadata. */
260
+ resource?: Extract<ResourceEntry, { kind: 'integration' }>
261
+
262
+ /** Integration provider type */
263
+ provider: IntegrationType
264
+ /** References credentials table (e.g., 'shopify-prod', 'zendesk-api') */
265
+ credentialName: string
266
+ }
267
+
268
+ /**
269
+ * Explicit resource relationship declaration
270
+ *
271
+ * Single-direction only - Command View derives reverse relationships.
272
+ * Agents/workflows declare what they trigger and use.
273
+ *
274
+ * @example
275
+ * {
276
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
277
+ * uses: { integrations: ['integration-shopify-prod', 'integration-postgres'] }
278
+ * }
279
+ */
280
+ export interface RelationshipDeclaration {
281
+ /** Resources this resource triggers */
282
+ triggers?: {
283
+ /** Agent resourceIds this resource triggers */
284
+ agents?: string[]
285
+ /** Workflow resourceIds this resource triggers */
286
+ workflows?: string[]
287
+ }
288
+ /** Integrations this resource uses */
289
+ uses?: {
290
+ /** Integration IDs this resource uses */
291
+ integrations?: string[]
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Resource relationships map
297
+ * Maps resourceId to its relationship declarations
298
+ *
299
+ * @example
300
+ * {
301
+ * 'order-processor-agent': {
302
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
303
+ * uses: { integrations: ['integration-shopify-prod'] }
304
+ * }
305
+ * }
306
+ */
307
+ export type ResourceRelationships = Record<string, RelationshipDeclaration>
308
+
309
+ // ============================================================================
310
+ // External Resource Types
311
+ // ============================================================================
312
+
313
+ /**
314
+ * External platform type
315
+ * Supported third-party automation platforms
316
+ */
317
+ export type ExternalPlatform = 'n8n' | 'make' | 'zapier' | 'other'
318
+
319
+ /**
320
+ * External automation resource metadata
321
+ *
322
+ * Represents workflows/automations running on third-party platforms
323
+ * (n8n, Make, Zapier, etc.) for visualization in Command View.
324
+ *
325
+ * NOTE: This is metadata ONLY for visualization. No execution logic,
326
+ * no API integration with external platforms, no status syncing.
327
+ *
328
+ * BREAKING CHANGES (2025-11-30):
279
329
  * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
280
- * - Field renames: `id` -> `resourceId` (inherited)
281
- * - New required field: `version` (inherited) - organizations must add version to all external resources
282
- * - New required field: `type: 'external'` (inherited) - resource type discriminator
283
- * - REMOVED FIELD: `triggeredBy` - per relationship-consolidation design, all relationships are forward-only declarations
284
- *
285
- * @example
286
- * {
287
- * resourceId: 'external-n8n-order-sync',
288
- * type: 'external',
289
- * version: '1.0.0',
290
- * platform: 'n8n',
291
- * name: 'Shopify Order Sync',
292
- * description: 'Legacy n8n workflow for syncing Shopify orders',
293
- * status: 'prod',
294
- * platformUrl: 'https://n8n.client.com/workflow/123',
295
- * triggers: { workflows: ['order-fulfillment-workflow'] },
296
- * uses: { integrations: ['integration-shopify-prod'] }
297
- * }
298
- */
299
- export interface ExternalResourceDefinition extends ResourceDefinition {
300
- /** Resource type discriminator (narrowed from base union) */
301
- type: 'external'
302
-
303
- /** Platform type */
304
- platform: ExternalPlatform
305
-
306
- // Optional platform-specific metadata
307
- /** Link to external platform (e.g., n8n workflow editor URL) */
308
- platformUrl?: string
309
- /** Platform's internal ID/reference */
310
- externalId?: string
311
-
312
- /** What this external resource triggers (external -> internal) */
313
- triggers?: {
314
- /** Elevasis workflow resourceIds this external automation triggers */
315
- workflows?: string[]
316
- /** Elevasis agent resourceIds this external automation triggers */
317
- agents?: string[]
318
- }
319
-
320
- /** Integrations this external resource uses (shared credentials) */
321
- uses?: {
322
- /** Integration IDs this external automation uses */
323
- integrations?: string[]
324
- }
325
-
326
- // NOTE: triggeredBy field removed - per relationship-consolidation design,
327
- // all relationships are forward-only declarations. Graph edges are built
328
- // from forward declarations only.
329
- }
330
-
331
- /**
332
- * Human Checkpoint definition - human decision points in automation
333
- *
334
- * Represents where human judgment is deployed in the automation landscape.
335
- * Tasks with matching command_queue_group are routed to this checkpoint.
336
- *
337
- * BREAKING CHANGES (2025-11-30):
330
+ * - Field renames: `id` -> `resourceId` (inherited)
331
+ * - New required field: `version` (inherited) - organizations must add version to all external resources
332
+ * - New required field: `type: 'external'` (inherited) - resource type discriminator
333
+ * - REMOVED FIELD: `triggeredBy` - per relationship-consolidation design, all relationships are forward-only declarations
334
+ *
335
+ * @example
336
+ * {
337
+ * resourceId: 'external-n8n-order-sync',
338
+ * type: 'external',
339
+ * version: '1.0.0',
340
+ * platform: 'n8n',
341
+ * name: 'Shopify Order Sync',
342
+ * description: 'Legacy n8n workflow for syncing Shopify orders',
343
+ * status: 'prod',
344
+ * platformUrl: 'https://n8n.client.com/workflow/123',
345
+ * triggers: { workflows: ['order-fulfillment-workflow'] },
346
+ * uses: { integrations: ['integration-shopify-prod'] }
347
+ * }
348
+ */
349
+ export interface ExternalResourceDefinition extends ResourceDefinition {
350
+ /** Resource type discriminator (narrowed from base union) */
351
+ type: 'external'
352
+
353
+ /** Platform type */
354
+ platform: ExternalPlatform
355
+
356
+ // Optional platform-specific metadata
357
+ /** Link to external platform (e.g., n8n workflow editor URL) */
358
+ platformUrl?: string
359
+ /** Platform's internal ID/reference */
360
+ externalId?: string
361
+
362
+ /** What this external resource triggers (external -> internal) */
363
+ triggers?: {
364
+ /** Elevasis workflow resourceIds this external automation triggers */
365
+ workflows?: string[]
366
+ /** Elevasis agent resourceIds this external automation triggers */
367
+ agents?: string[]
368
+ }
369
+
370
+ /** Integrations this external resource uses (shared credentials) */
371
+ uses?: {
372
+ /** Integration IDs this external automation uses */
373
+ integrations?: string[]
374
+ }
375
+
376
+ // NOTE: triggeredBy field removed - per relationship-consolidation design,
377
+ // all relationships are forward-only declarations. Graph edges are built
378
+ // from forward declarations only.
379
+ }
380
+
381
+ /**
382
+ * Human Checkpoint definition - human decision points in automation
383
+ *
384
+ * Represents where human judgment is deployed in the automation landscape.
385
+ * Tasks with matching command_queue_group are routed to this checkpoint.
386
+ *
387
+ * BREAKING CHANGES (2025-11-30):
338
388
  * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
339
- * - Field renames: `id` -> `resourceId` (inherited)
340
- * - description is now REQUIRED (was optional) - organizations must add description to all human checkpoints
341
- * - New required field: `version` (inherited) - organizations must add version to all human checkpoints
342
- * - New required field: `type: 'human'` (inherited) - resource type discriminator
343
- *
344
- * @example
345
- * {
346
- * resourceId: 'sales-approval',
347
- * type: 'human',
348
- * name: 'Sales Approval Queue',
349
- * description: 'High-value order approvals for sales team',
350
- * version: '1.0.0',
351
- * status: 'prod',
352
- * requestedBy: { agents: ['order-processor-agent'] },
353
- * routesTo: { agents: ['order-fulfillment-agent'] }
354
- * }
355
- */
356
- export interface HumanCheckpointDefinition extends ResourceDefinition {
357
- /** Resource type discriminator (narrowed from base union) */
358
- type: 'human'
359
-
360
- /** Resources that create tasks for this checkpoint */
361
- requestedBy?: {
362
- /** Agent resourceIds that request approval here */
363
- agents?: string[]
364
- /** Workflow resourceIds that request approval here */
365
- workflows?: string[]
366
- }
367
-
368
- /** Resources that receive approved decisions */
369
- routesTo?: {
370
- /** Agent resourceIds that handle approved tasks */
371
- agents?: string[]
372
- /** Workflow resourceIds that handle approved tasks */
373
- workflows?: string[]
374
- }
375
- }
389
+ * - Field renames: `id` -> `resourceId` (inherited)
390
+ * - description is now REQUIRED (was optional) - organizations must add description to all human checkpoints
391
+ * - New required field: `version` (inherited) - organizations must add version to all human checkpoints
392
+ * - New required field: `type: 'human'` (inherited) - resource type discriminator
393
+ *
394
+ * @example
395
+ * {
396
+ * resourceId: 'sales-approval',
397
+ * type: 'human',
398
+ * name: 'Sales Approval Queue',
399
+ * description: 'High-value order approvals for sales team',
400
+ * version: '1.0.0',
401
+ * status: 'prod',
402
+ * requestedBy: { agents: ['order-processor-agent'] },
403
+ * routesTo: { agents: ['order-fulfillment-agent'] }
404
+ * }
405
+ */
406
+ export interface HumanCheckpointDefinition extends ResourceDefinition {
407
+ /** Resource type discriminator (narrowed from base union) */
408
+ type: 'human'
409
+
410
+ /** Resources that create tasks for this checkpoint */
411
+ requestedBy?: {
412
+ /** Agent resourceIds that request approval here */
413
+ agents?: string[]
414
+ /** Workflow resourceIds that request approval here */
415
+ workflows?: string[]
416
+ }
417
+
418
+ /** Resources that receive approved decisions */
419
+ routesTo?: {
420
+ /** Agent resourceIds that handle approved tasks */
421
+ agents?: string[]
422
+ /** Workflow resourceIds that handle approved tasks */
423
+ workflows?: string[]
424
+ }
425
+ }