@stackone/ai
Version:
Tools for agents to perform actions on your SaaS
122 lines (120 loc) • 3.35 kB
TypeScript
import { ExecuteConfig, ExecuteOptions, Experimental_PreExecuteFunction, Experimental_ToolCreationOptions, JsonDict, ToolParameters } from "./types.js";
import { RequestBuilder } from "./modules/requestBuilder.js";
import "@orama/orama";
import { ToolSet } from "ai";
import { ChatCompletionTool } from "openai/resources/chat/completions";
//#region src/tool.d.ts
/**
* Base class for all tools. Provides common functionality for executing API calls
* and converting to various formats (OpenAI, AI SDK)
*/
declare class BaseTool {
name: string;
description: string;
parameters: ToolParameters;
executeConfig: ExecuteConfig;
protected requestBuilder: RequestBuilder;
protected experimental_preExecute?: Experimental_PreExecuteFunction;
constructor(name: string, description: string, parameters: ToolParameters, executeConfig: ExecuteConfig, headers?: Record<string, string>, experimental_preExecute?: Experimental_PreExecuteFunction);
/**
* Set headers for this tool
*/
setHeaders(headers: Record<string, string>): BaseTool;
/**
* Get the current headers
*/
getHeaders(): Record<string, string>;
/**
* Execute the tool with the provided parameters
*/
execute(inputParams?: JsonDict | string, options?: ExecuteOptions): Promise<JsonDict>;
/**
* Convert the tool to OpenAI format
*/
toOpenAI(): ChatCompletionTool;
/**
* Convert the tool to AI SDK format
*/
toAISDK(options?: {
executable?: boolean;
}): ToolSet;
}
/**
* StackOne-specific tool class with additional functionality
*/
declare class StackOneTool extends BaseTool {
/**
* Get the current account ID
*/
getAccountId(): string | undefined;
/**
* Set the account ID for this tool
*/
setAccountId(accountId: string): StackOneTool;
}
/**
* Collection of tools with utility methods
*/
declare class Tools implements Iterable<BaseTool> {
private tools;
constructor(tools: BaseTool[]);
/**
* Get the number of tools in the collection
*/
get length(): number;
/**
* Get a tool by name
*/
getTool(name: string, options?: Experimental_ToolCreationOptions): BaseTool | undefined;
/**
* Get a StackOne tool by name
*/
getStackOneTool(name: string): StackOneTool;
/**
* Check if a tool is a StackOne tool
*/
isStackOneTool(tool: BaseTool): tool is StackOneTool;
/**
* Get all StackOne tools in the collection
*/
getStackOneTools(): StackOneTool[];
/**
* Convert all tools to OpenAI format
*/
toOpenAI(): ChatCompletionTool[];
/**
* Convert all tools to AI SDK format
*/
toAISDK(): ToolSet;
/**
* Filter tools by a predicate function
*/
filter(predicate: (tool: BaseTool) => boolean): Tools;
/**
* Return meta tools for tool discovery and execution
* @beta This feature is in beta and may change in future versions
*/
metaTools(): Promise<Tools>;
/**
* Iterator implementation
*/
[Symbol.iterator](): Iterator<BaseTool>;
/**
* Convert to array
*/
toArray(): BaseTool[];
/**
* Map tools to a new array
*/
map<T>(mapper: (tool: BaseTool) => T): T[];
/**
* Execute a function for each tool
*/
forEach(callback: (tool: BaseTool) => void): void;
}
/**
* Result from meta_search_tools
*/
//#endregion
export { BaseTool, StackOneTool, Tools };
//# sourceMappingURL=tool.d.ts.map