agents-function-tools 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {agents_function_tools-0.2.0/src/agents_function_tools.egg-info → agents_function_tools-0.3.0}/PKG-INFO +53 -20
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/README.md +52 -19
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/pyproject.toml +1 -1
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0/src/agents_function_tools.egg-info}/PKG-INFO +53 -20
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/agents_function_tools.egg-info/SOURCES.txt +1 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/__init__.py +6 -1
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/http.py +1 -1
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/openai_tools.py +25 -3
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/tests/test_openai_tools.py +11 -1
- agents_function_tools-0.3.0/tests/test_public_api.py +10 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/LICENSE +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/setup.cfg +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/agents_function_tools.egg-info/dependency_links.txt +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/agents_function_tools.egg-info/requires.txt +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/agents_function_tools.egg-info/top_level.txt +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/archive.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/command.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/errors.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/host.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/responses.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/workspace.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/tests/test_archive.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/tests/test_command.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/tests/test_host_and_http.py +0 -0
- {agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/tests/test_workspace.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agents-function-tools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Portable, policy-friendly system function tools for AI applications.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -18,16 +18,22 @@ Dynamic: license-file
|
|
|
18
18
|
|
|
19
19
|
`agents-function-tools` is a portable Python library of policy-friendly system function tools. It contains no business model, Agent routing, domain workflow, database adapter, or code-review logic. Its Python import name is `function_tools`.
|
|
20
20
|
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python -m pip install agents-function-tools
|
|
25
|
+
```
|
|
26
|
+
|
|
21
27
|
## Included tools
|
|
22
28
|
|
|
23
|
-
| Category | Tools |
|
|
29
|
+
| Category | Tools | Tool group |
|
|
24
30
|
|---|---|---|
|
|
25
|
-
| Workspace read | List, read UTF-8, inspect metadata, glob-style find, hash files, disk usage | `
|
|
26
|
-
| Workspace write | Write text, create directories, copy a regular file, move a path, delete a path | `
|
|
27
|
-
| ZIP | List archive entries; create and extract bounded ZIP archives | `
|
|
28
|
-
| Network | Fetch bounded HTTPS text from configured hosts | `
|
|
29
|
-
| Host | Non-sensitive system info, UTC time, explicitly allowlisted environment variables | `
|
|
30
|
-
| Commands | Describe configured aliases; run one allowlisted executable with `shell=False` | `
|
|
31
|
+
| Workspace read | List, read UTF-8, inspect metadata, glob-style find, hash files, disk usage | `read` |
|
|
32
|
+
| Workspace write | Write text, create directories, copy a regular file, move a path, delete a path | `write` |
|
|
33
|
+
| ZIP | List archive entries; create and extract bounded ZIP archives | `read` / `write` |
|
|
34
|
+
| Network | Fetch bounded HTTPS text from configured hosts | `read` |
|
|
35
|
+
| Host | Non-sensitive system info, UTC time, explicitly allowlisted environment variables | `read` |
|
|
36
|
+
| Commands | Describe configured aliases; run one allowlisted executable with `shell=False` | `read` / `execute` |
|
|
31
37
|
|
|
32
38
|
Every tool returns the same JSON envelope with `ok`, `tool`, `effect`, `data`, and `error` fields. Paths are always relative to a configured workspace root.
|
|
33
39
|
|
|
@@ -43,19 +49,39 @@ Every tool returns the same JSON envelope with `ok`, `tool`, `effect`, `data`, a
|
|
|
43
49
|
- Host diagnostics intentionally exclude user identities, process lists, network configuration, installed software, and environment variables except for names explicitly configured by the host.
|
|
44
50
|
- Command execution accepts an argument array, never a shell string. Programs must be mapped by the host application, execution has a timeout, and output is truncated.
|
|
45
51
|
- The local command runner is not an OS security sandbox. Production deployment must run the service or runner inside the company-approved container/sandbox with no production secrets and restricted network access.
|
|
46
|
-
- Approval remains the orchestration layer's responsibility. Only
|
|
52
|
+
- Approval remains the orchestration layer's responsibility. Only attach `tools.write` or `tools.execute` after the matching approval policy has been validated.
|
|
47
53
|
|
|
48
54
|
This is a controlled operating-system capability adapter, not a general shell, process-management, credential, service-control, or unrestricted-network interface. Give each business Agent only the smallest subset of these tools it needs.
|
|
49
55
|
|
|
50
56
|
## Example
|
|
51
57
|
|
|
58
|
+
```python
|
|
59
|
+
from pathlib import Path
|
|
60
|
+
|
|
61
|
+
from agents import Agent
|
|
62
|
+
|
|
63
|
+
from function_tools import create_tools
|
|
64
|
+
|
|
65
|
+
tools = create_tools(Path("./workspace"))
|
|
66
|
+
|
|
67
|
+
agent = Agent(
|
|
68
|
+
name="Workspace assistant",
|
|
69
|
+
instructions="Use workspace tools when needed.",
|
|
70
|
+
tools=list(tools.read),
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`tools.read` is read-only. `tools.write` and `tools.execute` require approval on every call. The SDK derives each FunctionTool's input schema from the Python signature and docstring.
|
|
75
|
+
|
|
76
|
+
For configured commands, HTTPS hosts, or readable environment variables, use `ToolConfig`:
|
|
77
|
+
|
|
52
78
|
```python
|
|
53
79
|
import sys
|
|
54
80
|
from pathlib import Path
|
|
55
81
|
|
|
56
|
-
from function_tools
|
|
82
|
+
from function_tools import ToolConfig, create_tools
|
|
57
83
|
|
|
58
|
-
|
|
84
|
+
tools = create_tools(
|
|
59
85
|
ToolConfig(
|
|
60
86
|
workspace_root=Path("./workspace"),
|
|
61
87
|
command_programs={"python": sys.executable},
|
|
@@ -63,17 +89,8 @@ bundle = create_function_tools(
|
|
|
63
89
|
environment_variables=frozenset({"APP_ENV"}),
|
|
64
90
|
)
|
|
65
91
|
)
|
|
66
|
-
|
|
67
|
-
# Safe tools can be attached to an Agent immediately.
|
|
68
|
-
safe_tools = list(bundle.safe_read)
|
|
69
|
-
|
|
70
|
-
# Select side-effect tools only after the policy and approval checks pass.
|
|
71
|
-
write_tools = list(bundle.workspace_write)
|
|
72
|
-
execution_tools = list(bundle.workspace_execution)
|
|
73
92
|
```
|
|
74
93
|
|
|
75
|
-
The SDK derives each FunctionTool's input schema from the Python signature and docstring. For production, keep the groups separate when attaching them to an Agent; do not use `bundle.all` by default.
|
|
76
|
-
|
|
77
94
|
## License
|
|
78
95
|
|
|
79
96
|
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -88,3 +105,19 @@ uv run --python 3.10 pytest
|
|
|
88
105
|
```
|
|
89
106
|
|
|
90
107
|
Tests do not call the OpenAI API and do not require `OPENAI_API_KEY`.
|
|
108
|
+
|
|
109
|
+
## Release acceptance
|
|
110
|
+
|
|
111
|
+
Before every PyPI release, run:
|
|
112
|
+
|
|
113
|
+
```powershell
|
|
114
|
+
uv run python scripts/release_check.py
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The gate checks the lockfile, formatting, linting, tests, wheel and source-distribution contents, package metadata, a clean `python -m pip install --no-deps <wheel>`, and a separate clean runtime installation with dependencies.
|
|
118
|
+
|
|
119
|
+
Use the following command to run that gate and publish only when it passes:
|
|
120
|
+
|
|
121
|
+
```powershell
|
|
122
|
+
uv run python scripts/publish.py
|
|
123
|
+
```
|
|
@@ -2,16 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
`agents-function-tools` is a portable Python library of policy-friendly system function tools. It contains no business model, Agent routing, domain workflow, database adapter, or code-review logic. Its Python import name is `function_tools`.
|
|
4
4
|
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m pip install agents-function-tools
|
|
9
|
+
```
|
|
10
|
+
|
|
5
11
|
## Included tools
|
|
6
12
|
|
|
7
|
-
| Category | Tools |
|
|
13
|
+
| Category | Tools | Tool group |
|
|
8
14
|
|---|---|---|
|
|
9
|
-
| Workspace read | List, read UTF-8, inspect metadata, glob-style find, hash files, disk usage | `
|
|
10
|
-
| Workspace write | Write text, create directories, copy a regular file, move a path, delete a path | `
|
|
11
|
-
| ZIP | List archive entries; create and extract bounded ZIP archives | `
|
|
12
|
-
| Network | Fetch bounded HTTPS text from configured hosts | `
|
|
13
|
-
| Host | Non-sensitive system info, UTC time, explicitly allowlisted environment variables | `
|
|
14
|
-
| Commands | Describe configured aliases; run one allowlisted executable with `shell=False` | `
|
|
15
|
+
| Workspace read | List, read UTF-8, inspect metadata, glob-style find, hash files, disk usage | `read` |
|
|
16
|
+
| Workspace write | Write text, create directories, copy a regular file, move a path, delete a path | `write` |
|
|
17
|
+
| ZIP | List archive entries; create and extract bounded ZIP archives | `read` / `write` |
|
|
18
|
+
| Network | Fetch bounded HTTPS text from configured hosts | `read` |
|
|
19
|
+
| Host | Non-sensitive system info, UTC time, explicitly allowlisted environment variables | `read` |
|
|
20
|
+
| Commands | Describe configured aliases; run one allowlisted executable with `shell=False` | `read` / `execute` |
|
|
15
21
|
|
|
16
22
|
Every tool returns the same JSON envelope with `ok`, `tool`, `effect`, `data`, and `error` fields. Paths are always relative to a configured workspace root.
|
|
17
23
|
|
|
@@ -27,19 +33,39 @@ Every tool returns the same JSON envelope with `ok`, `tool`, `effect`, `data`, a
|
|
|
27
33
|
- Host diagnostics intentionally exclude user identities, process lists, network configuration, installed software, and environment variables except for names explicitly configured by the host.
|
|
28
34
|
- Command execution accepts an argument array, never a shell string. Programs must be mapped by the host application, execution has a timeout, and output is truncated.
|
|
29
35
|
- The local command runner is not an OS security sandbox. Production deployment must run the service or runner inside the company-approved container/sandbox with no production secrets and restricted network access.
|
|
30
|
-
- Approval remains the orchestration layer's responsibility. Only
|
|
36
|
+
- Approval remains the orchestration layer's responsibility. Only attach `tools.write` or `tools.execute` after the matching approval policy has been validated.
|
|
31
37
|
|
|
32
38
|
This is a controlled operating-system capability adapter, not a general shell, process-management, credential, service-control, or unrestricted-network interface. Give each business Agent only the smallest subset of these tools it needs.
|
|
33
39
|
|
|
34
40
|
## Example
|
|
35
41
|
|
|
42
|
+
```python
|
|
43
|
+
from pathlib import Path
|
|
44
|
+
|
|
45
|
+
from agents import Agent
|
|
46
|
+
|
|
47
|
+
from function_tools import create_tools
|
|
48
|
+
|
|
49
|
+
tools = create_tools(Path("./workspace"))
|
|
50
|
+
|
|
51
|
+
agent = Agent(
|
|
52
|
+
name="Workspace assistant",
|
|
53
|
+
instructions="Use workspace tools when needed.",
|
|
54
|
+
tools=list(tools.read),
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`tools.read` is read-only. `tools.write` and `tools.execute` require approval on every call. The SDK derives each FunctionTool's input schema from the Python signature and docstring.
|
|
59
|
+
|
|
60
|
+
For configured commands, HTTPS hosts, or readable environment variables, use `ToolConfig`:
|
|
61
|
+
|
|
36
62
|
```python
|
|
37
63
|
import sys
|
|
38
64
|
from pathlib import Path
|
|
39
65
|
|
|
40
|
-
from function_tools
|
|
66
|
+
from function_tools import ToolConfig, create_tools
|
|
41
67
|
|
|
42
|
-
|
|
68
|
+
tools = create_tools(
|
|
43
69
|
ToolConfig(
|
|
44
70
|
workspace_root=Path("./workspace"),
|
|
45
71
|
command_programs={"python": sys.executable},
|
|
@@ -47,17 +73,8 @@ bundle = create_function_tools(
|
|
|
47
73
|
environment_variables=frozenset({"APP_ENV"}),
|
|
48
74
|
)
|
|
49
75
|
)
|
|
50
|
-
|
|
51
|
-
# Safe tools can be attached to an Agent immediately.
|
|
52
|
-
safe_tools = list(bundle.safe_read)
|
|
53
|
-
|
|
54
|
-
# Select side-effect tools only after the policy and approval checks pass.
|
|
55
|
-
write_tools = list(bundle.workspace_write)
|
|
56
|
-
execution_tools = list(bundle.workspace_execution)
|
|
57
76
|
```
|
|
58
77
|
|
|
59
|
-
The SDK derives each FunctionTool's input schema from the Python signature and docstring. For production, keep the groups separate when attaching them to an Agent; do not use `bundle.all` by default.
|
|
60
|
-
|
|
61
78
|
## License
|
|
62
79
|
|
|
63
80
|
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -72,3 +89,19 @@ uv run --python 3.10 pytest
|
|
|
72
89
|
```
|
|
73
90
|
|
|
74
91
|
Tests do not call the OpenAI API and do not require `OPENAI_API_KEY`.
|
|
92
|
+
|
|
93
|
+
## Release acceptance
|
|
94
|
+
|
|
95
|
+
Before every PyPI release, run:
|
|
96
|
+
|
|
97
|
+
```powershell
|
|
98
|
+
uv run python scripts/release_check.py
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The gate checks the lockfile, formatting, linting, tests, wheel and source-distribution contents, package metadata, a clean `python -m pip install --no-deps <wheel>`, and a separate clean runtime installation with dependencies.
|
|
102
|
+
|
|
103
|
+
Use the following command to run that gate and publish only when it passes:
|
|
104
|
+
|
|
105
|
+
```powershell
|
|
106
|
+
uv run python scripts/publish.py
|
|
107
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agents-function-tools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Portable, policy-friendly system function tools for AI applications.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -18,16 +18,22 @@ Dynamic: license-file
|
|
|
18
18
|
|
|
19
19
|
`agents-function-tools` is a portable Python library of policy-friendly system function tools. It contains no business model, Agent routing, domain workflow, database adapter, or code-review logic. Its Python import name is `function_tools`.
|
|
20
20
|
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python -m pip install agents-function-tools
|
|
25
|
+
```
|
|
26
|
+
|
|
21
27
|
## Included tools
|
|
22
28
|
|
|
23
|
-
| Category | Tools |
|
|
29
|
+
| Category | Tools | Tool group |
|
|
24
30
|
|---|---|---|
|
|
25
|
-
| Workspace read | List, read UTF-8, inspect metadata, glob-style find, hash files, disk usage | `
|
|
26
|
-
| Workspace write | Write text, create directories, copy a regular file, move a path, delete a path | `
|
|
27
|
-
| ZIP | List archive entries; create and extract bounded ZIP archives | `
|
|
28
|
-
| Network | Fetch bounded HTTPS text from configured hosts | `
|
|
29
|
-
| Host | Non-sensitive system info, UTC time, explicitly allowlisted environment variables | `
|
|
30
|
-
| Commands | Describe configured aliases; run one allowlisted executable with `shell=False` | `
|
|
31
|
+
| Workspace read | List, read UTF-8, inspect metadata, glob-style find, hash files, disk usage | `read` |
|
|
32
|
+
| Workspace write | Write text, create directories, copy a regular file, move a path, delete a path | `write` |
|
|
33
|
+
| ZIP | List archive entries; create and extract bounded ZIP archives | `read` / `write` |
|
|
34
|
+
| Network | Fetch bounded HTTPS text from configured hosts | `read` |
|
|
35
|
+
| Host | Non-sensitive system info, UTC time, explicitly allowlisted environment variables | `read` |
|
|
36
|
+
| Commands | Describe configured aliases; run one allowlisted executable with `shell=False` | `read` / `execute` |
|
|
31
37
|
|
|
32
38
|
Every tool returns the same JSON envelope with `ok`, `tool`, `effect`, `data`, and `error` fields. Paths are always relative to a configured workspace root.
|
|
33
39
|
|
|
@@ -43,19 +49,39 @@ Every tool returns the same JSON envelope with `ok`, `tool`, `effect`, `data`, a
|
|
|
43
49
|
- Host diagnostics intentionally exclude user identities, process lists, network configuration, installed software, and environment variables except for names explicitly configured by the host.
|
|
44
50
|
- Command execution accepts an argument array, never a shell string. Programs must be mapped by the host application, execution has a timeout, and output is truncated.
|
|
45
51
|
- The local command runner is not an OS security sandbox. Production deployment must run the service or runner inside the company-approved container/sandbox with no production secrets and restricted network access.
|
|
46
|
-
- Approval remains the orchestration layer's responsibility. Only
|
|
52
|
+
- Approval remains the orchestration layer's responsibility. Only attach `tools.write` or `tools.execute` after the matching approval policy has been validated.
|
|
47
53
|
|
|
48
54
|
This is a controlled operating-system capability adapter, not a general shell, process-management, credential, service-control, or unrestricted-network interface. Give each business Agent only the smallest subset of these tools it needs.
|
|
49
55
|
|
|
50
56
|
## Example
|
|
51
57
|
|
|
58
|
+
```python
|
|
59
|
+
from pathlib import Path
|
|
60
|
+
|
|
61
|
+
from agents import Agent
|
|
62
|
+
|
|
63
|
+
from function_tools import create_tools
|
|
64
|
+
|
|
65
|
+
tools = create_tools(Path("./workspace"))
|
|
66
|
+
|
|
67
|
+
agent = Agent(
|
|
68
|
+
name="Workspace assistant",
|
|
69
|
+
instructions="Use workspace tools when needed.",
|
|
70
|
+
tools=list(tools.read),
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`tools.read` is read-only. `tools.write` and `tools.execute` require approval on every call. The SDK derives each FunctionTool's input schema from the Python signature and docstring.
|
|
75
|
+
|
|
76
|
+
For configured commands, HTTPS hosts, or readable environment variables, use `ToolConfig`:
|
|
77
|
+
|
|
52
78
|
```python
|
|
53
79
|
import sys
|
|
54
80
|
from pathlib import Path
|
|
55
81
|
|
|
56
|
-
from function_tools
|
|
82
|
+
from function_tools import ToolConfig, create_tools
|
|
57
83
|
|
|
58
|
-
|
|
84
|
+
tools = create_tools(
|
|
59
85
|
ToolConfig(
|
|
60
86
|
workspace_root=Path("./workspace"),
|
|
61
87
|
command_programs={"python": sys.executable},
|
|
@@ -63,17 +89,8 @@ bundle = create_function_tools(
|
|
|
63
89
|
environment_variables=frozenset({"APP_ENV"}),
|
|
64
90
|
)
|
|
65
91
|
)
|
|
66
|
-
|
|
67
|
-
# Safe tools can be attached to an Agent immediately.
|
|
68
|
-
safe_tools = list(bundle.safe_read)
|
|
69
|
-
|
|
70
|
-
# Select side-effect tools only after the policy and approval checks pass.
|
|
71
|
-
write_tools = list(bundle.workspace_write)
|
|
72
|
-
execution_tools = list(bundle.workspace_execution)
|
|
73
92
|
```
|
|
74
93
|
|
|
75
|
-
The SDK derives each FunctionTool's input schema from the Python signature and docstring. For production, keep the groups separate when attaching them to an Agent; do not use `bundle.all` by default.
|
|
76
|
-
|
|
77
94
|
## License
|
|
78
95
|
|
|
79
96
|
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -88,3 +105,19 @@ uv run --python 3.10 pytest
|
|
|
88
105
|
```
|
|
89
106
|
|
|
90
107
|
Tests do not call the OpenAI API and do not require `OPENAI_API_KEY`.
|
|
108
|
+
|
|
109
|
+
## Release acceptance
|
|
110
|
+
|
|
111
|
+
Before every PyPI release, run:
|
|
112
|
+
|
|
113
|
+
```powershell
|
|
114
|
+
uv run python scripts/release_check.py
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The gate checks the lockfile, formatting, linting, tests, wheel and source-distribution contents, package metadata, a clean `python -m pip install --no-deps <wheel>`, and a separate clean runtime installation with dependencies.
|
|
118
|
+
|
|
119
|
+
Use the following command to run that gate and publish only when it passes:
|
|
120
|
+
|
|
121
|
+
```powershell
|
|
122
|
+
uv run python scripts/publish.py
|
|
123
|
+
```
|
|
@@ -5,17 +5,22 @@ from .command import CommandPolicy, LocalCommandRunner
|
|
|
5
5
|
from .errors import FoundationToolError
|
|
6
6
|
from .host import HostInspector
|
|
7
7
|
from .http import HttpPolicy, HttpTextClient
|
|
8
|
+
from .openai_tools import FunctionToolBundle, ToolConfig, create_function_tools, create_tools
|
|
8
9
|
from .workspace import Workspace
|
|
9
10
|
|
|
10
|
-
__version__ = "0.
|
|
11
|
+
__version__ = "0.3.0"
|
|
11
12
|
|
|
12
13
|
__all__ = [
|
|
13
14
|
"CommandPolicy",
|
|
14
15
|
"FoundationToolError",
|
|
16
|
+
"FunctionToolBundle",
|
|
15
17
|
"HostInspector",
|
|
16
18
|
"HttpPolicy",
|
|
17
19
|
"HttpTextClient",
|
|
18
20
|
"LocalCommandRunner",
|
|
21
|
+
"ToolConfig",
|
|
19
22
|
"Workspace",
|
|
20
23
|
"ZipArchive",
|
|
24
|
+
"create_function_tools",
|
|
25
|
+
"create_tools",
|
|
21
26
|
]
|
{agents_function_tools-0.2.0 → agents_function_tools-0.3.0}/src/function_tools/openai_tools.py
RENAMED
|
@@ -18,7 +18,7 @@ from .workspace import Workspace
|
|
|
18
18
|
|
|
19
19
|
@dataclass(frozen=True)
|
|
20
20
|
class ToolConfig:
|
|
21
|
-
workspace_root: Path
|
|
21
|
+
workspace_root: Path | str
|
|
22
22
|
command_programs: Mapping[str, str] = field(default_factory=dict)
|
|
23
23
|
max_read_bytes: int = 1_000_000
|
|
24
24
|
max_write_bytes: int = 1_000_000
|
|
@@ -39,8 +39,30 @@ class FunctionToolBundle:
|
|
|
39
39
|
workspace_execution: tuple[Any, ...]
|
|
40
40
|
|
|
41
41
|
@property
|
|
42
|
-
def
|
|
43
|
-
|
|
42
|
+
def read(self) -> tuple[Any, ...]:
|
|
43
|
+
"""Read-only tools that can be attached without an approval request."""
|
|
44
|
+
|
|
45
|
+
return self.safe_read
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def write(self) -> tuple[Any, ...]:
|
|
49
|
+
"""Workspace-mutating tools that require approval for every call."""
|
|
50
|
+
|
|
51
|
+
return self.workspace_write
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def execute(self) -> tuple[Any, ...]:
|
|
55
|
+
"""Local command tools that require approval for every call."""
|
|
56
|
+
|
|
57
|
+
return self.workspace_execution
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def create_tools(config: ToolConfig | Path | str) -> FunctionToolBundle:
|
|
61
|
+
"""Create tools from a full policy config or a workspace path with safe defaults."""
|
|
62
|
+
|
|
63
|
+
if not isinstance(config, ToolConfig):
|
|
64
|
+
config = ToolConfig(workspace_root=config)
|
|
65
|
+
return create_function_tools(config)
|
|
44
66
|
|
|
45
67
|
|
|
46
68
|
def create_function_tools(config: ToolConfig) -> FunctionToolBundle:
|
|
@@ -6,7 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
|
|
7
7
|
from agents.tool_context import ToolContext
|
|
8
8
|
|
|
9
|
-
from function_tools
|
|
9
|
+
from function_tools import ToolConfig, create_function_tools, create_tools
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def test_sdk_tools_are_grouped_by_effect(tmp_path: Path) -> None:
|
|
@@ -38,6 +38,16 @@ def test_sdk_tools_are_grouped_by_effect(tmp_path: Path) -> None:
|
|
|
38
38
|
assert {tool.name for tool in bundle.workspace_execution} == {"run_local_command"}
|
|
39
39
|
assert all(tool.needs_approval is True for tool in bundle.workspace_write)
|
|
40
40
|
assert all(tool.needs_approval is True for tool in bundle.workspace_execution)
|
|
41
|
+
assert bundle.read == bundle.safe_read
|
|
42
|
+
assert bundle.write == bundle.workspace_write
|
|
43
|
+
assert bundle.execute == bundle.workspace_execution
|
|
44
|
+
assert not hasattr(bundle, "all")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_create_tools_accepts_a_workspace_path(tmp_path: Path) -> None:
|
|
48
|
+
bundle = create_tools(tmp_path)
|
|
49
|
+
|
|
50
|
+
assert bundle.read
|
|
41
51
|
|
|
42
52
|
|
|
43
53
|
def test_tool_error_uses_standard_response(tmp_path: Path) -> None:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import function_tools
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_top_level_api_exposes_the_quick_start() -> None:
|
|
7
|
+
assert function_tools.__version__ == "0.3.0"
|
|
8
|
+
assert callable(function_tools.create_tools)
|
|
9
|
+
assert callable(function_tools.create_function_tools)
|
|
10
|
+
assert function_tools.ToolConfig.__name__ == "ToolConfig"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|