59 lines
1.2 KiB
TypeScript
59 lines
1.2 KiB
TypeScript
export interface ToolInputSchema {
|
|
type: 'object';
|
|
properties: Record<string, unknown>;
|
|
required?: string[];
|
|
}
|
|
|
|
export interface Tool {
|
|
name: string;
|
|
description: string;
|
|
inputSchema: ToolInputSchema;
|
|
/** Secret scopes required to execute this tool (optional). */
|
|
requiredSecretScopes?: string[];
|
|
execute(args: unknown, context?: ToolExecutionContext): Promise<ToolResult>;
|
|
}
|
|
|
|
export interface ToolExecutionContext {
|
|
signal?: AbortSignal;
|
|
}
|
|
|
|
export interface ToolCall {
|
|
id: string;
|
|
name: string;
|
|
args: unknown;
|
|
}
|
|
|
|
export interface ToolResult {
|
|
success: boolean;
|
|
output: string;
|
|
error?: string;
|
|
}
|
|
|
|
// Content block for assistant messages containing tool calls
|
|
export interface ToolUseBlock {
|
|
type: 'tool_use';
|
|
id: string;
|
|
name: string;
|
|
input: unknown;
|
|
}
|
|
|
|
// Content block for user messages returning tool results
|
|
export interface ToolResultBlock {
|
|
type: 'tool_result';
|
|
tool_use_id: string;
|
|
content: string;
|
|
is_error?: boolean;
|
|
}
|
|
|
|
// Message from assistant requesting tool use
|
|
export interface ToolUseMessage {
|
|
role: 'assistant';
|
|
content: ToolUseBlock[];
|
|
}
|
|
|
|
// Message from user returning tool results
|
|
export interface ToolResultMessage {
|
|
role: 'user';
|
|
content: ToolResultBlock[];
|
|
}
|