mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 21:01:06 -05:00
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
export type AssistantMessageContent = TextContent | ToolUse
|
|
|
|
export interface TextContent {
|
|
type: "text"
|
|
content: string
|
|
partial: boolean
|
|
}
|
|
|
|
export const toolUseNames = [
|
|
"execute_command",
|
|
"read_file",
|
|
"write_to_file",
|
|
"search_files",
|
|
"list_files",
|
|
"list_code_definition_names",
|
|
"inspect_site",
|
|
"ask_followup_question",
|
|
"attempt_completion",
|
|
] as const
|
|
|
|
// Converts array of tool call names into a union type ("execute_command" | "read_file" | ...)
|
|
export type ToolUseName = (typeof toolUseNames)[number]
|
|
|
|
export const toolParamNames = [
|
|
"command",
|
|
"path",
|
|
"content",
|
|
"regex",
|
|
"file_pattern",
|
|
"recursive",
|
|
"url",
|
|
"question",
|
|
"result",
|
|
] as const
|
|
|
|
export type ToolParamName = (typeof toolParamNames)[number]
|
|
|
|
export interface ToolUse {
|
|
type: "tool_use"
|
|
name: ToolUseName
|
|
// params is a partial record, allowing only some or none of the possible parameters to be used
|
|
params: Partial<Record<ToolParamName, string>>
|
|
partial: boolean
|
|
}
|
|
|
|
export interface ExecuteCommandToolUse extends ToolUse {
|
|
name: "execute_command"
|
|
// Pick<Record<ToolParamName, string>, "command"> makes "command" required, but Partial<> makes it optional
|
|
params: Partial<Pick<Record<ToolParamName, string>, "command">>
|
|
}
|
|
|
|
export interface ReadFileToolUse extends ToolUse {
|
|
name: "read_file"
|
|
params: Partial<Pick<Record<ToolParamName, string>, "path">>
|
|
}
|
|
|
|
export interface WriteToFileToolUse extends ToolUse {
|
|
name: "write_to_file"
|
|
params: Partial<Pick<Record<ToolParamName, string>, "path" | "content">>
|
|
}
|
|
|
|
export interface SearchFilesToolUse extends ToolUse {
|
|
name: "search_files"
|
|
params: Partial<Pick<Record<ToolParamName, string>, "path" | "regex" | "file_pattern">>
|
|
}
|
|
|
|
export interface ListFilesToolUse extends ToolUse {
|
|
name: "list_files"
|
|
params: Partial<Pick<Record<ToolParamName, string>, "path" | "recursive">>
|
|
}
|
|
|
|
export interface ListCodeDefinitionNamesToolUse extends ToolUse {
|
|
name: "list_code_definition_names"
|
|
params: Partial<Pick<Record<ToolParamName, string>, "path">>
|
|
}
|
|
|
|
export interface InspectSiteToolUse extends ToolUse {
|
|
name: "inspect_site"
|
|
params: Partial<Pick<Record<ToolParamName, string>, "url">>
|
|
}
|
|
|
|
export interface AskFollowupQuestionToolUse extends ToolUse {
|
|
name: "ask_followup_question"
|
|
params: Partial<Pick<Record<ToolParamName, string>, "question">>
|
|
}
|
|
|
|
export interface AttemptCompletionToolUse extends ToolUse {
|
|
name: "attempt_completion"
|
|
params: Partial<Pick<Record<ToolParamName, string>, "result" | "command">>
|
|
}
|