EmboFlow/apps/worker/src/contracts/execution-context.ts

107 lines
2.5 KiB
TypeScript

export type ExecutorType = "python" | "docker" | "http";
export type ArtifactType = "json" | "directory" | "video";
export type TaskStatus = "pending" | "queued" | "running" | "success" | "failed" | "cancelled";
export type TaskStatusCounts = {
pending: number;
queued: number;
running: number;
success: number;
failed: number;
cancelled: number;
};
export type TaskExecutionSummary = {
outcome: "success" | "failed";
executorType: ExecutorType;
assetCount: number;
artifactIds: string[];
stdoutLineCount: number;
stderrLineCount: number;
errorMessage?: string;
};
export type RunExecutionSummary = {
totalTaskCount: number;
completedTaskCount: number;
artifactCount: number;
stdoutLineCount: number;
stderrLineCount: number;
failedTaskIds: string[];
taskCounts: TaskStatusCounts;
};
export type ExecutorExecutionResult = {
result: unknown;
stdoutLines?: string[];
stderrLines?: string[];
};
export type CodeHookSpec = {
language: "python";
entrypoint?: string;
source: string;
};
export type NodeRuntimeConfig = {
definitionId?: string;
executorType?: ExecutorType;
executorConfig?: Record<string, unknown>;
codeHookSpec?: CodeHookSpec;
artifactType?: ArtifactType;
artifactTitle?: string;
};
export type RunRuntimeSnapshot = {
selectedPreset?: string;
nodeBindings?: Record<string, string>;
nodeConfigs?: Record<string, NodeRuntimeConfig>;
pluginRefs?: string[];
};
export type TaskRecord = {
id: string;
workflowRunId?: string;
workflowVersionId?: string;
nodeId: string;
nodeType?: string;
nodeDefinitionId?: string;
executorType: ExecutorType;
executorConfig?: Record<string, unknown>;
codeHookSpec?: CodeHookSpec;
artifactType?: ArtifactType;
artifactTitle?: string;
status: TaskStatus;
attempt?: number;
assetIds?: string[];
upstreamNodeIds?: string[];
outputArtifactIds?: string[];
errorMessage?: string;
startedAt?: string;
finishedAt?: string;
durationMs?: number;
logLines?: string[];
stdoutLines?: string[];
stderrLines?: string[];
summary?: TaskExecutionSummary;
lastResultPreview?: Record<string, unknown>;
};
export type ExecutionAsset = {
id: string;
displayName: string;
sourcePath?: string;
topLevelPaths?: string[];
detectedFormats?: string[];
summary?: Record<string, unknown>;
};
export type ExecutionContext = {
taskId: string;
workflowRunId?: string;
workflowVersionId?: string;
nodeId: string;
assetIds?: string[];
assets?: ExecutionAsset[];
nodeDefinitionId?: string;
};