Skip to content

Commit 024a760

Browse files
committed
misc: small fix or general refactoring i did not bother commenting
1 parent 731d426 commit 024a760

File tree

2 files changed

+227
-46
lines changed

2 files changed

+227
-46
lines changed

docs/assets/make_ns.py

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import inspect
22
import pkgutil
3+
import typing as t
34

45
import nerve.tools.namespaces as namespaces
56

@@ -33,15 +34,48 @@
3334
print()
3435
print("<details>")
3536
print("<summary><b>Show Tools</b></summary>")
36-
37-
print("| Tool | Description |")
38-
print("|------|-------------|")
37+
print()
3938

4039
for name, func in inspect.getmembers(module, inspect.isfunction):
4140
if name[0] != "_" and func.__module__ == module.__name__:
4241
doc = func.__doc__ or ""
43-
doc = doc.strip().replace("\n", "<br>")
44-
print(f"| `{name}` | <pre>{doc}</pre> |")
42+
doc = doc.strip().strip()
43+
print(f"### `{name}`")
44+
print()
45+
print(f"<pre>{doc}</pre>")
46+
print()
47+
signature = inspect.signature(func)
48+
type_hints = t.get_type_hints(func, include_extras=True)
49+
params = signature.parameters.items()
50+
51+
if len(params) == 0:
52+
continue
53+
54+
print("**Parameters**")
55+
print()
56+
57+
for param_name, _param in params:
58+
if param_name == "self":
59+
continue
60+
61+
param_type = type_hints.get(param_name)
62+
if param_type is None:
63+
print(f"**{param_name}** NO TYPE")
64+
continue
65+
66+
is_annotated = t.get_origin(param_type) is t.Annotated
67+
68+
if is_annotated:
69+
args = t.get_args(param_type)
70+
base_type = args[0]
71+
description = args[1] if len(args) > 1 else ""
72+
if hasattr(description, "description"):
73+
description = description.description
74+
else:
75+
base_type = param_type
76+
description = ""
77+
78+
print(f"* `{param_name}` <i>({base_type})</i>: {description.strip()}")
4579

4680
print("</details>")
4781
print()

docs/namespaces.md

Lines changed: 188 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ Let the agent create its own tools in Python.
88

99
<details>
1010
<summary><b>Show Tools</b></summary>
11-
| Tool | Description |
12-
|------|-------------|
13-
| `create_tool` | <pre>Create a new tool or redefine an existing one by defining it as an annotated Python function.<br> Use this tool to implement the missing functionalities you need to perform your task.</pre> |
11+
12+
### `create_tool`
13+
14+
<pre>Create a new tool or redefine an existing one by defining it as an annotated Python function.
15+
Use this tool to implement the missing functionalities you need to perform your task.</pre>
16+
17+
**Parameters**
18+
19+
* `code` <i>(<class 'str'>)</i>: The Python code to create the tool.
1420
</details>
1521

1622
## computer
@@ -23,19 +29,69 @@ Computer use primitives for mouse, keyboard, and screen.
2329

