Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

ToolRegistry.md

148 lines2.9 KB

1---
2id: ToolRegistry
3title: ToolRegistry
4---
5​
6# Interface: ToolRegistry
7​
8Defined in: [packages/typescript/ai/src/tool-registry.ts:9](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L9)
9​
10A registry that holds tools and allows dynamic tool management.
11​
12The registry can be either mutable (allowing additions/removals during execution)
13or frozen (static tool list, for backward compatibility with tools arrays).
14​
15## Properties
16​
17### add()
18​
19```ts
20add: (tool) => void;
21```
22​
23Defined in: [packages/typescript/ai/src/tool-registry.ts:22](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L22)
24​
25Add a tool to the registry dynamically.
26For frozen registries, this is a no-op.
27​
28#### Parameters
29​
30##### tool
31​
32[`Tool`](Tool.md)
33​
34The tool to add
35​
36#### Returns
37​
38`void`
39​
40***
41​
42### get()
43​
44```ts
45get: (name) =>
46 | Tool<SchemaInput, SchemaInput, string>
47 | undefined;
48```
49​
50Defined in: [packages/typescript/ai/src/tool-registry.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L46)
51​
52Get a tool by name.
53​
54#### Parameters
55​
56##### name
57​
58`string`
59​
60The name of the tool to get
61​
62#### Returns
63​
64 \| [`Tool`](Tool.md)\<[`SchemaInput`](../type-aliases/SchemaInput.md), [`SchemaInput`](../type-aliases/SchemaInput.md), `string`\>
65 \| `undefined`
66​
67The tool if found, undefined otherwise
68​
69***
70​
71### getTools()
72​
73```ts
74getTools: () => readonly Tool<SchemaInput, SchemaInput, string>[];
75```
76​
77Defined in: [packages/typescript/ai/src/tool-registry.ts:14](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L14)
78​
79Get all current tools in the registry.
80Called each agent loop iteration to get the latest tool list.
81​
82#### Returns
83​
84readonly [`Tool`](Tool.md)\<[`SchemaInput`](../type-aliases/SchemaInput.md), [`SchemaInput`](../type-aliases/SchemaInput.md), `string`\>[]
85​
86***
87​
88### has()
89​
90```ts
91has: (name) => boolean;
92```
93​
94Defined in: [packages/typescript/ai/src/tool-registry.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L38)
95​
96Check if a tool exists in the registry.
97​
98#### Parameters
99​
100##### name
101​
102`string`
103​
104The name of the tool to check
105​
106#### Returns
107​
108`boolean`
109​
110***
111​
112### isFrozen
113​
114```ts
115readonly isFrozen: boolean;
116```
117​
118Defined in: [packages/typescript/ai/src/tool-registry.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L52)
119​
120Whether this registry is frozen (immutable).
121Frozen registries don't allow add/remove operations.
122​
123***
124​
125### remove()
126​
127```ts
128remove: (name) => boolean;
129```
130​
131Defined in: [packages/typescript/ai/src/tool-registry.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L31)
132​
133Remove a tool from the registry by name.
134For frozen registries, this always returns false.
135​
136#### Parameters
137​
138##### name
139​
140`string`
141​
142The name of the tool to remove
143​
144#### Returns
145​
146`boolean`
147​
148true if the tool was removed, false if not found or frozen