-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex_schema.py
More file actions
111 lines (82 loc) · 2.16 KB
/
index_schema.py
File metadata and controls
111 lines (82 loc) · 2.16 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"""
Type definitions for trace index schema using concrete classes.
"""
from dataclasses import dataclass, field, asdict
from typing import Optional, List, Literal
@dataclass
class TraceFileInfo:
"""Metadata about the trace file."""
path: str
size_bytes: int
sha256: str
def to_dict(self) -> dict:
return asdict(self)
@dataclass
class TraceSummary:
"""High-level summary of the trace."""
first_ts: str
last_ts: str
event_count: int
step_count: int
error_count: int
final_url: Optional[str]
def to_dict(self) -> dict:
return asdict(self)
@dataclass
class SnapshotInfo:
"""Snapshot metadata for index."""
snapshot_id: Optional[str] = None
digest: Optional[str] = None
url: Optional[str] = None
def to_dict(self) -> dict:
return asdict(self)
@dataclass
class ActionInfo:
"""Action metadata for index."""
type: Optional[str] = None
target_element_id: Optional[int] = None
args_digest: Optional[str] = None
success: Optional[bool] = None
def to_dict(self) -> dict:
return asdict(self)
@dataclass
class StepCounters:
"""Event counters per step."""
events: int = 0
snapshots: int = 0
actions: int = 0
llm_calls: int = 0
def to_dict(self) -> dict:
return asdict(self)
@dataclass
class StepIndex:
"""Index entry for a single step."""
step_index: int
step_id: str
goal: Optional[str]
status: Literal["ok", "error", "partial"]
ts_start: str
ts_end: str
offset_start: int
offset_end: int
url_before: Optional[str]
url_after: Optional[str]
snapshot_before: SnapshotInfo
snapshot_after: SnapshotInfo
action: ActionInfo
counters: StepCounters
def to_dict(self) -> dict:
result = asdict(self)
return result
@dataclass
class TraceIndex:
"""Complete trace index schema."""
version: int
run_id: str
created_at: str
trace_file: TraceFileInfo
summary: TraceSummary
steps: List[StepIndex] = field(default_factory=list)
def to_dict(self) -> dict:
"""Convert to dictionary for JSON serialization."""
return asdict(self)