mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
New CLI commands: ls, create, kill, capture (tmux capture-pane style with line range slicing and ANSI stripping), and send-keys (with special token interpretation). Server-side adds capture_terminal_request RPC and list-all-terminals support (optional CWD). Includes e2e tests and skill docs.
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import type { Command } from "commander";
|
|
import type { CommandError, SingleResult } from "../../output/index.js";
|
|
import {
|
|
connectTerminalClient,
|
|
resolveTerminalId,
|
|
toTerminalCommandError,
|
|
type TerminalCommandOptions,
|
|
} from "./shared.js";
|
|
import { terminalKillSchema, type TerminalKillRow } from "./schema.js";
|
|
|
|
export async function runKillCommand(
|
|
terminalId: string,
|
|
options: TerminalCommandOptions,
|
|
_command: Command,
|
|
): Promise<SingleResult<TerminalKillRow>> {
|
|
const { client } = await connectTerminalClient(options.host);
|
|
|
|
try {
|
|
const resolvedId = await requireTerminalId(client, terminalId);
|
|
const payload = await client.killTerminal(resolvedId);
|
|
return {
|
|
type: "single",
|
|
data: {
|
|
terminalId: payload.terminalId,
|
|
success: payload.success,
|
|
},
|
|
schema: terminalKillSchema,
|
|
};
|
|
} catch (err) {
|
|
throw toTerminalCommandError("TERMINAL_KILL_FAILED", "kill terminal", err);
|
|
} finally {
|
|
await client.close().catch(() => {});
|
|
}
|
|
}
|
|
|
|
async function requireTerminalId(
|
|
client: Awaited<ReturnType<typeof connectTerminalClient>>["client"],
|
|
terminalId: string,
|
|
): Promise<string> {
|
|
const resolvedId = await resolveTerminalId(client, terminalId);
|
|
if (resolvedId) {
|
|
return resolvedId;
|
|
}
|
|
|
|
const error: CommandError = {
|
|
code: "TERMINAL_NOT_FOUND",
|
|
message: `No terminal found matching: ${terminalId}`,
|
|
details: "Use `paseo terminal ls --all` to list available terminals.",
|
|
};
|
|
throw error;
|
|
}
|