@elevasis/sdk 0.2.0 → 0.3.2

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.
package/dist/index.d.ts CHANGED
@@ -289,6 +289,232 @@ interface FormSchema {
289
289
  layout?: 'vertical' | 'horizontal' | 'grid';
290
290
  }
291
291
 
292
+ /**
293
+ * Command View Types
294
+ *
295
+ * Unified type definitions for the Command View graph visualization.
296
+ * These types are used by both backend serialization and frontend rendering.
297
+ *
298
+ * Command View shows the resource graph: agents, workflows, triggers, integrations,
299
+ * external resources, and human checkpoints with their relationships.
300
+ */
301
+
302
+ /**
303
+ * Extended agent metadata for Command View
304
+ * Includes model and capability information for graph display
305
+ */
306
+ interface CommandViewAgent extends ResourceDefinition {
307
+ type: 'agent';
308
+ modelProvider: string;
309
+ modelId: string;
310
+ toolCount: number;
311
+ hasKnowledgeMap: boolean;
312
+ hasMemory: boolean;
313
+ sessionCapable: boolean;
314
+ }
315
+ /**
316
+ * Extended workflow metadata for Command View
317
+ * Includes step information for graph display
318
+ */
319
+ interface CommandViewWorkflow extends ResourceDefinition {
320
+ type: 'workflow';
321
+ stepCount: number;
322
+ entryPoint: string;
323
+ }
324
+ /**
325
+ * Relationship types between resources
326
+ *
327
+ * - triggers: Resource initiates/starts another resource (orange)
328
+ * - uses: Resource uses an integration (teal)
329
+ * - approval: Resource requires human approval (yellow)
330
+ */
331
+ type RelationshipType = 'triggers' | 'uses' | 'approval';
332
+ /**
333
+ * Command View edge (relationship between resources)
334
+ */
335
+ interface CommandViewEdge {
336
+ id: string;
337
+ source: string;
338
+ target: string;
339
+ relationship: RelationshipType;
340
+ label?: string;
341
+ }
342
+ /**
343
+ * Command View data structure
344
+ * Complete graph data for visualization
345
+ *
346
+ * Backend serializes this once at startup and serves it via /command-view endpoint.
347
+ * Frontend consumes this directly for graph rendering.
348
+ */
349
+ interface CommandViewData {
350
+ workflows: CommandViewWorkflow[];
351
+ agents: CommandViewAgent[];
352
+ triggers: TriggerDefinition[];
353
+ integrations: IntegrationDefinition[];
354
+ externalResources: ExternalResourceDefinition[];
355
+ humanCheckpoints: HumanCheckpointDefinition[];
356
+ edges: CommandViewEdge[];
357
+ domainDefinitions?: DomainDefinition[];
358
+ }
359
+
360
+ /**
361
+ * Serialized Registry Types
362
+ *
363
+ * Pre-computed JSON-safe types for API responses and Command View.
364
+ * Serialization happens once at API startup, enabling instant response times.
365
+ */
366
+
367
+ /**
368
+ * Serialized form field for API responses
369
+ */
370
+ interface SerializedFormField {
371
+ name: string;
372
+ label: string;
373
+ type: FormFieldType;
374
+ defaultValue?: unknown;
375
+ required?: boolean;
376
+ placeholder?: string;
377
+ description?: string;
378
+ options?: Array<{
379
+ label: string;
380
+ value: string | number;
381
+ }>;
382
+ min?: number;
383
+ max?: number;
384
+ }
385
+ /**
386
+ * Serialized form schema for API responses
387
+ */
388
+ interface SerializedFormSchema {
389
+ title?: string;
390
+ description?: string;
391
+ fields: SerializedFormField[];
392
+ layout?: 'vertical' | 'horizontal' | 'grid';
393
+ }
394
+ /**
395
+ * Serialized execution form schema for API responses
396
+ */
397
+ interface SerializedExecutionFormSchema extends SerializedFormSchema {
398
+ fieldMappings?: Record<string, string>;
399
+ submitButton?: {
400
+ label?: string;
401
+ loadingLabel?: string;
402
+ confirmMessage?: string;
403
+ };
404
+ }
405
+ /**
406
+ * Serialized schedule config for API responses
407
+ */
408
+ interface SerializedScheduleConfig {
409
+ enabled: boolean;
410
+ defaultSchedule?: string;
411
+ allowedPatterns?: string[];
412
+ }
413
+ /**
414
+ * Serialized webhook config for API responses
415
+ */
416
+ interface SerializedWebhookConfig {
417
+ enabled: boolean;
418
+ payloadSchema?: unknown;
419
+ }
420
+ /**
421
+ * Serialized execution interface for API responses
422
+ */
423
+ interface SerializedExecutionInterface {
424
+ form: SerializedExecutionFormSchema;
425
+ schedule?: SerializedScheduleConfig;
426
+ webhook?: SerializedWebhookConfig;
427
+ }
428
+ /**
429
+ * Serialized agent definition (JSON-safe)
430
+ * Result of serializeDefinition(AgentDefinition)
431
+ */
432
+ interface SerializedAgentDefinition {
433
+ config: {
434
+ resourceId: string;
435
+ name: string;
436
+ description: string;
437
+ version: string;
438
+ type: 'agent';
439
+ status: 'dev' | 'prod';
440
+ systemPrompt: string;
441
+ constraints?: {
442
+ maxIterations?: number;
443
+ timeout?: number;
444
+ maxSessionMemoryKeys?: number;
445
+ maxMemoryTokens?: number;
446
+ };
447
+ sessionCapable?: boolean;
448
+ memoryPreferences?: string;
449
+ };
450
+ modelConfig: {
451
+ provider: string;
452
+ model: string;
453
+ apiKey: string;
454
+ temperature: number;
455
+ maxTokens: number;
456
+ topP?: number;
457
+ modelOptions?: Record<string, unknown>;
458
+ };
459
+ contract: {
460
+ inputSchema: object;
461
+ outputSchema?: object;
462
+ };
463
+ tools: Array<{
464
+ name: string;
465
+ description: string;
466
+ inputSchema?: object;
467
+ outputSchema?: object;
468
+ }>;
469
+ knowledgeMap?: {
470
+ nodeCount: number;
471
+ nodes: Array<{
472
+ id: string;
473
+ description: string;
474
+ loaded: boolean;
475
+ hasPrompt: boolean;
476
+ }>;
477
+ };
478
+ metricsConfig?: object;
479
+ interface?: SerializedExecutionInterface;
480
+ }
481
+ /**
482
+ * Serialized workflow definition (JSON-safe)
483
+ * Result of serializeDefinition(WorkflowDefinition)
484
+ */
485
+ interface SerializedWorkflowDefinition {
486
+ config: {
487
+ resourceId: string;
488
+ name: string;
489
+ description: string;
490
+ version: string;
491
+ type: 'workflow';
492
+ status: 'dev' | 'prod';
493
+ };
494
+ entryPoint: string;
495
+ steps: Array<{
496
+ id: string;
497
+ name: string;
498
+ description: string;
499
+ inputSchema?: object;
500
+ outputSchema?: object;
501
+ next: {
502
+ type: 'linear' | 'conditional';
503
+ target?: string;
504
+ routes?: Array<{
505
+ target: string;
506
+ }>;
507
+ default?: string;
508
+ } | null;
509
+ }>;
510
+ contract: {
511
+ inputSchema: object;
512
+ outputSchema?: object;
513
+ };
514
+ metricsConfig?: object;
515
+ interface?: SerializedExecutionInterface;
516
+ }
517
+
292
518
  /**
293
519
  * Model Configuration
294
520
  * Centralized model information, configuration, options, constraints, and validation
@@ -850,6 +1076,157 @@ interface OrganizationResources {
850
1076
  /** Human checkpoint definitions - human decision points in automation */
