File size: 1,576 Bytes
f5d03aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from typing import Any, Literal

from pydantic import BaseModel, Field


NodeKind = Literal["Input", "AI Worker", "Decision Rules", "Human Review", "Simulated Tool", "Output"]


class Position(BaseModel):
    x: float = 0
    y: float = 0


class NodeData(BaseModel):
    label: str
    mode: NodeKind
    prompt: str = ""
    value: str = ""
    description: str = ""
    input_guidance: str = ""


class WorkflowNode(BaseModel):
    id: str
    type: str = "workflow"
    position: Position = Field(default_factory=Position)
    data: NodeData


class EdgeData(BaseModel):
    connectionType: Literal["flow", "tool"] = "flow"


class WorkflowEdge(BaseModel):
    id: str
    source: str
    target: str
    label: str = ""
    sourceHandle: str | None = None
    targetHandle: str | None = None
    data: EdgeData = Field(default_factory=EdgeData)


class Workflow(BaseModel):
    name: str = "Untitled workflow"
    nodes: list[WorkflowNode]
    edges: list[WorkflowEdge]


class StartRequest(BaseModel):
    workflow: Workflow
    input: str = ""


class ResumeRequest(BaseModel):
    run_id: str
    response: str


class TraceEvent(BaseModel):
    node_id: str
    label: str
    mode: str
    input: str
    output: str
    kind: Literal["flow", "tool"] = "flow"


class RunResponse(BaseModel):
    run_id: str
    status: Literal["completed", "awaiting_review", "error"]
    current_node_id: str | None = None
    message: str = ""
    result: str = ""
    trace: list[TraceEvent] = Field(default_factory=list)
    detail: dict[str, Any] = Field(default_factory=dict)