2430
<details>
2531
<summary><b>Show Tools</b></summary>
26-
| Tool | Description |
27-
|------|-------------|
28-
| `get_cursor_position` | <pre>Get the current mouse position.</pre> |
29-
| `keyboard_press_hotkeys` | <pre>Press one or more hotkeys on the keyboard.</pre> |
30-
| `keyboard_type` | <pre>Type the given text on the keyboard.</pre> |
31-
| `mouse_double_click` | <pre>Double click the left mouse button at the current mouse position.</pre> |
32-
| `mouse_left_click` | <pre>Click the left mouse button at the current mouse position.</pre> |
33-
| `mouse_left_click_drag` | <pre>Click and drag the left mouse button from the current mouse position to the given coordinates.</pre> |
34-
| `mouse_middle_click` | <pre>Click the middle mouse button at the current mouse position.</pre> |
35-
| `mouse_move` | <pre>Move the mouse to the given coordinates.</pre> |
36-
| `mouse_right_click` | <pre>Click the right mouse button at the current mouse position.</pre> |
37-
| `mouse_scroll` | <pre>Scroll the mouse wheel in the given direction.</pre> |
38-
| `screenshot` | <pre>Take a screenshot of the current screen.</pre> |
32+
33+
### `get_cursor_position`
34+
35+
<pre>Get the current mouse position.</pre>
36+
37+
### `keyboard_press_hotkeys`
38+
39+
<pre>Press one or more hotkeys on the keyboard.</pre>
40+
41+
**Parameters**
42+
43+
* `keys` <i>(<class 'str'>)</i>: The hotkey sequence to press (like 'ctrl+shift+cmd+space')
44+
### `keyboard_type`
45+
46+
<pre>Type the given text on the keyboard.</pre>
47+
48+
**Parameters**
49+
50+
* `text` <i>(<class 'str'>)</i>: The text to type
51+
### `mouse_double_click`
52+
53+
<pre>Double click the left mouse button at the current mouse position.</pre>
54+
55+
### `mouse_left_click`
56+
57+
<pre>Click the left mouse button at the current mouse position.</pre>
58+
59+
### `mouse_left_click_drag`
60+
61+
<pre>Click and drag the left mouse button from the current mouse position to the given coordinates.</pre>
62+
63+
**Parameters**
64+
65+
* `x` <i>(<class 'int'>)</i>: The x coordinate to move to
66+
* `y` <i>(<class 'int'>)</i>: The y coordinate to move to
67+
### `mouse_middle_click`
68+
69+
<pre>Click the middle mouse button at the current mouse position.</pre>
70+
71+
### `mouse_move`
72+
73+
<pre>Move the mouse to the given coordinates.</pre>
74+
75+
**Parameters**
76+
77+
* `x` <i>(<class 'int'>)</i>: The x coordinate to move to
78+
* `y` <i>(<class 'int'>)</i>: The y coordinate to move to
79+
### `mouse_right_click`
80+
81+
<pre>Click the right mouse button at the current mouse position.</pre>
82+
83+
### `mouse_scroll`
84+
85+
<pre>Scroll the mouse wheel in the given direction.</pre>
86+
87+
**Parameters**
88+
89+
* `x` <i>(<class 'int'>)</i>: The x coordinate to move to
90+
* `y` <i>(<class 'int'>)</i>: The y coordinate to move to
91+
### `screenshot`
92+
93+
<pre>Take a screenshot of the current screen.</pre>
94+
3995
</details>
4096

4197
## filesystem
@@ -44,10 +100,21 @@ Read-only access primitives to the local filesystem.
44100

45101
<details>
46102
<summary><b>Show Tools</b></summary>
47-
| Tool | Description |
48-
|------|-------------|
49-
| `list_folder_contents` | <pre>List the contents of a folder on disk.</pre> |
50-
| `read_file` | <pre>Read the contents of a file from disk.</pre> |
103+
104+
### `list_folder_contents`
105+
106+
<pre>List the contents of a folder on disk.</pre>
107+
108+
**Parameters**
109+
110+
* `path` <i>(<class 'str'>)</i>: The path to the folder to list
111+
### `read_file`
112+
113+
<pre>Read the contents of a file from disk.</pre>
114+
115+
**Parameters**
116+
117+
* `path` <i>(<class 'str'>)</i>: The path to the file to read
51118
</details>
52119

53120
## inquire
@@ -56,12 +123,38 @@ Let the agent interactively ask questions to the user in a structured way.
56123

57124
<details>
58125
<summary><b>Show Tools</b></summary>
59-
| Tool | Description |
60-
|------|-------------|
61-
| `ask_for_confirmation` | <pre>Ask a confirmation question to the user.</pre> |
62-
| `ask_for_multiple_choice` | <pre>Ask a multiple choice question to the user.</pre> |
63-
| `ask_for_single_choice` | <pre>Ask a single choice question to the user.</pre> |
64-
| `ask_question` | <pre>Ask a question to the user.</pre> |
126+
127+
### `ask_for_confirmation`
128+
129+
<pre>Ask a confirmation question to the user.</pre>
130+
131+
**Parameters**
132+
133+
* `question` <i>(<class 'str'>)</i>: The question to ask the user.
134+
* `default` <i>(<class 'bool'>)</i>: The default answer to the question.
135+
### `ask_for_multiple_choice`
136+
137+
<pre>Ask a multiple choice question to the user.</pre>
138+
139+
**Parameters**
140+
141+
* `question` <i>(<class 'str'>)</i>: The question to ask the user.
142+
* `choices` <i>(list[str])</i>: The choices to offer the user.
143+
### `ask_for_single_choice`
144+
145+
<pre>Ask a single choice question to the user.</pre>
146+
147+
**Parameters**
148+
149+
* `question` <i>(<class 'str'>)</i>: The question to ask the user.
150+
* `choices` <i>(list[str])</i>: The choices to offer the user.
151+
### `ask_question`
152+
153+
<pre>Ask a question to the user.</pre>
154+
155+
**Parameters**
156+
157+
* `question` <i>(<class 'str'>)</i>: The question to ask the user.
65158
</details>
66159

67160
## reasoning
@@ -70,10 +163,40 @@ Simulates the reasoning process at runtime.
70163

