1
>
/*---------------------------------------------------------------------------------------------
claudeToolDenial.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
/**
7
>
* Deny `message` returned to the SDK when the user declines a tool
8
>
* permission. The SDK surfaces it as the `is_error` tool_result content.
9
>
*/
10
>
export const CLAUDE_USER_DECLINED_MESSAGE = 'User declined';
11
>
/** Deny `message` when the user declines an `ExitPlanMode` plan. */
12
>
export const CLAUDE_PLAN_DECLINED_MESSAGE = 'The user declined the plan, maybe ask why?';
13
>
/** Deny `message` when the user cancels an `AskUserQuestion` prompt. */
14
>
export const CLAUDE_QUESTION_CANCELLED_MESSAGE = 'The user cancelled the question';
15
>
16
>
/**
17
>
* Classifies a failed tool's result message into a `languageModelToolInvoked`
18
>
* cancellation code (`denied`/`cancelled`), or `undefined` for a genuine tool
19
>
* error. The input is the `message` a denied `canUseTool` returns, which the
20
>
* SDK echoes back as the `is_error` tool_result content — so matching the
21
>
* known deny strings distinguishes a user cancellation from a tool failure.
22
>
*/
23
>
export function claudeToolDenialCode(message: string): 'denied' | 'cancelled' | undefined {
24
switch (message) {
25
case CLAUDE_USER_DECLINED_MESSAGE: