Skip to content

Commit 0c2ac58

Browse files
abrichrclaude
andauthored
feat: add universal action parser for DSL, JSON, and BenchmarkAction formats (#4)
Adds openadapt_types.parsing module with five public functions: - parse_action(): auto-detect format (DSL or JSON) and parse - parse_action_dsl(): parse DSL strings like CLICK(x=0.5, y=0.3) - parse_action_json(): parse JSON with canonical, flat, and coordinate formats - from_benchmark_action(): convert BenchmarkAction-style dicts to Action - to_benchmark_action_dict(): convert Action back to BenchmarkAction dict Handles Thought:/Action: prefixes, markdown fences, coordinate normalization detection, clamping, and legacy field mapping. All edge cases return Action(type=DONE) with a logged warning instead of raising. Includes 66 tests covering DSL, JSON, auto-detect, and BenchmarkAction round-trip conversion. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d5b3f3f commit 0c2ac58

File tree

3 files changed

+1011
-0
lines changed

3 files changed

+1011
-0
lines changed

openadapt_types/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
)
3636
from openadapt_types.episode import Episode, Step
3737
from openadapt_types.failure import FailureCategory, FailureRecord
38+
from openadapt_types.parsing import (
39+
from_benchmark_action,
40+
parse_action,
41+
parse_action_dsl,
42+
parse_action_json,
43+
to_benchmark_action_dict,
44+
)
3845

3946
__version__ = "0.1.0"
4047

@@ -56,4 +63,10 @@
5663
# failure
5764
"FailureCategory",
5865
"FailureRecord",
66+
# parsing
67+
"from_benchmark_action",
68+
"parse_action",
69+
"parse_action_dsl",
70+
"parse_action_json",
71+
"to_benchmark_action_dict",
5972
]

0 commit comments

Comments
 (0)