Skip to main content

apply_meta_update

Function apply_meta_update 

Source
pub fn apply_meta_update(
    stored: &mut MaybeUndefined<Map<String, Value>>,
    update: MaybeUndefined<Map<String, Value>>,
)
Available on crate feature unstable_protocol_v2 only.
Expand description

Applies the top-level _meta patch of an upsert update to stored metadata.

An omitted update leaves stored unchanged, and null clears it. An object patches stored one top-level key at a time: keys it omits keep their stored values, a key set to null is removed, and any other value replaces that key’s stored value whole. Nested objects are not merged, and a null nested inside a value is kept as data. Removing every key leaves an empty object, which means the same as no metadata.

Use this for the top-level _meta of upsert updates such as ToolCallUpdate, TerminalUpdate, message updates, SessionInfoUpdate, and CompactionUpdate. Other _meta fields are not patches.

See protocol docs: Metadata Patches