Skip to content

Commit 3fe0550

Browse files
committed
fix: tools
1 parent aff88fd commit 3fe0550

File tree

2 files changed

+96
-111
lines changed

2 files changed

+96
-111
lines changed

common/src/util/types/tools.d.ts

Lines changed: 95 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,281 +1,266 @@
11
/**
22
* Union type of all available tool names
33
*/
4-
export type ToolName =
5-
| 'add_message'
6-
| 'add_subgoal'
7-
| 'browser_logs'
8-
| 'code_search'
9-
| 'create_plan'
10-
| 'end_turn'
11-
| 'find_files'
12-
| 'read_docs'
13-
| 'read_files'
14-
| 'run_file_change_hooks'
15-
| 'run_terminal_command'
16-
| 'send_agent_message'
17-
| 'set_messages'
18-
| 'set_output'
19-
| 'spawn_agents'
20-
| 'spawn_agents_async'
21-
| 'str_replace'
22-
| 'think_deeply'
23-
| 'update_subgoal'
24-
| 'web_search'
25-
| 'write_file'
4+
export type ToolName = 'add_message' | 'add_subgoal' | 'browser_logs' | 'code_search' | 'create_plan' | 'end_turn' | 'find_files' | 'read_docs' | 'read_files' | 'run_file_change_hooks' | 'run_terminal_command' | 'send_agent_message' | 'set_messages' | 'set_output' | 'spawn_agents' | 'spawn_agents_async' | 'str_replace' | 'think_deeply' | 'update_subgoal' | 'web_search' | 'write_file'
265

276
/**
287
* Map of tool names to their parameter types
298
*/
309
export interface ToolParamsMap {
31-
add_message: AddMessageParams
32-
add_subgoal: AddSubgoalParams
33-
browser_logs: BrowserLogsParams
34-
code_search: CodeSearchParams
35-
create_plan: CreatePlanParams
36-
end_turn: EndTurnParams
37-
find_files: FindFilesParams
38-
read_docs: ReadDocsParams
39-
read_files: ReadFilesParams
40-
run_file_change_hooks: RunFileChangeHooksParams
41-
run_terminal_command: RunTerminalCommandParams
42-
send_agent_message: SendAgentMessageParams
43-
set_messages: SetMessagesParams
44-
set_output: SetOutputParams
45-
spawn_agents: SpawnAgentsParams
46-
spawn_agents_async: SpawnAgentsAsyncParams
47-
str_replace: StrReplaceParams
48-
think_deeply: ThinkDeeplyParams
49-
update_subgoal: UpdateSubgoalParams
50-
web_search: WebSearchParams
51-
write_file: WriteFileParams
10+
'add_message': AddMessageParams
11+
'add_subgoal': AddSubgoalParams
12+
'browser_logs': BrowserLogsParams
13+
'code_search': CodeSearchParams
14+
'create_plan': CreatePlanParams
15+
'end_turn': EndTurnParams
16+
'find_files': FindFilesParams
17+
'read_docs': ReadDocsParams
18+
'read_files': ReadFilesParams
19+
'run_file_change_hooks': RunFileChangeHooksParams
20+
'run_terminal_command': RunTerminalCommandParams
21+
'send_agent_message': SendAgentMessageParams
22+
'set_messages': SetMessagesParams
23+
'set_output': SetOutputParams
24+
'spawn_agents': SpawnAgentsParams
25+
'spawn_agents_async': SpawnAgentsAsyncParams
26+
'str_replace': StrReplaceParams
27+
'think_deeply': ThinkDeeplyParams
28+
'update_subgoal': UpdateSubgoalParams
29+
'web_search': WebSearchParams
30+
'write_file': WriteFileParams
5231
}
5332

5433
/**
5534
* Add a new message to the conversation history. To be used for complex requests that can't be solved in a single step, as you may forget what happened!
5635
*/
5736
export interface AddMessageParams {
58-
role: 'user' | 'assistant'
59-
content: string
37+
"role": "user" | "assistant"
38+
"content": string
6039
}
6140

6241
/**
6342
* Add a new subgoal for tracking progress. To be used for complex requests that can't be solved in a single step, as you may forget what happened!
6443
*/
6544
export interface AddSubgoalParams {
6645
// A unique identifier for the subgoal. Try to choose the next sequential integer that is not already in use.
67-
id: string
46+
"id": string
6847
// The objective of the subgoal, concisely and clearly stated.
69-
objective: string
48+
"objective": string
7049
// The status of the subgoal.
71-
status: 'NOT_STARTED' | 'IN_PROGRESS' | 'COMPLETE' | 'ABORTED'
50+
"status": "NOT_STARTED" | "IN_PROGRESS" | "COMPLETE" | "ABORTED"
7251
// A plan for the subgoal.
73-
plan?: string
52+
"plan"?: string
7453
// A log message for the subgoal progress.
75-
log?: string
54+
"log"?: string
7655
}
7756

