Documentation / @agentick/sandbox / applyEdits
Function: applyEdits() ​
applyEdits(
source,edits):EditResult
Defined in: edit.ts:615
Apply edits to a source string. Pure function, no I/O.
Mode detection (by field presence, precedence: range > insert > delete > replace):
- Range:
from+to+content— replace block between markers (inclusive) - Insert before/after:
old+insert+content— insert relative to anchor - Insert start/end:
insert+content— prepend/append to file - Delete:
old+delete: true— remove matched text - Replace:
old+new— find and replace
Matching strategy per anchor (in order):
- Exact byte match
- Line-normalized (trailing whitespace stripped)
- Indent-adjusted (leading whitespace baseline stripped, new indentation adjusted)
Multi-edit: all matches resolved against original source, validated for overlap, applied bottom-to-top.
Parameters ​
source ​
string
edits ​
Edit[]
Returns ​
Throws ​
EditError on match failure, validation error, or overlapping edits