@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
333 lines • 8.68 kB
TypeScript
/**
* Orchestration System Type Definitions
* @description Core type definitions for the template orchestration system
* @author Optimizely MCP Server
* @version 1.0.0
*/
export interface OrchestrationTemplate {
id: string;
name: string;
description: string;
version: string;
type: 'user' | 'system';
platform: 'feature' | 'web' | 'both';
author: string;
created_at: Date;
updated_at: Date;
template_format_version?: number;
parameters: TemplateParameters;
steps: OrchestrationStep[];
config?: OrchestrationConfig;
outputs?: TemplateOutputs;
tags?: string[];
examples?: TemplateExample[];
}
export interface TemplateParameters {
[key: string]: ParameterDefinition;
}
export interface ParameterDefinition {
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
description: string;
required: boolean;
default?: any;
validation?: ParameterValidation;
}
export interface ParameterValidation {
pattern?: string;
min?: number;
max?: number;
enum?: any[];
custom?: string;
}
export interface OrchestrationConfig {
continue_on_error?: boolean;
rollback_on_failure?: boolean;
parallel_execution?: boolean;
max_execution_time?: number;
max_retries?: number;
pre_execution?: string;
post_execution?: string;
log_level?: 'debug' | 'info' | 'warn' | 'error';
capture_intermediate_results?: boolean;
}
export interface TemplateOutputs {
[key: string]: OutputDefinition;
}
export interface OutputDefinition {
description: string;
value: string;
type?: string;
}
export type TemplateStep = OrchestrationStep;
export interface OrchestrationStep {
id: string;
name: string;
description?: string;
type: 'template' | 'conditional' | 'loop' | 'plugin' | 'wait' | 'parallel';
template?: TemplateStepConfig;
condition?: ConditionalStepConfig;
loop?: LoopStepConfig;
plugin?: PluginStepConfig;
wait?: WaitStepConfig;
parallel?: ParallelStepConfig;
depends_on?: string[];
skip_if?: string;
retry?: RetryConfig;
on_error?: 'fail' | 'continue' | 'rollback';
error_handler?: OrchestrationStep;
timeout?: number;
}
export interface TemplateStepConfig {
entity_type: string;
operation: 'create' | 'update' | 'delete' | 'adopt_or_create';
mode?: 'direct' | 'template';
entity_data?: any;
template_data?: any;
inputs?: {
[templateField: string]: string | any;
};
system_template_id?: string;
adopt_if_exists?: boolean;
optional?: boolean;
project_id?: string;
}
export interface ConditionalStepConfig {
if: string;
then: OrchestrationStep[];
else?: OrchestrationStep[];
}
export interface LoopStepConfig {
over: string;
iterator: string;
index?: string;
steps: OrchestrationStep[];
max_iterations?: number;
break_if?: string;
}
export interface PluginStepConfig {
code: string;
inputs?: Record<string, any>;
outputs?: string[];
}
export interface WaitStepConfig {
duration?: number;
until?: string;
max_wait?: number;
poll_interval?: number;
}
export interface ParallelStepConfig {
steps: OrchestrationStep[];
max_concurrency?: number;
fail_fast?: boolean;
}
export interface RetryConfig {
max_attempts: number;
delay: number;
backoff?: 'linear' | 'exponential';
backoff_multiplier?: number;
}
export interface OrchestrationContext {
template_id: string;
execution_id: string;
project_id?: string;
environment?: string;
user?: string;
entityRouter: any;
logger: any;
metricsProvider?: any;
cacheManager: any;
mcpTools?: any;
dry_run?: boolean;
debug?: boolean;
}
export interface OrchestrationState {
execution_id: string;
template_id: string;
status: 'initializing' | 'running' | 'completed' | 'failed' | 'cancelled';
parameters: Record<string, any>;
outputs: Record<string, any>;
steps: Map<string, StepExecutionState>;
variables: Record<string, any>;
errors: ExecutionError[];
started_at: Date;
completed_at?: Date;
get(path: string): any;
set(path: string, value: any): void;
recordStepStart(stepId: string): void;
recordStepComplete(stepId: string, result: any): void;
recordStepError(stepId: string, error: Error): void;
recordSkippedStep(stepId: string): void;
}
export interface StepExecutionState {
step_id: string;
status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
started_at?: Date;
completed_at?: Date;
result?: any;
error?: ExecutionError;
retry_count: number;
}
export interface ExecutionError {
step_id?: string;
message: string;
code?: string;
details?: any;
timestamp: Date;
recoverable: boolean;
}
export interface SystemTemplate {
id: string;
entity_type: string;
operation: string;
platform: 'feature' | 'web' | 'both';
schema: any;
orchestration_metadata: OrchestrationMetadata;
}
export interface OrchestrationMetadata {
outputs: {
[key: string]: {
type: string;
description: string;
path: string;
};
};
dependencies?: {
entity_type: string;
required: boolean;
description: string;
}[];
avg_execution_time_ms?: number;
tags?: string[];
min_version?: string;
max_version?: string;
}
export interface OrchestrationResult {
execution_id: string;
template_id: string;
template_name: string;
success: boolean;
status: 'completed' | 'failed' | 'cancelled';
summary: OrchestrationSummary;
created_entities: CreatedEntity[];
updated_entities?: UpdatedEntity[];
deleted_entities?: DeletedEntity[];
outputs: Record<string, any>;
execution_time_ms: number;
steps_executed: number;
steps_skipped: number;
steps_failed: number;
errors: ExecutionError[];
warnings: string[];
debug?: {
execution_plan?: ExecutionPlan;
step_results?: Map<string, any>;
state_snapshots?: any[];
};
}
export interface OrchestrationSummary {
headline: string;
operation_type: string;
total_operations: number;
successful_operations: number;
key_entities: KeyEntity[];
insights?: string[];
}
export interface KeyEntity {
type: string;
id: string;
name?: string;
operation: string;
}
export interface CreatedEntity {
step_id: string;
entity_type: string;
entity_id: string;
entity_name?: string;
details?: any;
}
export interface UpdatedEntity extends CreatedEntity {
changes: any;
}
export interface DeletedEntity {
step_id: string;
entity_type: string;
entity_id: string;
}
export interface ExecutionPlan {
batches: ExecutionBatch[];
estimated_duration_ms: number;
dependency_graph: DependencyGraph;
optimization_notes?: string[];
}
export interface ExecutionBatch {
batch_number: number;
steps: OrchestrationStep[];
can_parallelize: boolean;
estimated_duration_ms: number;
}
export interface DependencyGraph {
nodes: Map<string, DependencyNode>;
edges: DependencyEdge[];
}
export interface DependencyNode {
step_id: string;
step_name: string;
dependencies: string[];
dependents: string[];
}
export interface DependencyEdge {
from: string;
to: string;
type: 'required' | 'optional';
}
export interface PluginContext {
entityRouter: any;
metricsProvider?: any;
state: OrchestrationState;
parameters: Record<string, any>;
outputs: Record<string, any>;
logger: any;
permissions: PluginPermissions;
}
export interface PluginPermissions {
read_entities: boolean;
write_state: boolean;
access_metrics: boolean;
external_requests: boolean;
}
export interface PluginResult {
success: boolean;
output?: any;
error?: string;
logs?: string[];
metrics?: Record<string, number>;
}
export interface TemplateRecord {
id: string;
name: string;
version: string;
type: 'user' | 'system';
template_data: string;
created_at: string;
updated_at: string;
created_by?: string;
is_active: boolean;
}
export interface ExecutionRecord {
id: string;
template_id: string;
started_at: string;
completed_at?: string;
status: string;
parameters?: string;
state?: string;
result?: string;
error?: string;
}
export interface TemplateExample {
name: string;
description: string;
parameters: Record<string, any>;
expected_outcome?: string;
}
//# sourceMappingURL=index.d.ts.map