From 3aa5b3f9befe2eeb69d556958e5379dd254a5cf1 Mon Sep 17 00:00:00 2001 From: Nathan Apter Date: Wed, 29 Jan 2025 10:21:36 -0500 Subject: [PATCH] Allow the user to send context with approval or rejection --- src/core/Cline.ts | 30 +++++++++--------------------- src/core/prompts/responses.ts | 3 +++ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index e291197..a31c02a 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -1085,35 +1085,23 @@ export class Cline { const askApproval = async (type: ClineAsk, partialMessage?: string) => { const { response, text, images } = await this.ask(type, partialMessage, false) if (response !== "yesButtonClicked") { - if (response === "messageResponse") { + // Handle both messageResponse and noButtonClicked with text + if (text) { await this.say("user_feedback", text, images) pushToolResult( formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images), ) - // this.userMessageContent.push({ - // type: "text", - // text: `${toolDescription()}`, - // }) - // this.toolResults.push({ - // type: "tool_result", - // tool_use_id: toolUseId, - // content: this.formatToolResponseWithImages( - // await this.formatToolDeniedFeedback(text), - // images - // ), - // }) - this.didRejectTool = true - return false + } else { + pushToolResult(formatResponse.toolDenied()) } - pushToolResult(formatResponse.toolDenied()) - // this.toolResults.push({ - // type: "tool_result", - // tool_use_id: toolUseId, - // content: await this.formatToolDenied(), - // }) this.didRejectTool = true return false } + // Handle yesButtonClicked with text + if (text) { + await this.say("user_feedback", text, images) + pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images)) + } return true } diff --git a/src/core/prompts/responses.ts b/src/core/prompts/responses.ts index 05f33ba..f06dff3 100644 --- a/src/core/prompts/responses.ts +++ b/src/core/prompts/responses.ts @@ -8,6 +8,9 @@ export const formatResponse = { toolDeniedWithFeedback: (feedback?: string) => `The user denied this operation and provided the following feedback:\n\n${feedback}\n`, + toolApprovedWithFeedback: (feedback?: string) => + `The user approved this operation and provided the following context:\n\n${feedback}\n`, + toolError: (error?: string) => `The tool execution failed with the following error:\n\n${error}\n`, noToolsUsed: () =>