Path: blob/main/extensions/copilot/src/platform/chat/common/hookExecutor.ts
13401 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*--------------------------------------------------------------------------------------------*/45import type { CancellationToken, ChatHookCommand } from 'vscode';6import { createServiceIdentifier } from '../../../util/common/services';78export const IHookExecutor = createServiceIdentifier<IHookExecutor>('IHookExecutor');910export const enum HookCommandResultKind {11Success = 1,12/** Blocking error - shown to model (exit code 2) */13Error = 2,14/** Non-blocking error - shown to user only (other non-zero exit codes) */15NonBlockingError = 316}1718export interface IHookCommandResult {19readonly kind: HookCommandResultKind;20/**21* For success: stdout parsed as JSON if valid, otherwise as string.22* For errors: stderr content.23*/24readonly result: string | object;25/**26* The normalized exit code for the command.27* 0 = success, 2 = blocking error, other non-zero = non-blocking error.28* Terminations without a numeric exit code (e.g., by signal) are normalized to 1.29*/30readonly exitCode?: number;31}3233export interface IHookExecutor {34readonly _serviceBrand: undefined;3536/**37* Execute a single hook command, writing JSON input to stdin38* and capturing stdout/stderr.39*40* Exit code semantics:41* - 0: Success (stdout parsed as JSON if valid)42* - non-zero: Error (stderr returned)43*/44executeCommand(45hookCommand: ChatHookCommand,46input: unknown,47token: CancellationToken48): Promise<IHookCommandResult>;49}505152