Skip to content

feat(tools): add exec tool enhancement with background execution and PTY support#1869

Merged
yinwm merged 1 commit intosipeed:mainfrom
liuy:feat/exec-tool-enhancement
Mar 25, 2026
Merged

feat(tools): add exec tool enhancement with background execution and PTY support#1869
yinwm merged 1 commit intosipeed:mainfrom
liuy:feat/exec-tool-enhancement

Conversation

@liuy
Copy link
Contributor

@liuy liuy commented Mar 21, 2026

Re-submit of #1752 (was reverted by #1865)

Fixes

Issue Cause Fix
loong64 build failure creack/pty@v1.1.9 missing ztypes_loong64.go, causing undefined: _C_int Added PTY_PATCH_LOONG64 in Makefile to dynamically create type definitions
Windows build failure syscall.SysProcAttr.Setsid doesn't exist on Windows Added sysproc_unix.go / sysproc_windows.go with build tags
Tool schema compatibility Schema format incompatible with some models (e.g., GLM-5) Fixed tool schema definition for broader model support

New Files

File Description
pkg/tools/sysproc_unix.go Unix Setsid setup (//go:build !windows)
pkg/tools/sysproc_windows.go Windows no-op (//go:build windows)

Modified Files

File Changes
Makefile Added loong64 patch, executed after arm64 build, before loong64 build
pkg/tools/shell.go Removed syscall import, call setSysProcAttrForPty()

Testing

  • make build-all - All platforms compile successfully (amd64, arm, arm64, loong64, riscv64, mipsle, darwin-arm64, windows-amd64, netbsd-amd64, netbsd-arm64)
  • go test ./pkg/tools/... - All tests pass
  • ✅ Tested with: GLM-4.7, GLM-5, Minimax M2.x

…PTY support (sipeed#1752)

- Unified exec tool with actions: run/list/poll/read/write/send-keys/kill
- PTY support using creack/pty library
- Process session management with background execution
- Process group kill for cleaning up child processes
- Session cleanup: 30-minute TTL for old sessions
- Output buffer: 100MB limit with truncation

Actions:
- run: execute command (sync or background)
- list: list all sessions
- poll: check session status
- read: read session output
- write: send input to session stdin
- send-keys: send special keys (up, down, ctrl-c, enter, etc.)
- kill: terminate session

Tests:
- PTY: allowed commands, write/read, poll, kill, process group kill
- Non-PTY: background execution, list, read, write, poll, kill, process group kill
- Session management: add/get/remove/list/cleanup
@liuy liuy force-pushed the feat/exec-tool-enhancement branch from c3fdaa2 to 3f1ac29 Compare March 25, 2026 13:04
Copy link
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The fixes for loong64 and Windows build issues look good. Comprehensive test coverage with +946 lines.

@yinwm yinwm merged commit 70c4714 into sipeed:main Mar 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: build domain: tool go Pull requests that update go code type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants