Path: blob/main/src/vscode-dts/vscode.proposed.chatHooks.d.ts
5250 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45// version: 367declare module 'vscode' {89/**10* The type of hook to execute.11*/12export type ChatHookType = 'SessionStart' | 'UserPromptSubmit' | 'PreToolUse' | 'PostToolUse' | 'PreCompact' | 'SubagentStart' | 'SubagentStop' | 'Stop';1314/**15* Options for executing a hook command.16*/17export interface ChatHookExecutionOptions {18/**19* Input data to pass to the hook via stdin (will be JSON-serialized).20*/21readonly input?: unknown;22/**23* The tool invocation token from the chat request context,24* used to associate the hook execution with the current chat session.25*/26readonly toolInvocationToken: ChatParticipantToolToken;27}2829/**30* The kind of result from executing a hook command.31* - 'success': Hook executed successfully (exit code 0)32* - 'error': Blocking error shown to model (exit code 2)33* - 'warning': Non-blocking warning shown to user only (other exit codes)34*/35export type ChatHookResultKind = 'success' | 'error' | 'warning';3637/**38* Result of executing a hook command.39* Contains common flow control fields and the hook's output.40*/41export interface ChatHookResult {42/**43* The kind of result from executing the hook.44*/45readonly resultKind: ChatHookResultKind;46/**47* If set, the agent should stop processing entirely after this hook.48* The message is shown to the user but not to the agent.49*/50readonly stopReason?: string;51/**52* Warning message shown to the user.53*/54readonly warningMessage?: string;55/**56* The hook's output (hook-specific fields only).57* For errors, this is the error message string.58*/59readonly output: unknown;60}6162export namespace chat {63/**64* Execute all hooks of the specified type for the current chat session.65* Hooks are configured in hooks .json files in the workspace.66*67* @param hookType The type of hook to execute.68* @param options Hook execution options including the input data.69* @param token Optional cancellation token.70* @returns A promise that resolves to an array of hook execution results.71*/72export function executeHook(hookType: ChatHookType, options: ChatHookExecutionOptions, token?: CancellationToken): Thenable<ChatHookResult[]>;73}74}757677