851
1077
  humanCheckpoints?: HumanCheckpointDefinition[];
852
1078
  }
1079
+ /**
1080
+ * Organization Registry type
1081
+ */
1082
+ type OrganizationRegistry = Record<string, OrganizationResources>;
1083
+ declare class ResourceRegistry {
1084
+ private registry;
1085
+ /**
1086
+ * Pre-serialized organization data cache
1087
+ * Computed once at construction, never invalidated (static registry)
1088
+ */
1089
+ private serializedCache;
1090
+ constructor(registry: OrganizationRegistry);
1091
+ /**
1092
+ * Validates registry on construction
1093
+ * - Checks for duplicate resourceIds within organizations
1094
+ * - Validates model configurations against constraints
1095
+ * - Validates ExecutionInterface matches inputSchema
1096
+ * @throws Error if validation fails
1097
+ */
1098
+ private validateRegistry;
1099
+ /**
1100
+ * Validates relationship declarations reference valid resources
1101
+ * Runs at API server startup - fails fast in development
1102
+ * @throws Error if validation fails
1103
+ */
1104
+ private validateRelationships;
1105
+ /**
1106
+ * Get a resource definition by ID
1107
+ * Returns full definition (WorkflowDefinition or AgentDefinition)
1108
+ * Check definition.config.type to determine if it's a workflow or agent
1109
+ */
1110
+ getResourceDefinition(organizationName: string, resourceId: string): WorkflowDefinition | AgentDefinition | null;
1111
+ /**
1112
+ * List all resources for an organization
1113
+ * Returns ResourceDefinition metadata (not full definitions)
1114
+ *
1115
+ * Environment filtering (automatic):
1116
+ * - Development: Returns all resources (dev + prod)
1117
+ * - Production: Returns only prod resources (filters out dev)
1118
+ */
1119
+ listResourcesForOrganization(organizationName: string, environment?: ResourceStatus): ResourceList;
1120
+ /**
1121
+ * List all resources from all organizations
1122
+ * NOTE: For debugging only - returns raw registry data
1123
+ */
1124
+ listAllResources(): OrganizationRegistry;
1125
+ /**
1126
+ * Get triggers for an organization
1127
+ * @param organizationName - Organization name
1128
+ * @returns Array of trigger definitions (empty if none defined)
1129
+ */
1130
+ getTriggers(organizationName: string): TriggerDefinition[];
1131
+ /**
1132
+ * Get integrations for an organization
1133
+ * @param organizationName - Organization name
1134
+ * @returns Array of integration definitions (empty if none defined)
1135
+ */
1136
+ getIntegrations(organizationName: string): IntegrationDefinition[];
1137
+ /**
1138
+ * Get resource relationships for an organization
1139
+ * @param organizationName - Organization name
1140
+ * @returns Resource relationships map (undefined if none defined)
1141
+ */
1142
+ getRelationships(organizationName: string): ResourceRelationships | undefined;
1143
+ /**
1144
+ * Get a specific trigger by ID
1145
+ * @param organizationName - Organization name
1146
+ * @param triggerId - Trigger ID
1147
+ * @returns Trigger definition or null if not found
1148
+ */
1149
+ getTrigger(organizationName: string, triggerId: string): TriggerDefinition | null;
1150
+ /**
1151
+ * Get a specific integration by ID
1152
+ * @param organizationName - Organization name
1153
+ * @param integrationId - Integration ID
1154
+ * @returns Integration definition or null if not found
1155
+ */
1156
+ getIntegration(organizationName: string, integrationId: string): IntegrationDefinition | null;
1157
+ /**
1158
+ * Get external resources for an organization
1159
+ * @param organizationName - Organization name
1160
+ * @returns Array of external resource definitions (empty if none defined)
1161
+ */
1162
+ getExternalResources(organizationName: string): ExternalResourceDefinition[];
1163
+ /**
1164
+ * Get a specific external resource by ID
1165
+ * @param organizationName - Organization name
1166
+ * @param externalId - External resource ID
1167
+ * @returns External resource definition or null if not found
1168
+ */
1169
+ getExternalResource(organizationName: string, externalId: string): ExternalResourceDefinition | null;
1170
+ /**
1171
+ * Get human checkpoints for an organization
1172
+ * @param organizationName - Organization name
1173
+ * @returns Array of human checkpoint definitions (empty if none defined)
1174
+ */
1175
+ getHumanCheckpoints(organizationName: string): HumanCheckpointDefinition[];
1176
+ /**
1177
+ * Get a specific human checkpoint by ID
1178
+ * @param organizationName - Organization name
1179
+ * @param humanCheckpointId - Human checkpoint ID
1180
+ * @returns Human checkpoint definition or null if not found
1181
+ */
1182
+ getHumanCheckpoint(organizationName: string, humanCheckpointId: string): HumanCheckpointDefinition | null;
1183
+ /**
1184
+ * Get serialized resource definition (instant lookup)
1185
+ * Use for API responses - returns pre-computed JSON-safe structure
1186
+ *
1187
+ * @param organizationName - Organization name
1188
+ * @param resourceId - Resource ID
1189
+ * @returns Serialized definition or null if not found
1190
+ */
1191
+ getSerializedDefinition(organizationName: string, resourceId: string): SerializedAgentDefinition | SerializedWorkflowDefinition | null;
1192
+ /**
1193
+ * Get resource list for organization (instant lookup)
1194
+ * Use for /resources endpoint - returns pre-computed ResourceDefinition array
1195
+ *
1196
+ * @param organizationName - Organization name
1197
+ * @returns Resource list with workflows, agents, and total count
1198
+ */
1199
+ getResourceList(organizationName: string): {
1200
+ workflows: ResourceDefinition[];
1201
+ agents: ResourceDefinition[];
1202
+ total: number;
1203
+ };
1204
+ /**
1205
+ * Get Command View data for organization (instant lookup)
1206
+ * Use for /command-view endpoint - returns complete graph data
1207
+ *
1208
+ * @param organizationName - Organization name
1209
+ * @returns Command View data with nodes and edges
1210
+ */
1211
+ getCommandViewData(organizationName: string): CommandViewData;
1212
+ /**
1213
+ * List resources that have UI interfaces configured
1214
+ * Used by Execution Runner Catalog UI
1215
+ *
1216
+ * @param organizationName - Organization name
1217
+ * @param environment - Optional environment filter ('dev' or 'prod')
1218
+ * @returns Array of resources with interfaces
1219
+ */
1220
+ listExecutable(organizationName: string, environment?: 'dev' | 'prod'): Array<{
1221
+ resourceId: string;
1222
+ resourceName: string;
1223
+ resourceType: 'workflow' | 'agent';
1224
+ description?: string;
1225
+ status: 'dev' | 'prod';
1226
+ version: string;
1227
+ interface: SerializedExecutionInterface;
1228
+ }>;
1229
+ }
853
1230
 
