refactor: standardize on pid as canonical background execution field

Remove the dual executionId/pid fields from BackgroundExecutionData.
Use pid everywhere for consistency with existing types (ExecutingToolCall,
ExecutionHandle). A codebase-wide rename to executionId is planned as a
follow-up once all consumers are migrated.
This commit is contained in:
Adam Weidman
2026-03-09 01:10:42 -04:00
parent 013cfafbf9
commit c77fd3fc7a
4 changed files with 12 additions and 41 deletions
-1
View File
@@ -347,7 +347,6 @@ export class ShellToolInvocation extends BaseToolInvocation<
} else if (this.params.is_background || result.backgrounded) {
llmContent = `Command moved to background (PID: ${result.pid}). Output hidden. Press Ctrl+B to view.`;
data = {
executionId: result.pid,
pid: result.pid,
command: this.params.command,
initialOutput: result.output,
+5 -21
View File
@@ -75,15 +75,13 @@ export interface ToolInvocation<
/**
* Structured payload used by tools to surface background execution metadata to
* the CLI UI.
*
* NOTE: `pid` is used as the canonical identifier for now to stay consistent
* with existing types (ExecutingToolCall.pid, ExecutionHandle.pid, etc.).
* A future rename to `executionId` is planned once the codebase is fully
* migrated — not done in this PR to keep the diff focused on the abstraction.
*/
export interface BackgroundExecutionData extends Record<string, unknown> {
/**
* Neutral execution identifier for background lifecycle tracking.
*/
executionId?: number;
/**
* Backwards-compatible alias for executionId.
*/
pid?: number;
command?: string;
initialOutput?: string;
@@ -96,32 +94,18 @@ export function isBackgroundExecutionData(
return false;
}
const executionId = 'executionId' in data ? data.executionId : undefined;
const pid = 'pid' in data ? data.pid : undefined;
const command = 'command' in data ? data.command : undefined;
const initialOutput =
'initialOutput' in data ? data.initialOutput : undefined;
return (
(executionId === undefined || typeof executionId === 'number') &&
(pid === undefined || typeof pid === 'number') &&
(command === undefined || typeof command === 'string') &&
(initialOutput === undefined || typeof initialOutput === 'string')
);
}
export function getBackgroundExecutionId(
data: BackgroundExecutionData,
): number | undefined {
if (typeof data.executionId === 'number') {
return data.executionId;
}
if (typeof data.pid === 'number') {
return data.pid;
}
return undefined;
}
/**
* Options for policy updates that can be customized by tool invocations.
*/