71164
<details>
72165
<summary><b>Show Tools</b></summary>
73-
| Tool | Description |
74-
|------|-------------|
75-
| `clear_thoughts` | <pre>If the reasoning process proved wrong, inconsistent or ineffective, clear your thoughts and start again.</pre> |
76-
| `think` | <pre>Adhere strictly to this reasoning framework, ensuring thoroughness, precision, and logical rigor.<br><br> ## Problem Decomposition<br><br> Break the query into discrete, sequential steps.<br> Explicitly state assumptions and context.<br><br> ## Stepwise Analysis<br><br> Address each step individually.<br> Explain the rationale, principles, or rules applied (e.g., mathematical laws, linguistic conventions).<br> Use examples, analogies, or intermediate calculations to illustrate reasoning.<br><br> ## Validation & Error Checking<br><br> Verify logical consistency at each step.<br> Flag potential oversights, contradictions, or edge cases.<br> Confirm numerical accuracy (e.g., recompute calculations).<br><br> ## Synthesis & Conclusion<br><br> Integrate validated steps into a coherent solution.<br> Summarize key insights and ensure the conclusion directly addresses the original query.</pre> |
166+
167+
### `clear_thoughts`
168+
169+
<pre>If the reasoning process proved wrong, inconsistent or ineffective, clear your thoughts and start again.</pre>
170+
171+
### `think`
172+
173+
<pre>Adhere strictly to this reasoning framework, ensuring thoroughness, precision, and logical rigor.
174+
175+
## Problem Decomposition
176+
177+
Break the query into discrete, sequential steps.
178+
Explicitly state assumptions and context.
179+
180+
## Stepwise Analysis
181+
182+
Address each step individually.
183+
Explain the rationale, principles, or rules applied (e.g., mathematical laws, linguistic conventions).
184+
Use examples, analogies, or intermediate calculations to illustrate reasoning.
185+
186+
## Validation & Error Checking
187+
188+
Verify logical consistency at each step.
189+
Flag potential oversights, contradictions, or edge cases.
190+
Confirm numerical accuracy (e.g., recompute calculations).
191+
192+
## Synthesis & Conclusion
193+
194+
Integrate validated steps into a coherent solution.
195+
Summarize key insights and ensure the conclusion directly addresses the original query.</pre>
196+
197+
**Parameters**
198+
199+
* `thought` <i>(<class 'str'>)</i>: A thought to think about
77200
</details>
78201

79202
## shell
@@ -82,9 +205,14 @@ Let the agent execute shell commands.
82205

83206
<details>
84207
<summary><b>Show Tools</b></summary>
85-
| Tool | Description |
86-
|------|-------------|
87-
| `shell` | <pre>Execute a shell command on the local computer and return the output. Non interactive shell with a timeout of 30 seconds.</pre> |
208+
209+
### `shell`
210+
211+
<pre>Execute a shell command on the local computer and return the output. Non interactive shell with a timeout of 30 seconds.</pre>
212+
213+
**Parameters**
214+
215+
* `command` <i>(<class 'str'>)</i>: The shell command to execute
88216
</details>
89217

90218
## task
@@ -93,10 +221,21 @@ Let the agent autonomously set the task as complete or failed.
93221

94222
<details>
95223
<summary><b>Show Tools</b></summary>
96-
| Tool | Description |
97-
|------|-------------|
98-
| `task_complete_success` | <pre>When your objective has been reached use this tool to set the task as complete.</pre> |
99-
| `task_failed` | <pre>Use this tool if you determine that the given goal or task is impossible given the information you have.</pre> |
224+
225+
### `task_complete_success`
226+
227+
<pre>When your objective has been reached use this tool to set the task as complete.</pre>
228+
229+
**Parameters**
230+
231+
* `reason` <i>(str | None)</i>: Optional reason why the task is complete or report of conclusive information.
232+
### `task_failed`
233+
234+
<pre>Use this tool if you determine that the given goal or task is impossible given the information you have.</pre>
235+
236+
**Parameters**
237+
238+
* `reason` <i>(<class 'str'>)</i>: The reason why the task is impossible
100239
</details>
101240

102241
## time
@@ -105,9 +244,17 @@ Provides tools for getting the current date and time and waiting for a given num
105244

106245
<details>
107246
<summary><b>Show Tools</b></summary>
108-
| Tool | Description |
109-
|------|-------------|
110-
| `current_time_and_date` | <pre>Get the current date and time.</pre> |
111-
| `wait` | <pre>Wait for a given number of seconds.</pre> |
247+
248+
### `current_time_and_date`
249+
250+
<pre>Get the current date and time.</pre>
251+
252+
### `wait`
253+
254+
<pre>Wait for a given number of seconds.</pre>
255+
256+
**Parameters**
257+
258+
* `seconds` <i>(<class 'int'>)</i>: The number of seconds to wait
112259
</details>
113260

0 commit comments

Comments
 (0)