feat: add process submit helper

This commit is contained in:
Peter Steinberger
2026-01-17 06:38:47 +00:00
parent 65a8a93854
commit 3dc4a96330
4 changed files with 108 additions and 2 deletions

View File

@@ -58,11 +58,22 @@ export function createProcessTool(
return {
name: "process",
label: "process",
description: "Manage running exec sessions: list, poll, log, write, send-keys, paste, kill.",
description:
"Manage running exec sessions: list, poll, log, write, send-keys, submit, paste, kill.",
parameters: processSchema,
execute: async (_toolCallId, args) => {
const params = args as {
action: "list" | "poll" | "log" | "write" | "send-keys" | "paste" | "kill" | "clear" | "remove";
action:
| "list"
| "poll"
| "log"
| "write"
| "send-keys"
| "submit"
| "paste"
| "kill"
| "clear"
| "remove";
sessionId?: string;
data?: string;
keys?: string[];
@@ -429,6 +440,62 @@ export function createProcessTool(
};
}
case "submit": {
if (!scopedSession) {
return {
content: [
{
type: "text",
text: `No active session found for ${params.sessionId}`,
},
],
details: { status: "failed" },
};
}
if (!scopedSession.backgrounded) {
return {
content: [
{
type: "text",
text: `Session ${params.sessionId} is not backgrounded.`,
},
],
details: { status: "failed" },
};
}
const stdin = scopedSession.stdin ?? scopedSession.child?.stdin;
if (!stdin || stdin.destroyed) {
return {
content: [
{
type: "text",
text: `Session ${params.sessionId} stdin is not writable.`,
},
],
details: { status: "failed" },
};
}
await new Promise<void>((resolve, reject) => {
stdin.write("\r", (err) => {
if (err) reject(err);
else resolve();
});
});
return {
content: [
{
type: "text",
text: `Submitted session ${params.sessionId} (sent CR).`,
},
],
details: {
status: "running",
sessionId: params.sessionId,
name: scopedSession ? deriveSessionName(scopedSession.command) : undefined,
},
};
}
case "paste": {
if (!scopedSession) {
return {