Commit 0c2ac58
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- openadapt_types
- tests
3 files changed
+1011
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
59 | 72 | | |
0 commit comments