Skip to main content

Module state_parsing

Module state_parsing 

Source
Expand description

Stream-message state parsers: rate-limit / api-retry / runtime-session / settings-parse-error. Mirrors upstreamโ€™s agent-sdk/src/bridge/state_parsing.ts.

Re-exportsยง

use serde_json::Map; ๐Ÿ”’
use serde_json::Value; ๐Ÿ”’
use forge_primitives::ApiRetryError; ๐Ÿ”’
use forge_primitives::RateLimitStatus; ๐Ÿ”’
use forge_primitives::RuntimeSessionState; ๐Ÿ”’
use forge_primitives::SettingsParseErrorUpdate; ๐Ÿ”’

Functionsยง

build_api_retry_update
Mirrors upstreamโ€™s buildApiRetryUpdate(message). Returns a typed ApiRetryUpdate when all three required numeric fields parse correctly.
build_rate_limit_update
Mirrors upstreamโ€™s buildRateLimitUpdate(rateLimitInfo). Returns a typed RateLimitUpdate when the input has a recognised status, populating optional fields when present.
normalize_settings_parse_error ๐Ÿ”’
Mirrors normalizeSettingsParseError(value).
normalize_settings_parse_errors
Accepts either a single record or an array; returns all valid entries.
number_field ๐Ÿ”’
parse_api_retry_error ๐Ÿ”’
parse_clamped_u64 ๐Ÿ”’
Reads a numeric field as u64, returning None when the field is missing or its value is outside [0, u64::MAX) (note the open upper bound - see the body comment). Out-of-range drops emit a debug breadcrumb so a misbehaving CLI is observable.
parse_clamped_u16_optional ๐Ÿ”’
Optional sibling of parse_clamped_u64 for u16-sized fields (status codes). Field-absent is silent (None); out-of-range value logs at debug and returns None.
parse_enum ๐Ÿ”’
Deserialize a wire-string enum variant from an optional JSON value. Returns None for missing field, wrong JSON type, or unrecognised variant - the three failure modes share a single drop path. Each enum carries #[serde(rename_all = "snake_case")] so this is just the typed wrapper.
parse_rate_limit_status ๐Ÿ”’
parse_runtime_session_state
record ๐Ÿ”’