Spaces:
Sleeping
Sleeping
Create src/macg/protocol.py
Browse files- src/macg/protocol.py +27 -0
src/macg/protocol.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
from dataclasses import dataclass, field
|
| 3 |
+
from typing import Any, Literal, Optional
|
| 4 |
+
import time
|
| 5 |
+
import uuid
|
| 6 |
+
|
| 7 |
+
Role = Literal["user", "orchestrator", "coder", "reviewer", "tester", "tool"]
|
| 8 |
+
|
| 9 |
+
@dataclass
|
| 10 |
+
class Message:
|
| 11 |
+
role: Role
|
| 12 |
+
content: str
|
| 13 |
+
meta: dict[str, Any] = field(default_factory=dict)
|
| 14 |
+
ts: float = field(default_factory=lambda: time.time())
|
| 15 |
+
id: str = field(default_factory=lambda: uuid.uuid4().hex)
|
| 16 |
+
|
| 17 |
+
@dataclass
|
| 18 |
+
class Artifact:
|
| 19 |
+
"""A shared bundle agents pass around: code, tests, notes, scores, etc."""
|
| 20 |
+
task: str
|
| 21 |
+
module_name: str = "solution"
|
| 22 |
+
code: str = ""
|
| 23 |
+
tests: str = ""
|
| 24 |
+
review_notes: str = ""
|
| 25 |
+
test_report: str = ""
|
| 26 |
+
passed: bool = False
|
| 27 |
+
iteration: int = 0
|