854
1231
  /**
855
1232
  * MetricsCollector
@@ -1162,6 +1539,17 @@ interface DomainDefinition {
1162
1539
  /** Optional Tabler icon name (e.g., 'IconHeadset') */
1163
1540
  icon?: string;
1164
1541
  }
1542
+ /**
1543
+ * Resource list for organization
1544
+ * Returns ResourceDefinition metadata (not full definitions)
1545
+ */
1546
+ interface ResourceList {
1547
+ workflows: ResourceDefinition[];
1548
+ agents: ResourceDefinition[];
1549
+ total: number;
1550
+ organizationName: string;
1551
+ environment?: 'dev' | 'prod';
1552
+ }
1165
1553
  /** Webhook provider identifiers */
1166
1554
  type WebhookProviderType = 'cal-com' | 'fillout' | 'stripe' | 'signature-api' | 'instantly' | 'test';
1167
1555
  /** Webhook trigger configuration */
@@ -1433,6 +1821,20 @@ declare const DOMAINS: {
1433
1821
  */
1434
1822
  type ResourceDomain = (typeof DOMAINS)[keyof typeof DOMAINS];
1435
1823
 
1824
+ /**
1825
+ * Registry Validation Utilities
1826
+ *
1827
+ * Centralized validation logic for ResourceRegistry.
1828
+ * All validation runs at API startup - fails fast in development.
1829
+ */
1830
+
1831
+ declare class RegistryValidationError extends Error {
1832
+ readonly orgName: string;
1833
+ readonly resourceId: string | null;
1834
+ readonly field: string | null;
1835
+ constructor(orgName: string, resourceId: string | null, field: string | null, message: string);
1836
+ }
1837
+
1436
1838
  /**
1437
1839
  * Project configuration for an external developer project.
1438
1840
  * Defined in elevas.config.ts at the project root.
@@ -1471,5 +1873,5 @@ declare class ToolingError extends ExecutionError {
1471
1873
  constructor(errorType: string, message: string, details?: unknown);
1472
1874
  }
1473
1875
 
1474
- export { ExecutionError, StepType, ToolingError };
1876
+ export { ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError };
1475
1877
  export type { AgentConfig, AgentConstraints, AgentDefinition, ConditionalNext, Contract, DomainDefinition, ElevasConfig, EventTriggerConfig, ExecutionContext, ExecutionInterface, ExecutionMetadata, FormField, FormFieldType, FormSchema, IntegrationDefinition, LLMModel, LinearNext, ModelConfig, NextConfig, OrganizationResources, ResourceDefinition, ResourceDomain, ResourceMetricsConfig, ResourceStatus, ResourceType, ScheduleTriggerConfig, StepHandler, Tool, ToolExecutionOptions, ToolingErrorType, TriggerConfig, TriggerDefinition, WebhookProviderType, WebhookTriggerConfig, WorkflowConfig, WorkflowDefinition, WorkflowStep };