/** * JSON object type - simple key-value structure */ export interface JsonObject { [key: string]: any; } /** * Represents a datasource configuration */ export interface ToolDatasourceInfo { uid: string; name: string; type: string; jsonData?: Record; } /** * Function to determine if a tool should be registered based on available datasources */ export type ShouldRegisterFunction = (datasources: ToolDatasourceInfo[]) => boolean; /** * Minimal options for a single request. * Tools only need these basic options. This is a standalone type to avoid * dependency on ConversationManager types from the main app. */ export interface SingleRequestOptions { weak?: boolean; signal?: AbortSignal; showThinking?: boolean; reasoningLevel?: string; } /** * Minimal tool use content structure. * Represents the minimal interface needed by tools without depending on main app types. * Matches the structure from the chat API schema (ToolUseContent). */ export interface MinimalToolUseContent { toolId: string; toolName: string; toolInput?: Record; type?: 'tool_use'; } /** * Minimal response from a single request. * Tools primarily need the text and toolUse fields. The output field is available * but typed as unknown to avoid dependency on ChatPromptOutput from the main app. */ export interface SingleRequestResponse { text: string; toolUse: MinimalToolUseContent[]; output?: unknown; } /** * Interface for a Conversation Manager that can execute tools. * This represents the capability to make single requests to the LLM with tool execution support. */ export interface ToolExecutingManager { /** * Make a single request to the model with centralized error handling * @param systemPrompt System prompt message * @param userMessage User message * @param options Options for the single request (weak, signal, showThinking) * @returns The model's response text */ singleRequest(systemPrompt: string, userMessage: string, options?: SingleRequestOptions): Promise; } /** * Type for tool invocation options. * The manager is typed as `ToolExecutingManager` to avoid dependency on ConversationManager from the main app. * Consumers should cast it to the appropriate type when needed. */ export type ToolInvokeOptions = { manager: ToolExecutingManager; signal?: AbortSignal; timeout?: number; /** * Unique ID of this tool invocation from the LLM. * Can be used to create isolated conversation audiences for retries * (e.g., audience: `tool-${toolUseId}`). */ toolUseId?: string; }; /** * Structured tool result block format used by chat tool_result messages. */ export interface ToolResultTextBlock { type: 'text'; text?: string; } export interface ToolResultImageURLBlock { type: 'image_url'; url?: string; } export type ToolResultBlock = ToolResultTextBlock | ToolResultImageURLBlock; export type ToolResultContent = string | ToolResultBlock[]; /** * Tool output can be: * - A simple string (legacy) * - Structured tool result blocks (text/image_url) * - A tuple of [content, artifact] where artifact can be any type (string, boolean, number, object, array, etc.) * Examples include PanelJSON, but the artifact can be any structured data type */ export type ToolOutput = ToolResultContent | [ToolResultContent, any | null] | [ToolResultContent, any[]] | [ToolResultContent, Record]; /** * Minimal Tool interface - matches the structure needed without extending external Tool type */ export interface Tool { name: string; description: string; inputSchema: JSONSchema; /** * When true, this tool is marked for deferred loading via tool search. * Deferred tools are not included in the LLM context until Claude searches for them, * saving context space (~200-400 tokens per tool). */ deferLoading?: boolean; } /** * Basic tool interface for inline tools that don't need to support conditional registration * with the "Assistant" (aka frontend agent or chat). * * These tools are typically used for simple, one-off tasks like generating content or executing commands. */ export interface InlineToolRunnable extends Tool { invoke: (input: JsonObject, options: ToolInvokeOptions) => Promise; metadata?: JsonObject & { explainer?: (input?: JsonObject) => string; }; verboseParsingErrors?: boolean; responseFormat?: 'content_and_artifact' | string; } /** * JSON Schema type definition from @types/json-schema * Using JSONSchema7 (Draft 7) which is compatible with zod's toJSONSchema output * and other JSON Schema converters (yup, joi-to-json, etc.) */ export type _JSONSchema = boolean | JSONSchema; export type JSONSchema = { [k: string]: unknown; $schema?: 'https://json-schema.org/draft/2020-12/schema' | 'http://json-schema.org/draft-07/schema#' | 'http://json-schema.org/draft-04/schema#'; $id?: string; $anchor?: string; $ref?: string; $dynamicRef?: string; $dynamicAnchor?: string; $vocabulary?: Record; $comment?: string; $defs?: Record; type?: 'object' | 'array' | 'string' | 'number' | 'boolean' | 'null' | 'integer'; additionalItems?: _JSONSchema; unevaluatedItems?: _JSONSchema; prefixItems?: _JSONSchema[]; items?: _JSONSchema | _JSONSchema[]; contains?: _JSONSchema; additionalProperties?: _JSONSchema; unevaluatedProperties?: _JSONSchema; properties?: Record; patternProperties?: Record; dependentSchemas?: Record; propertyNames?: _JSONSchema; if?: _JSONSchema; then?: _JSONSchema; else?: _JSONSchema; allOf?: JSONSchema[]; anyOf?: JSONSchema[]; oneOf?: JSONSchema[]; not?: _JSONSchema; multipleOf?: number; maximum?: number; exclusiveMaximum?: number | boolean; minimum?: number; exclusiveMinimum?: number | boolean; maxLength?: number; minLength?: number; pattern?: string; maxItems?: number; minItems?: number; uniqueItems?: boolean; maxContains?: number; minContains?: number; maxProperties?: number; minProperties?: number; required?: string[]; dependentRequired?: Record; enum?: Array; const?: string | number | boolean | null; id?: string; title?: string; description?: string; default?: unknown; deprecated?: boolean; readOnly?: boolean; writeOnly?: boolean; nullable?: boolean; examples?: unknown[]; format?: string; contentMediaType?: string; contentEncoding?: string; contentSchema?: JSONSchema; _prefault?: unknown; }; //# sourceMappingURL=types.d.ts.map