import { tool } from "@opencode-ai/plugin"; import { closeMultiModel } from "../core/close"; /** * OpenCode tool definition for closing multi-model tmux sessions. * * Kills the tmux session and optionally removes git worktrees, * creates archive tags, and deletes associated branches. */ export const closeTool = tool({ description: "Close a multi-model tmux session and optionally cleanup worktrees and branches", args: { sessionName: tool.schema.string().min(1).describe("tmux session name to close"), cleanupWorktrees: tool.schema.boolean().default(true).describe("whether to remove worktrees and delete branches (default: true)"), createArchiveTags: tool.schema.boolean().default(true).describe("whether to create archive tags before deleting branches (default: true)"), }, async execute(args, context) { // In plugin mode, we skip confirmation (force=true) since there's no interactive terminal const result = await closeMultiModel({ sessionName: args.sessionName, cleanupWorktrees: args.cleanupWorktrees, createArchiveTags: args.createArchiveTags, force: true, }); if (!result.success) { return result.error!; } return result.instructions; }, });