7857
/**
7958
* Parameters for browser_logs tool
8059
*/
8160
export interface BrowserLogsParams {
8261
// The type of browser action to perform (e.g., "navigate").
83-
type: string
62+
"type": string
8463
// The URL to navigate to.
85-
url: string
64+
"url": string
8665
// When to consider navigation successful. Defaults to 'load'.
87-
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle0'
66+
"waitUntil"?: "load" | "domcontentloaded" | "networkidle0"
8867
}
8968

9069
/**
9170
* Search for string patterns in the project's files. This tool uses ripgrep (rg), a fast line-oriented search tool. Use this tool only when read_files is not sufficient to find the files you need.
9271
*/
9372
export interface CodeSearchParams {
9473
// The pattern to search for.
95-
pattern: string
74+
"pattern": string
9675
// Optional ripgrep flags to customize the search (e.g., "-i" for case-insensitive, "-t ts" for TypeScript files only, "-A 3" for 3 lines after match, "-B 2" for 2 lines before match, "--type-not test" to exclude test files).
97-
flags?: string
76+
"flags"?: string
9877
// Optional working directory to search within, relative to the project root. Defaults to searching the entire project.
99-
cwd?: string
78+
"cwd"?: string
79+
// Easp flag must be set to true
80+
"cb_easp"?: boolean
10081
}
10182

10283
/**
10384
* Generate a detailed markdown plan for complex tasks.
10485
*/
10586
export interface CreatePlanParams {
10687
// The path including the filename of a markdown file that will be overwritten with the plan.
107-
path: string
88+
"path": string
10889
// A detailed plan to solve the user's request.
109-
plan: string
90+
"plan": string
11091
}
11192

11293
/**
11394
* End your turn, regardless of any new tool results that might be coming. This will allow the user to type another prompt.
11495
*/
115-
export interface EndTurnParams {}
96+
export interface EndTurnParams {
97+
98+
}
11699

117100
/**
118101
* Find several files related to a brief natural language description of the files or the name of a function or class you are looking for.
119102
*/
120103
export interface FindFilesParams {
121104
// A brief natural language description of the files or the name of a function or class you are looking for. It's also helpful to mention a directory or two to look within.
122-
prompt: string
105+
"prompt": string
123106
}
124107

125108
/**
126109
* Fetch up-to-date documentation for libraries and frameworks using Context7 API.
127110
*/
128111
export interface ReadDocsParams {
129112
// The exact library or framework name (e.g., "Next.js", "MongoDB", "React"). Use the official name as it appears in documentation, not a search query.
130-
libraryTitle: string
113+
"libraryTitle": string
131114
// Optional specific topic to focus on (e.g., "routing", "hooks", "authentication")
132-
topic?: string
115+
"topic"?: string
133116
// Optional maximum number of tokens to return. Defaults to 10000. Values less than 10000 are automatically increased to 10000.
134-
max_tokens?: number
117+
"max_tokens"?: number
135118
}
136119

137120
/**
138121
* Read the multiple files from disk and return their contents. Use this tool to read as many files as would be helpful to answer the user's request.
139122
*/
140123
export interface ReadFilesParams {
141124
// List of file paths to read.
142-
paths: string[]
125+
"paths": string[]
143126
}
144127

145128
/**
146129
* Parameters for run_file_change_hooks tool
147130
*/
148131
export interface RunFileChangeHooksParams {
149132
// List of file paths that were changed and should trigger file change hooks
150-
files: string[]
133+
"files": string[]
151134
}
152135

153136
/**
154137
* Execute a CLI command from the **project root** (different from the user's cwd).
155138
*/
156139
export interface RunTerminalCommandParams {
157140
// CLI command valid for user's OS.
158-
command: string
141+
"command": string
159142
// Either SYNC (waits, returns output) or BACKGROUND (runs in background). Default SYNC
160-
process_type: 'SYNC' | 'BACKGROUND'
143+
"process_type": "SYNC" | "BACKGROUND"
161144
// The working directory to run the command in. Default is the project root.
162-
cwd?: string
145+
"cwd"?: string
163146
// Set to -1 for no timeout. Does not apply for BACKGROUND commands. Default 30
164-
timeout_seconds: number
147+
"timeout_seconds": number
165148
}
166149

167150
/**
168151
* Send a message to another agent (parent or child) for communication and data exchange.
169152
*/
170153
export interface SendAgentMessageParams {
171154
// ID of the target agent to send message to. Use "PARENT_ID" to send to parent agent.
172-
target_agent_id: string
155+
"target_agent_id": string
173156
// Message prompt to send to the target agent
174-
prompt: string
157+
"prompt": string
175158
// Optional parameters object to send with the message
176-
params?: Record<string, any>
159+
"params"?: Record<string, any>
177160
}
178161

179162
/**
180163
* Set the conversation history to the provided messages.
181164
*/
182165
export interface SetMessagesParams {
183-
messages: {
184-
role: 'user' | 'assistant'
185-
content: string
186-
}[]
166+
"messages": {
167+
"role": "user" | "assistant"
168+
"content": string
169+
}[]
187170
}
188171

