Skip to content

Commit c20e98e

Browse files
committed
🤖 feat: add display_name field for background processes
1 parent 50c7986 commit c20e98e

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

src/common/types/tools.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface BashToolArgs {
88
script: string;
99
timeout_secs?: number; // Optional: defaults to 3 seconds for interactivity
1010
run_in_background?: boolean; // Run without blocking (for long-running processes)
11+
display_name?: string; // Human-readable name for background processes
1112
}
1213

1314
interface CommonBashFields {
@@ -205,7 +206,7 @@ export interface BashBackgroundTerminateArgs {
205206
}
206207

207208
export type BashBackgroundTerminateResult =
208-
| { success: true; message: string }
209+
| { success: true; message: string; display_name?: string }
209210
| { success: false; error: string };
210211

211212
// Bash Background List Tool Types
@@ -219,6 +220,7 @@ export interface BashBackgroundListProcess {
219220
exitCode?: number;
220221
stdout_path: string; // Path to stdout log file
221222
stderr_path: string; // Path to stderr log file
223+
display_name?: string; // Human-readable name (e.g., "Dev Server")
222224
}
223225

224226
export type BashBackgroundListResult =

src/common/utils/tools/toolDefinitions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ export const TOOL_DEFINITIONS = {
6464
"Read output via bash (e.g. tail, grep, cat). " +
6565
"Process persists across tool calls until terminated or workspace is removed."
6666
),
67+
display_name: z
68+
.string()
69+
.optional()
70+
.describe(
71+
"Human-readable name for background processes (e.g., 'Dev Server', 'TypeCheck Watch'). " +
72+
"Only used when run_in_background=true."
73+
),
6774
}),
6875
},
6976
file_read: {

src/node/services/backgroundProcessManager.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface BackgroundProcessMeta {
1414
status: "running" | "exited" | "killed" | "failed";
1515
exitCode?: number;
1616
exitTime?: number;
17+
displayName?: string;
1718
}
1819

1920
/**
@@ -30,6 +31,7 @@ export interface BackgroundProcess {
3031
exitTime?: number; // Timestamp when exited (undefined if running)
3132
status: "running" | "exited" | "killed" | "failed";
3233
handle: BackgroundHandle; // For process interaction
34+
displayName?: string; // Human-readable name (e.g., "Dev Server")
3335
}
3436

3537
/**
@@ -59,6 +61,7 @@ export class BackgroundProcessManager {
5961
cwd: string;
6062
secrets?: Record<string, string>;
6163
niceness?: number;
64+
displayName?: string;
6265
}
6366
): Promise<
6467
{ success: true; processId: string; outputDir: string } | { success: false; error: string }
@@ -91,6 +94,7 @@ export class BackgroundProcessManager {
9194
script,
9295
startTime,
9396
status: "running",
97+
displayName: config.displayName,
9498
};
9599
await handle.writeMeta(JSON.stringify(meta, null, 2));
96100

@@ -103,6 +107,7 @@ export class BackgroundProcessManager {
103107
startTime,
104108
status: "running",
105109
handle,
110+
displayName: config.displayName,
106111
};
107112

108113
// Store process in map

src/node/services/tools/bash.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export const createBashTool: ToolFactory = (config: ToolConfiguration) => {
230230
description: TOOL_DEFINITIONS.bash.description + "\nRuns in " + config.cwd + " - no cd needed",
231231
inputSchema: TOOL_DEFINITIONS.bash.schema,
232232
execute: async (
233-
{ script, timeout_secs, run_in_background },
233+
{ script, timeout_secs, run_in_background, display_name },
234234
{ abortSignal }
235235
): Promise<BashToolResult> => {
236236
// Validate script input
@@ -267,6 +267,7 @@ export const createBashTool: ToolFactory = (config: ToolConfiguration) => {
267267
cwd: config.cwd,
268268
secrets: config.secrets,
269269
niceness: config.niceness,
270+
displayName: display_name,
270271
}
271272
);
272273

src/node/services/tools/bash_background_list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const createBashBackgroundListTool: ToolFactory = (config: ToolConfigurat
3838
exitCode: p.exitCode,
3939
stdout_path: `${p.outputDir}/stdout.log`,
4040
stderr_path: `${p.outputDir}/stderr.log`,
41+
display_name: p.displayName,
4142
})),
4243
};
4344
},

src/node/services/tools/bash_background_terminate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const createBashBackgroundTerminateTool: ToolFactory = (config: ToolConfi
3939
return {
4040
success: true,
4141
message: `Process ${process_id} terminated`,
42+
display_name: process.displayName,
4243
};
4344
}
4445

0 commit comments

Comments
 (0)