feat(interactive-bash): block tmux output capture commands
Block capture-pane, save-buffer, show-buffer, pipe-pane and their aliases in interactive_bash tool. Guide users to use bash tool instead for terminal output capture operations. - Add BLOCKED_TMUX_SUBCOMMANDS list in constants.ts - Add input validation in tools.ts to reject blocked commands - Update tool description with blocked commands documentation 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
export const DEFAULT_TIMEOUT_MS = 60_000
|
||||
|
||||
export const BLOCKED_TMUX_SUBCOMMANDS = [
|
||||
"capture-pane",
|
||||
"capturep",
|
||||
"save-buffer",
|
||||
"saveb",
|
||||
"show-buffer",
|
||||
"showb",
|
||||
"pipe-pane",
|
||||
"pipep",
|
||||
]
|
||||
|
||||
export const INTERACTIVE_BASH_DESCRIPTION = `Execute tmux commands for interactive terminal session management.
|
||||
|
||||
Use session names following the pattern "omo-{name}" for automatic tracking.`
|
||||
Use session names following the pattern "omo-{name}" for automatic tracking.
|
||||
|
||||
BLOCKED COMMANDS (use bash tool instead):
|
||||
- capture-pane / capturep: Use bash to read output files or pipe output
|
||||
- save-buffer / saveb: Use bash to save content to files
|
||||
- show-buffer / showb: Use bash to read buffer content
|
||||
- pipe-pane / pipep: Use bash for piping output`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@opencode-ai/plugin/tool"
|
||||
import { DEFAULT_TIMEOUT_MS, INTERACTIVE_BASH_DESCRIPTION } from "./constants"
|
||||
import { BLOCKED_TMUX_SUBCOMMANDS, DEFAULT_TIMEOUT_MS, INTERACTIVE_BASH_DESCRIPTION } from "./constants"
|
||||
import { getCachedTmuxPath } from "./utils"
|
||||
|
||||
/**
|
||||
@@ -62,6 +62,11 @@ export const interactive_bash = tool({
|
||||
return "Error: Empty tmux command"
|
||||
}
|
||||
|
||||
const subcommand = parts[0].toLowerCase()
|
||||
if (BLOCKED_TMUX_SUBCOMMANDS.includes(subcommand)) {
|
||||
return `Error: '${parts[0]}' is blocked. Use bash tool instead for capturing/printing terminal output.`
|
||||
}
|
||||
|
||||
const proc = Bun.spawn([tmuxPath, ...parts], {
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
|
||||
Reference in New Issue
Block a user