-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add taskCommandExecuted event to track command execution results #6375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
de6db59
f4c1717
92f3f9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -96,4 +96,16 @@ export type TaskEvents = { | |||||
| // Task Analytics | ||||||
| [RooCodeEventName.TaskToolFailed]: [taskId: string, tool: ToolName, error: string] | ||||||
| [RooCodeEventName.TaskTokenUsageUpdated]: [taskId: string, tokenUsage: TokenUsage] | ||||||
|
|
||||||
| // Command Execution | ||||||
| taskCommandExecuted: [ | ||||||
|
||||||
| taskCommandExecuted: [ | |
| \t[RooCodeEventName.TaskCommandExecuted]: [ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -274,6 +274,15 @@ export async function executeCommand( | |
| await task.say("error", t("common:errors:command_timeout", { seconds: commandExecutionTimeoutSeconds })) | ||
| task.terminalProcess = undefined | ||
|
|
||
| // Emit taskCommandExecuted event for timeout | ||
| task.emit("taskCommandExecuted", task.taskId, { | ||
|
||
| command, | ||
| exitCode: undefined, | ||
| output: accumulatedOutput, // Use accumulatedOutput instead of result | ||
| succeeded: false, | ||
| failureReason: `Command timed out after ${commandExecutionTimeoutSeconds}s`, | ||
| }) | ||
|
|
||
| return [ | ||
| false, | ||
| `The command was terminated after exceeding a user-configured ${commandExecutionTimeoutSeconds}s timeout. Do not try to re-run the command.`, | ||
|
|
@@ -311,6 +320,15 @@ export async function executeCommand( | |
| const { text, images } = message | ||
| await task.say("user_feedback", text, images) | ||
|
|
||
| // Emit taskCommandExecuted event for running command with user feedback | ||
| task.emit("taskCommandExecuted", task.taskId, { | ||
| command, | ||
| exitCode: undefined, | ||
| output: accumulatedOutput, // Use accumulatedOutput instead of result | ||
| succeeded: false, | ||
| failureReason: "Command is still running (user provided feedback)", | ||
| }) | ||
|
|
||
| return [ | ||
| true, | ||
| formatResponse.toolResult( | ||
|
|
@@ -325,6 +343,7 @@ export async function executeCommand( | |
| ] | ||
| } else if (completed || exitDetails) { | ||
| let exitStatus: string = "" | ||
| let exitCode: number | undefined = exitDetails?.exitCode | ||
|
|
||
| if (exitDetails !== undefined) { | ||
| if (exitDetails.signalName) { | ||
|
|
@@ -350,6 +369,16 @@ export async function executeCommand( | |
|
|
||
| let workingDirInfo = ` within working directory '${terminal.getCurrentWorkingDirectory().toPosix()}'` | ||
|
|
||
| // Emit taskCommandExecuted event | ||
| const succeeded = exitCode === 0 | ||
| task.emit("taskCommandExecuted", task.taskId, { | ||
| command, | ||
| exitCode, | ||
| output: result, | ||
| succeeded, | ||
| failureReason: succeeded ? undefined : exitStatus, | ||
| }) | ||
|
|
||
| return [false, `Command executed in terminal ${workingDirInfo}. ${exitStatus}\nOutput:\n${result}`] | ||
| } else { | ||
| return [ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new 'taskCommandExecuted' event is defined here but isn’t added to the RooCodeEventName enum nor included in the taskEventSchema discriminated union. Consistency between runtime validation and enum usage is crucial. Consider adding a corresponding enum entry (e.g. TaskCommandExecuted) and including it in the union.