Skip to main content

parse_utils

AI Agent Parse Utilities for Consolidated Parameter Resolution. Provides O(1) utility functions for parameter parsing:
  • URL detection and parsing
  • Path detection
  • Typo suggestion (only on error path)
  • Error message generation
Performance: All happy-path operations are O(1). Typo suggestion uses Levenshtein distance only when raising errors.

Import

Functions

detect_url_scheme()

Detect URL scheme from a string. O(1) operation.

is_path_like()

Check if a string looks like a file path. O(1) operation.

suggest_similar()

Find the most similar string from candidates using Levenshtein distance.

make_preset_error()

Create a helpful error message for invalid preset.

canonical_preset_key()

The single spelling rule for preset names. Validation and resolution must

validate_preset_string()

Raise a helpful error when a string does not name a known preset.

is_policy_string()

Check if a string is a policy specification. O(1) operation.

parse_policy_string()

Parse a policy string into type and action. O(1) operation.

merge_config_with_overrides()

Merge a base config with override dict.