resolve shell from PATH (fallback /bin/sh); rewrite write tool with lineOffset/byteOffset + delLines/delBytes

This commit is contained in:
Luxferre
2026-10-14 10:58:08 +03:00
parent 34f1da34ca
commit 6e80a3e8fc
5 changed files with 132 additions and 56 deletions
+18 -10
View File
@@ -357,20 +357,28 @@ anything is sent back to the model.
### `write` tool
- Parameters: `filePath` (string, required; also accepts `path`); `offset`
(integer, optional, byte offset); `del_bytes` (integer, optional); `content`
(string, required, may be empty).
- Action: if `offset` and `del_bytes` are both omitted, the entire file is
overwritten with `content` (the file and any necessary parent directories
are created if missing); otherwise `content` is written at `offset`,
optionally deleting `del_bytes` bytes first (splicing prefix + content +
suffix and never appending to the end of an existing file). (Also accepted as
legacy `write_file`.)
- Parameters: `filePath` (string, required; also accepts `path`); `content`
(string, required, may be empty); `lineOffset` (integer, optional, 1-indexed
line number to start writing from — takes precedence over `byteOffset`);
`byteOffset` (integer, optional, byte offset — used only when `lineOffset` is
not given); `delLines` (integer, optional, number of lines to delete starting
at the insertion point — takes precedence over `delBytes`); `delBytes`
(integer, optional, number of bytes to delete — used only when `delLines` is
not given).
- Action: if none of `lineOffset`, `byteOffset`, `delLines` and `delBytes` are
provided, the entire file is overwritten with `content` (the file and any
necessary parent directories are created if missing). Otherwise `content` is
written at the resolved line/byte offset, optionally deleting `delLines`
lines or `delBytes` bytes first (splicing prefix + content + suffix). Line
numbers are 1-indexed and match the `read` tool's numbering; a `lineOffset`
past the end of the file appends at the end. (Also accepted as legacy
`write_file`; legacy `offset`/`del_bytes` are no longer emitted but the
`byteOffset`/`delBytes` byte-based mode covers the same behavior.)
### `bash` tool
- Parameters: `command` (string, required); `workdir` (string, optional).
- Action: run `command` via `bash -c` subject to `shell_timeout`
- Action: run `command` through the system shell (`bash` resolved from `PATH`, falling back to `/bin/sh` if bash is unavailable) via `-c`, subject to `shell_timeout`
(default `120s`) and return `output + '\nexit: ' + exit_code`. (Also
accepted as legacy `shell_exec`.)