@iqai/adk 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +189 -189
- package/dist/index.d.ts +189 -189
- package/dist/index.js +525 -500
- package/dist/index.mjs +444 -419
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1679,104 +1679,107 @@ declare class AgentTool extends BaseTool {
|
|
|
1679
1679
|
}
|
|
1680
1680
|
|
|
1681
1681
|
/**
|
|
1682
|
-
*
|
|
1683
|
-
*
|
|
1684
|
-
* This tool automatically generates a function declaration from the function's
|
|
1685
|
-
* signature and documentation, making it easy to expose functions to agents.
|
|
1682
|
+
* Tool that allows an agent to exit the current execution loop
|
|
1686
1683
|
*/
|
|
1687
|
-
declare class
|
|
1688
|
-
|
|
1689
|
-
private mandatoryArgs;
|
|
1690
|
-
private parameterTypes;
|
|
1684
|
+
declare class ExitLoopTool extends BaseTool {
|
|
1685
|
+
protected logger: Logger;
|
|
1691
1686
|
/**
|
|
1692
|
-
*
|
|
1693
|
-
*
|
|
1694
|
-
* @param func The function to wrap
|
|
1695
|
-
* @param options Optional configuration for the tool
|
|
1687
|
+
* Constructor for ExitLoopTool
|
|
1696
1688
|
*/
|
|
1697
|
-
constructor(
|
|
1698
|
-
name?: string;
|
|
1699
|
-
description?: string;
|
|
1700
|
-
isLongRunning?: boolean;
|
|
1701
|
-
shouldRetryOnFailure?: boolean;
|
|
1702
|
-
maxRetryAttempts?: number;
|
|
1703
|
-
parameterTypes?: Record<string, string>;
|
|
1704
|
-
});
|
|
1689
|
+
constructor();
|
|
1705
1690
|
/**
|
|
1706
|
-
*
|
|
1691
|
+
* Execute the exit loop action
|
|
1707
1692
|
*/
|
|
1708
|
-
runAsync(
|
|
1693
|
+
runAsync(_args: Record<string, any>, context: ToolContext): Promise<any>;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
interface FileOperationResult {
|
|
1697
|
+
success: boolean;
|
|
1698
|
+
data?: any;
|
|
1699
|
+
error?: string;
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Tool for performing file system operations
|
|
1703
|
+
*/
|
|
1704
|
+
declare class FileOperationsTool extends BaseTool {
|
|
1705
|
+
private basePath;
|
|
1706
|
+
constructor(options?: {
|
|
1707
|
+
basePath?: string;
|
|
1708
|
+
});
|
|
1709
1709
|
/**
|
|
1710
|
-
*
|
|
1710
|
+
* Get the function declaration for the tool
|
|
1711
1711
|
*/
|
|
1712
1712
|
getDeclaration(): FunctionDeclaration;
|
|
1713
1713
|
/**
|
|
1714
|
-
*
|
|
1714
|
+
* Execute the file operation
|
|
1715
1715
|
*/
|
|
1716
|
-
|
|
1716
|
+
runAsync(args: {
|
|
1717
|
+
operation: "read" | "write" | "append" | "delete" | "exists" | "list" | "mkdir";
|
|
1718
|
+
filepath: string;
|
|
1719
|
+
content?: string;
|
|
1720
|
+
encoding?: BufferEncoding;
|
|
1721
|
+
}, _context: ToolContext): Promise<FileOperationResult>;
|
|
1717
1722
|
/**
|
|
1718
|
-
*
|
|
1723
|
+
* Resolve a file path relative to the base path
|
|
1719
1724
|
*/
|
|
1720
|
-
private
|
|
1725
|
+
private resolvePath;
|
|
1721
1726
|
/**
|
|
1722
|
-
*
|
|
1723
|
-
* In TypeScript, we can't easily inspect parameter defaults at runtime,
|
|
1724
|
-
* so this is a best-effort approach.
|
|
1727
|
+
* Validate that a path is within the base path for security
|
|
1725
1728
|
*/
|
|
1726
|
-
private
|
|
1729
|
+
private validatePath;
|
|
1727
1730
|
/**
|
|
1728
|
-
*
|
|
1731
|
+
* Read a file
|
|
1729
1732
|
*/
|
|
1730
|
-
private
|
|
1733
|
+
private readFile;
|
|
1731
1734
|
/**
|
|
1732
|
-
*
|
|
1735
|
+
* Write to a file
|
|
1733
1736
|
*/
|
|
1734
|
-
private
|
|
1737
|
+
private writeFile;
|
|
1735
1738
|
/**
|
|
1736
|
-
*
|
|
1739
|
+
* Append to a file
|
|
1737
1740
|
*/
|
|
1738
|
-
private
|
|
1741
|
+
private appendFile;
|
|
1739
1742
|
/**
|
|
1740
|
-
*
|
|
1743
|
+
* Delete a file
|
|
1741
1744
|
*/
|
|
1742
|
-
private
|
|
1745
|
+
private deleteFile;
|
|
1746
|
+
/**
|
|
1747
|
+
* Check if a file exists
|
|
1748
|
+
*/
|
|
1749
|
+
private fileExists;
|
|
1750
|
+
/**
|
|
1751
|
+
* List directory contents
|
|
1752
|
+
*/
|
|
1753
|
+
private listDirectory;
|
|
1754
|
+
/**
|
|
1755
|
+
* Create a directory
|
|
1756
|
+
*/
|
|
1757
|
+
private makeDirectory;
|
|
1743
1758
|
}
|
|
1744
1759
|
|
|
1745
1760
|
/**
|
|
1746
|
-
*
|
|
1761
|
+
* Tool that allows an agent to get a choice from the user
|
|
1747
1762
|
*/
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1763
|
+
declare class GetUserChoiceTool extends BaseTool {
|
|
1764
|
+
protected logger: Logger;
|
|
1765
|
+
/**
|
|
1766
|
+
* Constructor for GetUserChoiceTool
|
|
1767
|
+
*/
|
|
1768
|
+
constructor();
|
|
1769
|
+
/**
|
|
1770
|
+
* Get the function declaration for the tool
|
|
1771
|
+
*/
|
|
1772
|
+
getDeclaration(): FunctionDeclaration;
|
|
1773
|
+
/**
|
|
1774
|
+
* Execute the user choice action
|
|
1775
|
+
* This is a long running operation that will return null initially
|
|
1776
|
+
* and the actual choice will be provided asynchronously
|
|
1777
|
+
*/
|
|
1778
|
+
runAsync(args: {
|
|
1779
|
+
options: string[];
|
|
1780
|
+
question?: string;
|
|
1781
|
+
}, context: ToolContext): Promise<any>;
|
|
1752
1782
|
}
|
|
1753
|
-
/**
|
|
1754
|
-
* Builds a function declaration from a TypeScript function.
|
|
1755
|
-
*
|
|
1756
|
-
* This utility analyzes the function signature and JSDoc comments to create
|
|
1757
|
-
* a FunctionDeclaration object that can be used with LLMs.
|
|
1758
|
-
*
|
|
1759
|
-
* @param func The function to analyze
|
|
1760
|
-
* @param options Options for customizing the declaration
|
|
1761
|
-
* @returns A FunctionDeclaration representing the function
|
|
1762
|
-
*/
|
|
1763
|
-
declare function buildFunctionDeclaration(func: (...args: any[]) => any, options?: BuildFunctionDeclarationOptions): FunctionDeclaration;
|
|
1764
|
-
|
|
1765
|
-
/**
|
|
1766
|
-
* Creates a new FunctionTool that wraps a function.
|
|
1767
|
-
* This is a convenience function for creating a new FunctionTool.
|
|
1768
|
-
*
|
|
1769
|
-
* @param func The function to wrap
|
|
1770
|
-
* @param options Optional configuration for the tool
|
|
1771
|
-
* @returns A new FunctionTool wrapping the function
|
|
1772
|
-
*/
|
|
1773
|
-
declare function createFunctionTool(func: (...args: any[]) => any, options?: {
|
|
1774
|
-
name?: string;
|
|
1775
|
-
description?: string;
|
|
1776
|
-
isLongRunning?: boolean;
|
|
1777
|
-
shouldRetryOnFailure?: boolean;
|
|
1778
|
-
maxRetryAttempts?: number;
|
|
1779
|
-
}): any;
|
|
1780
1783
|
|
|
1781
1784
|
/**
|
|
1782
1785
|
* Simple GoogleSearch tool implementation
|
|
@@ -1833,68 +1836,77 @@ declare class HttpRequestTool extends BaseTool {
|
|
|
1833
1836
|
private isValidJson;
|
|
1834
1837
|
}
|
|
1835
1838
|
|
|
1836
|
-
interface FileOperationResult {
|
|
1837
|
-
success: boolean;
|
|
1838
|
-
data?: any;
|
|
1839
|
-
error?: string;
|
|
1840
|
-
}
|
|
1841
1839
|
/**
|
|
1842
|
-
*
|
|
1840
|
+
* A tool that loads the artifacts and adds them to the session.
|
|
1843
1841
|
*/
|
|
1844
|
-
declare class
|
|
1845
|
-
|
|
1846
|
-
constructor(options?: {
|
|
1847
|
-
basePath?: string;
|
|
1848
|
-
});
|
|
1842
|
+
declare class LoadArtifactsTool extends BaseTool {
|
|
1843
|
+
constructor();
|
|
1849
1844
|
/**
|
|
1850
1845
|
* Get the function declaration for the tool
|
|
1851
1846
|
*/
|
|
1852
1847
|
getDeclaration(): FunctionDeclaration;
|
|
1853
1848
|
/**
|
|
1854
|
-
* Execute the
|
|
1849
|
+
* Execute the load artifacts operation
|
|
1855
1850
|
*/
|
|
1856
1851
|
runAsync(args: {
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
}, _context: ToolContext): Promise<FileOperationResult>;
|
|
1852
|
+
artifact_names?: string[];
|
|
1853
|
+
}, context: ToolContext): Promise<{
|
|
1854
|
+
artifact_names: string[];
|
|
1855
|
+
}>;
|
|
1862
1856
|
/**
|
|
1863
|
-
*
|
|
1857
|
+
* Processes the outgoing LLM request for this tool.
|
|
1864
1858
|
*/
|
|
1865
|
-
|
|
1859
|
+
processLlmRequest(toolContext: ToolContext, llmRequest: LlmRequest): Promise<void>;
|
|
1866
1860
|
/**
|
|
1867
|
-
*
|
|
1861
|
+
* Appends artifacts information to the LLM request
|
|
1868
1862
|
*/
|
|
1869
|
-
private
|
|
1863
|
+
private appendArtifactsToLlmRequest;
|
|
1870
1864
|
/**
|
|
1871
|
-
*
|
|
1865
|
+
* Extracts function response from a part if it exists
|
|
1872
1866
|
*/
|
|
1873
|
-
private
|
|
1867
|
+
private extractFunctionResponse;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
/**
|
|
1871
|
+
* Tool that allows an agent to load memories relevant to a query
|
|
1872
|
+
*/
|
|
1873
|
+
declare class LoadMemoryTool extends BaseTool {
|
|
1874
|
+
protected logger: Logger;
|
|
1874
1875
|
/**
|
|
1875
|
-
*
|
|
1876
|
+
* Constructor for LoadMemoryTool
|
|
1876
1877
|
*/
|
|
1877
|
-
|
|
1878
|
+
constructor();
|
|
1878
1879
|
/**
|
|
1879
|
-
*
|
|
1880
|
+
* Get the function declaration for the tool
|
|
1880
1881
|
*/
|
|
1881
|
-
|
|
1882
|
+
getDeclaration(): FunctionDeclaration;
|
|
1882
1883
|
/**
|
|
1883
|
-
*
|
|
1884
|
+
* Execute the memory loading action
|
|
1884
1885
|
*/
|
|
1885
|
-
|
|
1886
|
+
runAsync(args: {
|
|
1887
|
+
query: string;
|
|
1888
|
+
}, context: ToolContext): Promise<any>;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* Tool that allows an agent to transfer control to another agent
|
|
1893
|
+
*/
|
|
1894
|
+
declare class TransferToAgentTool extends BaseTool {
|
|
1895
|
+
protected logger: Logger;
|
|
1886
1896
|
/**
|
|
1887
|
-
*
|
|
1897
|
+
* Constructor for TransferToAgentTool
|
|
1888
1898
|
*/
|
|
1889
|
-
|
|
1899
|
+
constructor();
|
|
1890
1900
|
/**
|
|
1891
|
-
*
|
|
1901
|
+
* Get the function declaration for the tool
|
|
1892
1902
|
*/
|
|
1893
|
-
|
|
1903
|
+
getDeclaration(): FunctionDeclaration;
|
|
1894
1904
|
/**
|
|
1895
|
-
*
|
|
1905
|
+
* Execute the transfer to agent action
|
|
1896
1906
|
*/
|
|
1897
|
-
|
|
1907
|
+
runAsync(args: {
|
|
1908
|
+
agent_name: string;
|
|
1909
|
+
}, context: ToolContext): Promise<any>;
|
|
1898
1910
|
}
|
|
1899
1911
|
|
|
1900
1912
|
interface UserInteractionResult {
|
|
@@ -1922,116 +1934,104 @@ declare class UserInteractionTool extends BaseTool {
|
|
|
1922
1934
|
}
|
|
1923
1935
|
|
|
1924
1936
|
/**
|
|
1925
|
-
*
|
|
1937
|
+
* A tool that wraps a user-defined TypeScript function.
|
|
1938
|
+
*
|
|
1939
|
+
* This tool automatically generates a function declaration from the function's
|
|
1940
|
+
* signature and documentation, making it easy to expose functions to agents.
|
|
1926
1941
|
*/
|
|
1927
|
-
declare class
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
*/
|
|
1932
|
-
constructor();
|
|
1942
|
+
declare class FunctionTool<T extends Record<string, any>> extends BaseTool {
|
|
1943
|
+
private func;
|
|
1944
|
+
private mandatoryArgs;
|
|
1945
|
+
private parameterTypes;
|
|
1933
1946
|
/**
|
|
1934
|
-
*
|
|
1947
|
+
* Creates a new FunctionTool wrapping the provided function.
|
|
1948
|
+
*
|
|
1949
|
+
* @param func The function to wrap
|
|
1950
|
+
* @param options Optional configuration for the tool
|
|
1935
1951
|
*/
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1952
|
+
constructor(func: (...args: any[]) => any, options?: {
|
|
1953
|
+
name?: string;
|
|
1954
|
+
description?: string;
|
|
1955
|
+
isLongRunning?: boolean;
|
|
1956
|
+
shouldRetryOnFailure?: boolean;
|
|
1957
|
+
maxRetryAttempts?: number;
|
|
1958
|
+
parameterTypes?: Record<string, string>;
|
|
1959
|
+
});
|
|
1944
1960
|
/**
|
|
1945
|
-
*
|
|
1961
|
+
* Executes the wrapped function with the provided arguments.
|
|
1946
1962
|
*/
|
|
1947
|
-
|
|
1963
|
+
runAsync(args: T, context: ToolContext): Promise<any>;
|
|
1948
1964
|
/**
|
|
1949
|
-
*
|
|
1965
|
+
* Returns the function declaration for this tool.
|
|
1950
1966
|
*/
|
|
1951
1967
|
getDeclaration(): FunctionDeclaration;
|
|
1952
1968
|
/**
|
|
1953
|
-
*
|
|
1954
|
-
* This is a long running operation that will return null initially
|
|
1955
|
-
* and the actual choice will be provided asynchronously
|
|
1969
|
+
* Checks if the wrapped function accepts a toolContext parameter.
|
|
1956
1970
|
*/
|
|
1957
|
-
|
|
1958
|
-
options: string[];
|
|
1959
|
-
question?: string;
|
|
1960
|
-
}, context: ToolContext): Promise<any>;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
/**
|
|
1964
|
-
* Tool that allows an agent to transfer control to another agent
|
|
1965
|
-
*/
|
|
1966
|
-
declare class TransferToAgentTool extends BaseTool {
|
|
1967
|
-
protected logger: Logger;
|
|
1971
|
+
private functionAcceptsToolContext;
|
|
1968
1972
|
/**
|
|
1969
|
-
*
|
|
1973
|
+
* Checks if the wrapped function is async.
|
|
1970
1974
|
*/
|
|
1971
|
-
|
|
1975
|
+
private isAsyncFunction;
|
|
1972
1976
|
/**
|
|
1973
|
-
*
|
|
1977
|
+
* Extracts the mandatory arguments from a function.
|
|
1978
|
+
* In TypeScript, we can't easily inspect parameter defaults at runtime,
|
|
1979
|
+
* so this is a best-effort approach.
|
|
1974
1980
|
*/
|
|
1975
|
-
|
|
1981
|
+
private getMandatoryArgs;
|
|
1976
1982
|
/**
|
|
1977
|
-
*
|
|
1983
|
+
* Checks which mandatory arguments are missing from the provided args.
|
|
1978
1984
|
*/
|
|
1979
|
-
|
|
1980
|
-
agent_name: string;
|
|
1981
|
-
}, context: ToolContext): Promise<any>;
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
/**
|
|
1985
|
-
* Tool that allows an agent to load memories relevant to a query
|
|
1986
|
-
*/
|
|
1987
|
-
declare class LoadMemoryTool extends BaseTool {
|
|
1988
|
-
protected logger: Logger;
|
|
1985
|
+
private getMissingMandatoryArgs;
|
|
1989
1986
|
/**
|
|
1990
|
-
*
|
|
1987
|
+
* Extracts the function parameters from the function's signature.
|
|
1991
1988
|
*/
|
|
1992
|
-
|
|
1989
|
+
private getFunctionParameters;
|
|
1993
1990
|
/**
|
|
1994
|
-
*
|
|
1991
|
+
* Converts an argument to the proper type based on the function signature.
|
|
1995
1992
|
*/
|
|
1996
|
-
|
|
1993
|
+
private convertArgumentType;
|
|
1997
1994
|
/**
|
|
1998
|
-
*
|
|
1995
|
+
* Extracts the type of a specific parameter from the function signature.
|
|
1999
1996
|
*/
|
|
2000
|
-
|
|
2001
|
-
query: string;
|
|
2002
|
-
}, context: ToolContext): Promise<any>;
|
|
1997
|
+
private getParameterType;
|
|
2003
1998
|
}
|
|
2004
1999
|
|
|
2005
2000
|
/**
|
|
2006
|
-
*
|
|
2001
|
+
* Options for building a function declaration
|
|
2007
2002
|
*/
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
*/
|
|
2013
|
-
getDeclaration(): FunctionDeclaration;
|
|
2014
|
-
/**
|
|
2015
|
-
* Execute the load artifacts operation
|
|
2016
|
-
*/
|
|
2017
|
-
runAsync(args: {
|
|
2018
|
-
artifact_names?: string[];
|
|
2019
|
-
}, context: ToolContext): Promise<{
|
|
2020
|
-
artifact_names: string[];
|
|
2021
|
-
}>;
|
|
2022
|
-
/**
|
|
2023
|
-
* Processes the outgoing LLM request for this tool.
|
|
2024
|
-
*/
|
|
2025
|
-
processLlmRequest(toolContext: ToolContext, llmRequest: LlmRequest): Promise<void>;
|
|
2026
|
-
/**
|
|
2027
|
-
* Appends artifacts information to the LLM request
|
|
2028
|
-
*/
|
|
2029
|
-
private appendArtifactsToLlmRequest;
|
|
2030
|
-
/**
|
|
2031
|
-
* Extracts function response from a part if it exists
|
|
2032
|
-
*/
|
|
2033
|
-
private extractFunctionResponse;
|
|
2003
|
+
interface BuildFunctionDeclarationOptions {
|
|
2004
|
+
name?: string;
|
|
2005
|
+
description?: string;
|
|
2006
|
+
ignoreParams?: string[];
|
|
2034
2007
|
}
|
|
2008
|
+
/**
|
|
2009
|
+
* Builds a function declaration from a TypeScript function.
|
|
2010
|
+
*
|
|
2011
|
+
* This utility analyzes the function signature and JSDoc comments to create
|
|
2012
|
+
* a FunctionDeclaration object that can be used with LLMs.
|
|
2013
|
+
*
|
|
2014
|
+
* @param func The function to analyze
|
|
2015
|
+
* @param options Options for customizing the declaration
|
|
2016
|
+
* @returns A FunctionDeclaration representing the function
|
|
2017
|
+
*/
|
|
2018
|
+
declare function buildFunctionDeclaration(func: (...args: any[]) => any, options?: BuildFunctionDeclarationOptions): FunctionDeclaration;
|
|
2019
|
+
|
|
2020
|
+
/**
|
|
2021
|
+
* Creates a new FunctionTool that wraps a function.
|
|
2022
|
+
* This is a convenience function for creating a new FunctionTool.
|
|
2023
|
+
*
|
|
2024
|
+
* @param func The function to wrap
|
|
2025
|
+
* @param options Optional configuration for the tool
|
|
2026
|
+
* @returns A new FunctionTool wrapping the function
|
|
2027
|
+
*/
|
|
2028
|
+
declare function createFunctionTool(func: (...args: any[]) => any, options?: {
|
|
2029
|
+
name?: string;
|
|
2030
|
+
description?: string;
|
|
2031
|
+
isLongRunning?: boolean;
|
|
2032
|
+
shouldRetryOnFailure?: boolean;
|
|
2033
|
+
maxRetryAttempts?: number;
|
|
2034
|
+
}): any;
|
|
2035
2035
|
|
|
2036
2036
|
type McpConfig = {
|
|
2037
2037
|
name: string;
|