@utcp/sdk
Version:
Universal Tool Calling Protocol (UTCP) client library for TypeScript
79 lines (78 loc) • 2.74 kB
TypeScript
import { ClientTransportInterface } from '../client-transport-interface';
import { Tool } from '../../shared/tool';
import { ProviderUnion } from '../../shared/provider';
/**
* Transport implementation for text file-based tool providers.
*
* This transport reads tool definitions from local text files. The file should
* contain a JSON object with a 'tools' array containing tool definitions.
*
* Since tools are defined statically in text files, tool calls are not supported
* and will raise a ValueError.
*/
export declare class TextTransport implements ClientTransportInterface {
private basePath;
/**
* Initialize the text transport.
*
* @param basePath The base path to resolve relative file paths from.
*/
constructor(basePath?: string);
/**
* Log informational messages.
*/
private _logInfo;
/**
* Log error messages.
*/
private _logError;
/**
* Register a text provider and discover its tools.
*
* @param manual_provider The TextProvider to register
* @returns List of tools defined in the text file
* @throws Error if provider is not a TextProvider
* @throws Error if the specified file doesn't exist
* @throws Error if the file contains invalid JSON
*/
register_tool_provider(manual_provider: ProviderUnion): Promise<Tool[]>;
/**
* Deregister a text provider.
*
* This is a no-op for text providers since they are stateless.
*
* @param manual_provider The provider to deregister
*/
deregister_tool_provider(manual_provider: ProviderUnion): Promise<void>;
/**
* Call a tool on a text provider.
*
* For text providers, this returns the content of the text file.
*
* @param tool_name Name of the tool to call (ignored for text providers)
* @param args Arguments for the tool call (ignored for text providers)
* @param tool_provider The TextProvider containing the file
* @returns The content of the text file as a string
* @throws Error if provider is not a TextProvider
* @throws Error if the specified file doesn't exist
*/
call_tool(tool_name: string, args: Record<string, any>, tool_provider: ProviderUnion): Promise<any>;
/**
* Close the transport.
*
* This is a no-op for text transports since they don't maintain connections.
*/
close(): Promise<void>;
/**
* Check if a path is absolute.
* @param path The path to check
* @returns True if the path is absolute, false otherwise
*/
private isAbsolutePath;
/**
* Convert a file path to a URI.
* @param path The file path
* @returns The file URI
*/
private pathToUri;
}