189172
/**
190173
* JSON object to set as the agent output. This completely replaces any previous output. If the agent was spawned, this value will be passed back to its parent. If the agent has an outputSchema defined, the output will be validated against it.
191174
*/
192-
export interface SetOutputParams {}
175+
export interface SetOutputParams {
176+
177+
}
193178

194179
/**
195180
* Spawn multiple agents and send a prompt to each of them.
196181
*/
197182
export interface SpawnAgentsParams {
198-
agents: {
199-
// Agent to spawn
200-
agent_type: string
201-
// Prompt to send to the agent
202-
prompt?: string
203-
// Parameters object for the agent (if any)
204-
params?: Record<string, any>
205-
}[]
183+
"agents": {
184+
// Agent to spawn
185+
"agent_type": string
186+
// Prompt to send to the agent
187+
"prompt"?: string
188+
// Parameters object for the agent (if any)
189+
"params"?: Record<string, any>
190+
}[]
206191
}
207192

208193
/**
209194
* Parameters for spawn_agents_async tool
210195
*/
211196
export interface SpawnAgentsAsyncParams {
212-
agents: {
213-
// Agent to spawn
214-
agent_type: string
215-
// Prompt to send to the agent
216-
prompt?: string
217-
// Parameters object for the agent (if any)
218-
params?: Record<string, any>
219-
}[]
197+
"agents": {
198+
// Agent to spawn
199+
"agent_type": string
200+
// Prompt to send to the agent
201+
"prompt"?: string
202+
// Parameters object for the agent (if any)
203+
"params"?: Record<string, any>
204+
}[]
220205
}
221206

222207
/**
223208
* Replace strings in a file with new strings.
224209
*/
225210
export interface StrReplaceParams {
226211
// The path to the file to edit.
227-
path: string
212+
"path": string
228213
// Array of replacements to make.
229-
replacements: {
230-
// The string to replace. This must be an *exact match* of the string you want to replace, including whitespace and punctuation.
231-
old: string
232-
// The string to replace the corresponding old string with. Can be empty to delete.
233-
new: string
234-
}[]
214+
"replacements": {
215+
// The string to replace. This must be an *exact match* of the string you want to replace, including whitespace and punctuation.
216+
"old": string
217+
// The string to replace the corresponding old string with. Can be empty to delete.
218+
"new": string
219+
}[]
235220
}
236221

237222
/**
238223
* Deeply consider complex tasks by brainstorming approaches and tradeoffs step-by-step.
239224
*/
240225
export interface ThinkDeeplyParams {
241226
// Detailed step-by-step analysis. Initially keep each step concise (max ~5-7 words per step).
242-
thought: string
227+
"thought": string
243228
}
244229

245230
/**
246231
* Update a subgoal in the context given the id, and optionally the status or plan, or a new log to append. Feel free to update any combination of the status, plan, or log in one invocation.
247232
*/
248233
export interface UpdateSubgoalParams {
249234
// The id of the subgoal to update.
250-
id: string
235+
"id": string
251236
// Change the status of the subgoal.
252-
status?: 'NOT_STARTED' | 'IN_PROGRESS' | 'COMPLETE' | 'ABORTED'
237+
"status"?: "NOT_STARTED" | "IN_PROGRESS" | "COMPLETE" | "ABORTED"
253238
// Change the plan for the subgoal.
254-
plan?: string
239+
"plan"?: string
255240
// Add a log message to the subgoal. This will create a new log entry and append it to the existing logs. Use this to record your progress and any new information you learned as you go.
256-
log?: string
241+
"log"?: string
257242
}
258243

259244
/**
260245
* Search the web for current information using Linkup API.
261246
*/
262247
export interface WebSearchParams {
263248
// The search query to find relevant web content
264-
query: string
249+
"query": string
265250
// Search depth - 'standard' for quick results, 'deep' for more comprehensive search. Default is 'standard'.
266-
depth: 'standard' | 'deep'
251+
"depth": "standard" | "deep"
267252
}
268253

269254
/**
270255
* Create or edit a file with the given content.
271256
*/
272257
export interface WriteFileParams {
273258
// Path to the file relative to the **project root**
274-
path: string
259+
"path": string
275260
// What the change is intended to do in only one sentence.
276-
instructions: string
261+
"instructions": string
277262
// Edit snippet to apply to the file.
278-
content: string
263+
"content": string
279264
}
280265

281266
/**

scripts/generate-tool-definitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function main() {
1414

1515
try {
1616
const content = compileToolDefinitions()
17-
const outputPath = join(process.cwd(), 'common/src/util/tools.d.ts')
17+
const outputPath = join(process.cwd(), 'common/src/util/types/tools.d.ts')
1818

1919
writeFileSync(outputPath, content, 'utf8')
2020

0 commit comments

Comments
 (0)