Skip to main content

Module compact

Module compact 

Source
Expand description

Output compaction, byte caps and redaction.

Structsยง

Cap
Message

Enumsยง

ToolsMode

Constantsยง

MARKER_RESERVE ๐Ÿ”’
Bytes reserved inside the budget for the truncated / original_bytes keys (and a wrapper for a non-object root).
MIN_SHORTEN_LEN ๐Ÿ”’
A string at or below this length is never shortened (the marker would not save bytes).
SHORTEN_SLACK ๐Ÿ”’
Extra bytes removed past the excess when shortening a string, so the ...[+N bytes] tail always nets a saving.

Functionsยง

cap_json
Cap value at cap.max_bytes (exempt arrays aside) and keep it valid JSON. A reduced result carries "truncated": true and "original_bytes": n.
children ๐Ÿ”’
Visit every child value that is not an exempt array.
compact_form_field
Keep the form-field keys the agent needs (packages/schema/src/form.ts:53-119).
compact_message
compact_permission
cut_array_tail ๐Ÿ”’
cut_object_tail ๐Ÿ”’
depth_cap
Replace every container nested deeper than max_depth (the root is depth 0) with "<depth>".
for_first_mut ๐Ÿ”’
largest ๐Ÿ”’
pick ๐Ÿ”’
redact
Redact secret-bearing keys and strip URL userinfo from every string.
redact_text
Remove user[:pass]@ from every scheme://user:pass@host in s.
reduce_exempt ๐Ÿ”’
Reduce every exempt array found under v; returns whether anything changed.
scalar_len ๐Ÿ”’
scalar_or_full_len ๐Ÿ”’
sensitive_key ๐Ÿ”’
shorten_string ๐Ÿ”’
shrink ๐Ÿ”’
Reduce v until size(v, skip) <= budget: arrays cut at element boundaries, then the longest strings shortened, then (last resort, so the bound always holds) object entries dropped.
size ๐Ÿ”’
Serialised length of v, counting an array under an exempt key as [].
str_of ๐Ÿ”’
unwrap_envelope
Split a CLI envelope into (data, cursor, meta); a _tag envelope is a CLI_ERROR.