persona-models 0.1.0__tar.gz

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.
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ .venv/
5
+ dist/
6
+ *.egg-info/
7
+ .eggs/
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: persona-models
3
+ Version: 0.1.0
4
+ Summary: Shared Pydantic models for Persona AI platform
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: pydantic>=2.0.0
@@ -0,0 +1,22 @@
1
+ from persona_models.common import create_uuid, create_shortuuid, Paginated
2
+ from persona_models.agents import AgentConfiguration, ModelConfiguration, SynthesizerConfiguration
3
+ from persona_models.sessions import (
4
+ Session, Message, FunctionCall, FunctionResponse, File, Image,
5
+ AgentContext, AgentResponse, GenerationResponse, TransferAction,
6
+ CollaborationMode, EmptyMessage, MessageAccumulator, merge_messages,
7
+ Source, SourceChunk, Reasoning,
8
+ )
9
+ from persona_models.workflows import Workflow, Connection, WorkflowResult
10
+ from persona_models.triggers import Trigger, TriggerSource, TriggerDestination, TriggerExecutionResult
11
+ from persona_models.credentials import Credentials, AuthorizeRequest
12
+ from persona_models.knowledge_bases import KnowledgeBase, KnowledgeBaseDocument
13
+ from persona_models.projects import Project
14
+ from persona_models.features import FeatureTemplate, Feature, McpServerConfiguration, FlagConfiguration
15
+ from persona_models.missions import Mission, MissionStep, WorkerAgent
16
+ from persona_models.service_prices import ServicePrice, Usage, UsageCost
17
+ from persona_models.mcp import (
18
+ HttpTransport, StdioTransport, McpTransport,
19
+ ToolInvokeRequest, ToolInvokeResponse,
20
+ RetrieveResourceRequest, RetrieveResourceResponse,
21
+ GenerationRequest,
22
+ )
@@ -0,0 +1,304 @@
1
+ from typing import List, Optional, Literal, Union
2
+
3
+ from pydantic import BaseModel, Field, ConfigDict
4
+ from pydantic.alias_generators import to_camel
5
+ from typing_extensions import TypedDict
6
+
7
+ from persona_models.common import create_uuid
8
+
9
+ SynthesizerType = Literal["gcloud", "elevenlabs", "gtts", "openai"]
10
+
11
+ LanguageCode = Literal["en-US", "it-IT", "es-ES", "fr-FR", "de-DE", "pt-BR"]
12
+
13
+
14
+ class SynthesizerConfiguration(BaseModel):
15
+ enabled: Optional[bool] = True
16
+ synthesizer_name: SynthesizerType = "gcloud"
17
+ language_code: Optional[LanguageCode] = None
18
+ voice: Optional[str] = None
19
+ sample_rate_hertz: Optional[int] = 24000
20
+ speed: Optional[float] = None
21
+ similarity_boost: Optional[float] = None
22
+ stability: Optional[float] = None
23
+ style: Optional[float] = None
24
+ voice_instructions: Optional[str] = None
25
+
26
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
27
+
28
+
29
+ TranscriberType = Literal["gcloud", "deepgram"]
30
+
31
+
32
+ class TranscriberConfiguration(BaseModel):
33
+ enabled: Optional[bool] = True
34
+ transcriber_name: TranscriberType = "gcloud"
35
+ language_code: Optional[LanguageCode] = None
36
+ sample_rate_hertz: Optional[int] = None
37
+
38
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
39
+
40
+
41
+ ModelName = Literal[
42
+ # Google
43
+ "gemini-3-pro",
44
+ "gemini-2.5-pro",
45
+ "gemini-2.5-flash",
46
+ "gemini-2.5-flash-lite",
47
+ "gemini-2.0-flash",
48
+ "gemini-1.5-pro",
49
+ "gemini-1.5-flash",
50
+ "gemini-2.0-flash-001",
51
+ "gemini-2.0-flash-lite",
52
+ "gemini-2.0-flash-lite-001",
53
+ "gemini-1.5-flash-latest",
54
+ "gemini-1.5-flash-001",
55
+ "gemini-1.5-flash-002",
56
+ "gemini-1.5-pro-latest",
57
+ "gemini-1.5-pro-001",
58
+ "gemini-1.5-pro-002",
59
+ # OpenAI
60
+ "gpt-5.2",
61
+ "gpt-5",
62
+ "gpt-5-mini",
63
+ "gpt-5-nano",
64
+ "gpt-4.1",
65
+ "gpt-4.1-mini",
66
+ "gpt-4.1-nano",
67
+ "gpt-4o",
68
+ "gpt-4o-mini",
69
+ "gpt-4.5",
70
+ "o1",
71
+ "o1-mini",
72
+ "o3-mini",
73
+ "o4-mini",
74
+ "o4-mini-high",
75
+ "gpt-3.5-turbo",
76
+ "gpt-3.5-turbo-16k",
77
+ # Fireworks
78
+ "accounts/fireworks/models/minimax-m2p5",
79
+ "accounts/fireworks/models/deepseek-v3p2",
80
+ "accounts/fireworks/models/kimi-k2p5",
81
+ "accounts/fireworks/models/glm-5",
82
+ # Grok
83
+ "grok-4-1-fast-reasoning",
84
+ "grok-4-1-fast-non-reasoning",
85
+ "grok-code-fast-1",
86
+ "grok-4-fast-reasoning",
87
+ "grok-4-fast-non-reasoning",
88
+ "grok-4-0709",
89
+ "grok-3-mini",
90
+ "grok-3",
91
+ "grok-2-vision-1212",
92
+ # Ollama
93
+ "ollama",
94
+ ]
95
+
96
+
97
+ class ModelConfiguration(BaseModel):
98
+ model_name: ModelName
99
+ temperature: float = 1
100
+ reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] = None
101
+ url: Optional[str] = None
102
+ ollama_model_name: Optional[str] = None
103
+
104
+ model_config = ConfigDict(
105
+ alias_generator=to_camel, populate_by_name=True, use_enum_values=True
106
+ )
107
+
108
+
109
+ ToolType = Literal["remote", "local"]
110
+
111
+
112
+ class ToolRemoteConfig(BaseModel):
113
+ service_url: str
114
+ secret: Optional[str] = None
115
+ timeout: Optional[int] = 60
116
+
117
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
118
+
119
+
120
+ class ToolProperty(TypedDict):
121
+ type: str
122
+ description: str
123
+
124
+
125
+ class ToolParameters(TypedDict):
126
+ type: str
127
+ title: str
128
+ required: Optional[List[str]]
129
+ properties: Optional[dict[str, ToolProperty]]
130
+
131
+
132
+ class ToolOutput(TypedDict):
133
+ type: str
134
+ title: str
135
+ properties: Optional[dict[str, ToolProperty]]
136
+
137
+
138
+ class ToolLocalConfig(BaseModel):
139
+ parameters: ToolParameters
140
+ output: ToolOutput
141
+
142
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
143
+
144
+
145
+ class Tool(BaseModel):
146
+ type: ToolType = "remote"
147
+ name: str
148
+ description: Optional[str] = None
149
+ config: Union[ToolRemoteConfig, ToolLocalConfig]
150
+
151
+ def is_remote(self) -> bool:
152
+ return self.type == "remote"
153
+
154
+ def is_local(self) -> bool:
155
+ return self.type == "local"
156
+
157
+ model_config = ConfigDict(
158
+ alias_generator=to_camel, populate_by_name=True, use_enum_values=True
159
+ )
160
+
161
+
162
+ class ToolkitConfiguration(BaseModel):
163
+ tools: List[Tool] | None = None
164
+
165
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
166
+
167
+
168
+ KnowledgeType = Literal["multi_hop", "simple"]
169
+
170
+
171
+ class MultiHopKnowledgeConfiguration(BaseModel):
172
+ model: ModelConfiguration
173
+ max_steps: int
174
+
175
+
176
+ class KnowledgeConfiguration(BaseModel):
177
+ enabled: Optional[bool] = True
178
+ knowledge_type: KnowledgeType = "multi_hop"
179
+ namespace: str | list[str] | None = None
180
+ number_of_entries: int = 3
181
+ knowledge_base_id: str | None = None
182
+ args: Union[MultiHopKnowledgeConfiguration, dict] = Field(
183
+ default_factory=dict, alias="args"
184
+ )
185
+
186
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
187
+
188
+
189
+ class TwilioConfiguration(BaseModel):
190
+ phone_number: str
191
+
192
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
193
+
194
+
195
+ class WakeupConfiguration(BaseModel):
196
+ enabled: Optional[bool] = False
197
+ wakeup_words: List[str] = None
198
+ sleep_words: Optional[List[str]] = None
199
+ sleep_in_each_request: bool = False
200
+ sleep_delay_seconds: Optional[int] = None
201
+
202
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
203
+
204
+
205
+ class TelegramConfiguration(BaseModel):
206
+ enabled: Optional[bool] = False
207
+ bot_token: str
208
+ enabled_users: List[str] | None = None
209
+
210
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
211
+
212
+
213
+ class WhatsAppConfiguration(BaseModel):
214
+ phone_number_id: str
215
+ enabled_users: List[str] | None = None
216
+
217
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
218
+
219
+
220
+ class Variable(BaseModel):
221
+ name: str
222
+ value: str | None = None
223
+ description: str | None = None
224
+
225
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
226
+
227
+
228
+ class Collaborator(BaseModel):
229
+ agent_id: str
230
+ scope: str
231
+
232
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
233
+
234
+
235
+ CollaborationModeType = Literal[
236
+ "persistent_transfer", "delegate_and_return", "consult_then_respond"
237
+ ]
238
+
239
+
240
+ class CollaborationConfiguration(BaseModel):
241
+ enabled: Optional[bool] = False
242
+ collaborators: List[Collaborator]
243
+ mode: CollaborationModeType = "delegate_and_return"
244
+ max_number_of_iterations: int = 10
245
+
246
+ model_config = ConfigDict(
247
+ alias_generator=to_camel, populate_by_name=True, use_enum_values=True
248
+ )
249
+
250
+
251
+ AgentType = Literal["agent"]
252
+
253
+ AgentProtocol = Literal["webrtc", "twilio", "rest", "websocket", "telegram"]
254
+
255
+ StmType = Literal["simple", "summary"]
256
+
257
+
258
+ class NetworkConfiguration(BaseModel):
259
+ allowed_websites: Optional[List[str]] = None
260
+ allowed_ips: Optional[List[str]] = None
261
+
262
+
263
+ class StmConfiguration(BaseModel):
264
+ type: StmType
265
+ max_messages: int = 10
266
+ model: ModelConfiguration | None = None
267
+ max_number_of_words: int = 50
268
+ include_tool_calls: bool = False
269
+
270
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
271
+
272
+
273
+ class AgentConfiguration(BaseModel):
274
+ id: str = Field(default_factory=create_uuid)
275
+ project_id: str | None = None
276
+ api_key: str | None = None
277
+ code: str | None = None
278
+ name: str
279
+ description: Optional[str] = None
280
+ type: AgentType = "agent"
281
+ synthesizer: Optional[SynthesizerConfiguration] = None
282
+ transcriber: Optional[TranscriberConfiguration] = None
283
+ model: ModelConfiguration
284
+ system_instructions: Optional[str] = None
285
+ toolkit: Optional[ToolkitConfiguration] = None
286
+ variables: Optional[List[Variable]] = None
287
+ enabled_protocols: List[AgentProtocol] | None = None
288
+ twilio: Optional[TwilioConfiguration] = None
289
+ language_code: Optional[LanguageCode] = None
290
+ initial_message: Optional[str] = None
291
+ knowledge: Optional[KnowledgeConfiguration] = None
292
+ wakeup: Optional[WakeupConfiguration] = None
293
+ telegram: Optional[TelegramConfiguration] = None
294
+ whatsapp: Optional[WhatsAppConfiguration] = None
295
+ collaboration: Optional[CollaborationConfiguration] = None
296
+ network: Optional[NetworkConfiguration] = None
297
+ features: Optional[list] = None
298
+ response_schema: Optional[dict] = None
299
+ short_term_memory: Optional[StmConfiguration] = None
300
+ verbose_errors: bool = False
301
+
302
+ model_config = ConfigDict(
303
+ alias_generator=to_camel, populate_by_name=True, use_enum_values=True
304
+ )
@@ -0,0 +1,31 @@
1
+ import uuid
2
+ from typing import Generic, TypeVar
3
+
4
+ from pydantic import BaseModel, ConfigDict
5
+ from pydantic.alias_generators import to_camel
6
+
7
+ TEntity = TypeVar("TEntity", bound=BaseModel)
8
+
9
+
10
+ def create_uuid(prefix: str = None) -> str:
11
+ if prefix:
12
+ return f"{prefix}_{uuid.uuid4().hex}"
13
+ else:
14
+ return uuid.uuid4().hex
15
+
16
+
17
+ def create_shortuuid(prefix: str = None) -> str:
18
+ short = uuid.uuid4().hex[:22]
19
+ if prefix:
20
+ return f"{prefix}_{short}"
21
+ else:
22
+ return short
23
+
24
+
25
+ class Paginated(BaseModel, Generic[TEntity]):
26
+ items: list[TEntity]
27
+ total: int
28
+ page: int
29
+ size: int
30
+
31
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
@@ -0,0 +1,51 @@
1
+ from datetime import datetime
2
+ from typing import Optional
3
+
4
+ from pydantic import BaseModel, Field, ConfigDict
5
+ from pydantic.alias_generators import to_camel
6
+
7
+ from persona_models.common import create_uuid
8
+
9
+
10
+ class AuthorizeRequest(BaseModel):
11
+ name: str
12
+ client_id: Optional[str] = None
13
+ client_secret: Optional[str] = None
14
+ scope: Optional[str] = None
15
+ api_key: Optional[str] = None
16
+ api_secret: Optional[str] = None
17
+ token: Optional[str] = None
18
+ server: Optional[str] = None
19
+ port: Optional[int] = None
20
+ username: Optional[str] = None
21
+ password: Optional[str] = None
22
+ use_ssl: Optional[bool] = None
23
+ success_url: Optional[str] = None
24
+
25
+ model_config = ConfigDict(
26
+ populate_by_name=True, alias_generator=to_camel, extra="allow"
27
+ )
28
+
29
+
30
+ class Credentials(BaseModel):
31
+ id: str = Field(default_factory=create_uuid)
32
+ name: str | None = None
33
+ project_id: str | None = None
34
+ provider: str
35
+ obtained_at: datetime | None = None
36
+ valid_until: datetime | None = None
37
+ data: dict = Field(default_factory=dict)
38
+ client_id: Optional[str] = None
39
+ client_secret: Optional[str] = None
40
+ api_key: Optional[str] = None
41
+ api_secret: Optional[str] = None
42
+ token: Optional[str] = None
43
+ active: bool = True
44
+ server: Optional[str] = None
45
+ port: Optional[int] = None
46
+ username: Optional[str] = None
47
+ password: Optional[str] = None
48
+ use_ssl: Optional[bool] = None
49
+ success_url: Optional[str] = None
50
+
51
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
@@ -0,0 +1,53 @@
1
+ from typing import Literal, List, Union, Optional
2
+
3
+ from pydantic import BaseModel, ConfigDict, Field
4
+ from pydantic.alias_generators import to_camel
5
+
6
+ from persona_models.common import create_uuid
7
+ from persona_models.mcp import HttpTransport, StdioTransport
8
+
9
+
10
+ class McpServerConfiguration(BaseModel):
11
+ name: str
12
+ transport: Union[HttpTransport, StdioTransport]
13
+ enabled_tools: List[str] | None = None
14
+ disabled_tools: List[str] | None = None
15
+
16
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
17
+
18
+
19
+ class FlagConfiguration(BaseModel):
20
+ flag: str
21
+
22
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
23
+
24
+
25
+ FeatureType = Literal["mcp", "flag"]
26
+ FeatureConfiguration = Union[McpServerConfiguration, FlagConfiguration]
27
+
28
+
29
+ class FeatureCredentialsConfiguration(BaseModel):
30
+ require_credentials: bool = False
31
+ credentials_type: str | None = None
32
+
33
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
34
+
35
+
36
+ class FeatureTemplate(BaseModel):
37
+ id: str = Field(default_factory=create_uuid, validate_default=False)
38
+ project_id: str | None = None
39
+ type: FeatureType
40
+ name: str
41
+ description: str
42
+ configuration: Optional[FeatureConfiguration] = None
43
+ credentials_configuration: Optional[FeatureCredentialsConfiguration] = None
44
+
45
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
46
+
47
+
48
+ class Feature(BaseModel):
49
+ id: str = Field(default_factory=create_uuid)
50
+ template_id: str | None = None
51
+ credentials_id: str | None = None
52
+
53
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
@@ -0,0 +1,48 @@
1
+ from typing import Literal, Optional
2
+
3
+ from pydantic import BaseModel, Field, ConfigDict
4
+ from pydantic.alias_generators import to_camel
5
+
6
+ from persona_models.common import create_uuid
7
+
8
+ KnowledgeBaseQuality = Literal["extremely_high", "very_high", "high", "medium", "low"]
9
+ KnowledgeBaseDocumentStatus = Literal["pending", "processing", "completed", "failed"]
10
+ KnowledgeBaseChunkSize = Literal["small", "medium", "large"]
11
+
12
+
13
+ class KnowledgeBase(BaseModel):
14
+ id: str = Field(default_factory=create_uuid)
15
+ project_id: str | None = None
16
+ name: str
17
+ description: str | None = None
18
+ quality: KnowledgeBaseQuality = "medium"
19
+ chunk_size: KnowledgeBaseChunkSize = "medium"
20
+ embedding_model: str = "text-multilingual-embedding-002"
21
+
22
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
23
+
24
+
25
+ class KnowledgeBaseDocument(BaseModel):
26
+ id: str = Field(default_factory=create_uuid)
27
+ knowledge_base_id: str
28
+ path: str
29
+ name: str
30
+ size: int | None = None
31
+ total_pages: int | None = None
32
+ content_type: str | None = None
33
+ status: KnowledgeBaseDocumentStatus = "pending"
34
+ progress: float = 0.0
35
+ extractor: str = "fitz"
36
+ error: str | None = None
37
+ metadata: dict = Field(default_factory=dict)
38
+ callback_url: str | None = None
39
+
40
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
41
+
42
+
43
+ class SearchChunksRequest(BaseModel):
44
+ query: str
45
+ top_k: int = 5
46
+ threshold: Optional[float] = None
47
+
48
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
@@ -0,0 +1,69 @@
1
+ from typing import Union, Optional, List
2
+
3
+ from pydantic import BaseModel, ConfigDict
4
+ from pydantic.alias_generators import to_camel
5
+
6
+
7
+ class HttpTransport(BaseModel):
8
+ url: str
9
+ enable_persona_auth: bool = True
10
+
11
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
12
+
13
+
14
+ class StdioTransport(BaseModel):
15
+ command: str
16
+ args: list[str]
17
+ env: Optional[dict[str, str]] = None
18
+ cwd: Optional[str] = None
19
+
20
+
21
+ McpTransport = Union[HttpTransport, StdioTransport]
22
+
23
+
24
+ class ToolInvokeRequest(BaseModel):
25
+ mcp_server_name: str
26
+ transport: McpTransport
27
+ tool_name: str
28
+ args: dict
29
+ session_id: str
30
+ credentials_id: str | None = None
31
+ user_id: str | None = None
32
+ billing_disabled: bool = False
33
+
34
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
35
+
36
+
37
+ class ToolInvokeResponse(BaseModel):
38
+ results: list = []
39
+
40
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
41
+
42
+
43
+ class RetrieveResourceRequest(BaseModel):
44
+ mcp_server_name: str
45
+ transport: McpTransport
46
+ uri: str
47
+ session_id: str
48
+ credentials_id: str | None = None
49
+ user_id: str | None = None
50
+ billing_disabled: bool = False
51
+
52
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
53
+
54
+
55
+ class RetrieveResourceResponse(BaseModel):
56
+ contents: list = []
57
+
58
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
59
+
60
+
61
+ class GenerationRequest(BaseModel):
62
+ agent_id: str | None = None
63
+ user_message: str | dict | list = ""
64
+ initial_context: dict | None = None
65
+ response_schema: dict | None = None
66
+ parent_session_id: str | None = None
67
+ user_id: str | None = None
68
+
69
+ model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
@@ -0,0 +1,84 @@
1
+ from datetime import datetime
2
+ from typing import Any, Dict, List, Literal, Optional
3
+
4
+ from pydantic import BaseModel, ConfigDict, Field
5
+ from pydantic.alias_generators import to_camel
6
+
7
+ from persona_models.common import create_uuid
8
+
9
+ MissionStatus = Literal[
10
+ "draft", "planned", "active", "review", "paused", "completed", "failed", "cancelled"
11
+ ]
12
+ MissionStepStatus = Literal["pending", "in_progress", "completed", "failed", "skipped"]
13
+
14
+
15
+ class WorkerAgent(BaseModel):
16
+ agent_id: str
17
+ scope: str
18
+ name: Optional[str] = None
19
+
20
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
21
+
22
+
23
+ class MissionStep(BaseModel):
24
+ id: str = Field(default_factory=create_uuid)
25
+ name: str
26
+ description: str | None = None
27
+ status: MissionStepStatus = "pending"
28
+ worker_agent_id: str | None = None
29
+ parent_step_id: str | None = None
30
+ dependencies: List[str] = Field(default_factory=list)
31
+ output: str | None = None
32
+ error: str | None = None
33
+ metadata: Dict[str, Any] = Field(default_factory=dict)
34
+ created_at: datetime = Field(default_factory=datetime.now)
35
+ updated_at: datetime = Field(default_factory=datetime.now)
36
+ started_at: datetime | None = None
37
+ completed_at: datetime | None = None
38
+
39
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
40
+
41
+
42
+ class Mission(BaseModel):
43
+ id: str = Field(default_factory=create_uuid)
44
+ project_id: str
45
+ name: str
46
+ goal: str
47
+ status: MissionStatus = "draft"
48
+ planner_agent_id: str
49
+ worker_agents: List[WorkerAgent] = Field(default_factory=list)
50
+ steps: List[MissionStep] = Field(default_factory=list)
51
+ current_step_id: str | None = None
52
+ version: int = 1
53
+ user_instructions: List[str] = Field(default_factory=list)
54
+ created_at: datetime = Field(default_factory=datetime.now)
55
+ updated_at: datetime = Field(default_factory=datetime.now)
56
+
57
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
58
+
59
+ def get_step(self, step_id: str) -> Optional[MissionStep]:
60
+ for step in self.steps:
61
+ if step.id == step_id or step.name == step_id:
62
+ return step
63
+ return None
64
+
65
+ def get_root_steps(self) -> List[MissionStep]:
66
+ return [s for s in self.steps if s.parent_step_id is None]
67
+
68
+ def get_ready_steps(self) -> List[MissionStep]:
69
+ completed_ids = {s.id for s in self.steps if s.status == "completed"}
70
+ return [
71
+ s
72
+ for s in self.steps
73
+ if s.status == "pending"
74
+ and all(dep in completed_ids for dep in s.dependencies)
75
+ ]
76
+
77
+
78
+ class CreateMissionRequest(BaseModel):
79
+ name: str
80
+ goal: str
81
+ planner_agent_id: str
82
+ worker_agents: List[WorkerAgent] = Field(default_factory=list)
83
+
84
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)