feat(tool): add interactive terminal tool with persistent PTY sessions#23760
Closed
herjarsa wants to merge 1 commit intoanomalyco:devfrom
Closed
feat(tool): add interactive terminal tool with persistent PTY sessions#23760herjarsa wants to merge 1 commit intoanomalyco:devfrom
herjarsa wants to merge 1 commit intoanomalyco:devfrom
Conversation
Introduces a new terminal tool with action-based session management: - run (default): backward-compatible one-shot execution - create: start persistent PTY session, returns sessionId - send: write input to existing session (commands, control sequences) - read: cursor-based incremental output reading - close: terminate session and cleanup resources Sessions stored via InstanceState for per-directory isolation with FIFO eviction at max 20 sessions. Fixes PowerShell exit code by using \ instead of \True on Windows. Closes anomalyco#23759
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #23759
Adds a fully interactive terminal tool that lets the agent manage persistent PTY sessions - create, send input, read output (with cursor-based incremental reads), and close sessions. This makes the terminal a true extension of the agent rather than a one-shot command runner.
What's included
run,create,send,read,closeexitCode(via sentinel command on Windows), discriminated union Zod schemaPty.Servicereadaction returns only new output since last readFiles changed
src/tool/terminal.tssrc/tool/terminal.txtsrc/tool/txt.d.tssrc/tool/registry.tstest/tool/terminal.test.tspackage.json@babel/typesdevDep (Windows Bun workaround)Testing
runaction tests - bus event propagation limitation in test context)Design decisions
Pty.onExit: Windows PowerShell does not reliably emit exit events, so we inject a sentinel command that writesEXIT_CODE:<N>to stdout and parse it