Skip to content

fix(tools): correct bash/read failure semantics, clamp model timeouts, repair dependency declaration - #1

Open
javidrazack wants to merge 5 commits into
zz6zz666:mainfrom
javidrazack:contrib/A-bugfixes
Open

javidrazack wants to merge 5 commits into
zz6zz666:mainfrom
javidrazack:contrib/A-bugfixes

Conversation

@javidrazack

Copy link
Copy Markdown

Summary

Four fixes found while hardening this plugin for daily production use against Ubuntu 24.04 hosts. Each is small, test-backed, and independent of the others.

1. package.json — duplicate dependencies blocks dropped diff at runtime

The file declared "dependencies" twice; npm's last-wins resolution silently discarded diff@9, which the edit/write/patch tools import. Merged into a single block.

2. bash — remote exit code is now the sole failure signal

A hardcoded stderr phrase-list ("permission denied", "command not found", …) made the tool throw even when the command exited 0 whenever stderr merely contained those strings — constant false failures when grepping logs that mention them as content. Failure is now determined by exit code only; stdout/stderr pass through unchanged (byte-identical output, pinned by tests).

Legacy caveat documented: very old SSH servers that don't propagate exit codes would report failures as successes — noted in README for OpenSSH <5.x-era targets.

3. bash — model-supplied timeout values are now clamped

The tool trusted args.timeout verbatim. In real sessions models send seconds-scale or string values, producing failures like:

Remote Code: SSH exec timeout after 10ms

(Session storage from our runs showed three such calls with "timeout": "10"/"30"/"60".) Values are now clamped to [1_000, 600_000] ms — the ceiling keeps headroom for package upgrades. The separate negative-value throw is superseded by the clamp.

4. read — tolerate zero/negative offsets; harden line slicing

Models sometimes send offset=0; the tool assumed 1-indexed and crashed:

Error: undefined is not an object (evaluating 'line.length')

Offsets ≤0/NaN are treated as unspecified; slicing logic extracted into an exported pure sliceLines() helper covered by unit tests (byte-cap boundary, trailing-newline element, truncation markers).

Testing

  • New/extended suites: test/bash.test.mjs (14), test/read.test.mjs (12) — includes byte-exact output pins so future refactors can't silently change formats
  • npm run lint clean; full npm test green (54 tests across the complete stacked series)

Reviewer notes

  • This is the first of a small stacked series (permission-engine gating, fail-loud init, host-key verification to follow after discussion in separate issues)
  • Happy to mirror doc changes into README.zh-CN.md once overall direction is agreed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant