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