basic-open-agent-tools 0.7.2__tar.gz → 0.7.4__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.
- {basic_open_agent_tools-0.7.2/src/basic_open_agent_tools.egg-info → basic_open_agent_tools-0.7.4}/PKG-INFO +1 -1
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/pyproject.toml +1 -1
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/__init__.py +1 -5
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/data/__init__.py +0 -18
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/data/config_processing.py +18 -47
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/data/json_tools.py +7 -7
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/data/validation.py +10 -10
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/file_system/operations.py +1 -1
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/helpers.py +0 -141
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4/src/basic_open_agent_tools.egg-info}/PKG-INFO +1 -1
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools.egg-info/SOURCES.txt +0 -2
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/tests/test_data_config_processing.py +4 -5
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/tests/test_data_json_tools.py +7 -7
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/tests/test_helpers.py +1 -0
- basic_open_agent_tools-0.7.4/tests/test_read_only_tools.py +0 -0
- basic_open_agent_tools-0.7.2/src/basic_open_agent_tools/data/transform.py +0 -655
- basic_open_agent_tools-0.7.2/tests/test_data_transform.py +0 -295
- basic_open_agent_tools-0.7.2/tests/test_read_only_tools.py +0 -127
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/LICENSE +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/README.md +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/setup.cfg +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/setup.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/crypto/__init__.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/data/csv_tools.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/exceptions.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/file_system/__init__.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/file_system/info.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/file_system/tree.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/file_system/validation.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/network/__init__.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/system/__init__.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/text/__init__.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/text/processing.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/types.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/utilities/__init__.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools.egg-info/dependency_links.txt +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools.egg-info/requires.txt +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools.egg-info/top_level.txt +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/tests/test_data_csv_tools.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/tests/test_data_validation.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/tests/test_file_system_tools.py +0 -0
- {basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/tests/test_text_processing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: basic-open-agent-tools
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.4
|
|
4
4
|
Summary: An open foundational toolkit providing essential components for building AI agents with minimal dependencies for local (non-HTTP/API) actions.
|
|
5
5
|
Home-page: https://github.com/open-agent-tools/basic-open-agent-tools
|
|
6
6
|
Author: Open Agent Tools
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "basic-open-agent-tools"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.4" # Clean up module structure and remove transform functionality
|
|
8
8
|
description = "An open foundational toolkit providing essential components for building AI agents with minimal dependencies for local (non-HTTP/API) actions."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
{basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/__init__.py
RENAMED
|
@@ -6,7 +6,7 @@ with minimal dependencies for local (non-HTTP/API) actions.
|
|
|
6
6
|
|
|
7
7
|
from typing import List
|
|
8
8
|
|
|
9
|
-
__version__ = "0.7.
|
|
9
|
+
__version__ = "0.7.4"
|
|
10
10
|
|
|
11
11
|
# Modular structure
|
|
12
12
|
from . import data, exceptions, file_system, text, types
|
|
@@ -17,12 +17,10 @@ from .helpers import (
|
|
|
17
17
|
list_all_available_tools,
|
|
18
18
|
load_all_data_tools,
|
|
19
19
|
load_all_filesystem_tools,
|
|
20
|
-
load_all_read_only_tools,
|
|
21
20
|
load_all_text_tools,
|
|
22
21
|
load_data_config_tools,
|
|
23
22
|
load_data_csv_tools,
|
|
24
23
|
load_data_json_tools,
|
|
25
|
-
load_data_transformation_tools,
|
|
26
24
|
load_data_validation_tools,
|
|
27
25
|
merge_tool_lists,
|
|
28
26
|
)
|
|
@@ -51,11 +49,9 @@ __all__: List[str] = [
|
|
|
51
49
|
"load_all_filesystem_tools",
|
|
52
50
|
"load_all_text_tools",
|
|
53
51
|
"load_all_data_tools",
|
|
54
|
-
"load_all_read_only_tools",
|
|
55
52
|
"load_data_json_tools",
|
|
56
53
|
"load_data_csv_tools",
|
|
57
54
|
"load_data_validation_tools",
|
|
58
|
-
"load_data_transformation_tools",
|
|
59
55
|
"load_data_config_tools",
|
|
60
56
|
"merge_tool_lists",
|
|
61
57
|
"get_tool_info",
|
|
@@ -5,7 +5,6 @@ This module provides data processing and manipulation tools organized into logic
|
|
|
5
5
|
- json_tools: JSON serialization, compression, and validation
|
|
6
6
|
- csv_tools: CSV file processing, parsing, and cleaning
|
|
7
7
|
- validation: Data validation and schema checking
|
|
8
|
-
- transform: Data transformation, cleaning, and normalization
|
|
9
8
|
- config_processing: Configuration file processing (YAML, TOML, INI)
|
|
10
9
|
"""
|
|
11
10
|
|
|
@@ -38,15 +37,6 @@ from .json_tools import (
|
|
|
38
37
|
safe_json_serialize,
|
|
39
38
|
validate_json_string,
|
|
40
39
|
)
|
|
41
|
-
from .transform import (
|
|
42
|
-
clean_data,
|
|
43
|
-
convert_data_types,
|
|
44
|
-
deduplicate_records,
|
|
45
|
-
normalize_data,
|
|
46
|
-
pivot_data,
|
|
47
|
-
rename_fields,
|
|
48
|
-
transform_data,
|
|
49
|
-
)
|
|
50
40
|
from .validation import (
|
|
51
41
|
check_required_fields,
|
|
52
42
|
create_validation_report,
|
|
@@ -71,14 +61,6 @@ __all__: List[str] = [
|
|
|
71
61
|
"detect_csv_delimiter",
|
|
72
62
|
"validate_csv_structure",
|
|
73
63
|
"clean_csv_data",
|
|
74
|
-
# Data transformation
|
|
75
|
-
"transform_data",
|
|
76
|
-
"rename_fields",
|
|
77
|
-
"convert_data_types",
|
|
78
|
-
"clean_data",
|
|
79
|
-
"deduplicate_records",
|
|
80
|
-
"normalize_data",
|
|
81
|
-
"pivot_data",
|
|
82
64
|
# Validation
|
|
83
65
|
"validate_schema_simple",
|
|
84
66
|
"check_required_fields",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import configparser
|
|
4
4
|
import json
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import List, Union
|
|
6
6
|
|
|
7
7
|
from ..exceptions import DataError
|
|
8
8
|
|
|
@@ -102,7 +102,7 @@ def read_toml_file(file_path: str) -> dict:
|
|
|
102
102
|
|
|
103
103
|
try:
|
|
104
104
|
with open(file_path, "rb") as f:
|
|
105
|
-
result:
|
|
105
|
+
result: dict = tomli.load(f)
|
|
106
106
|
return result
|
|
107
107
|
except FileNotFoundError:
|
|
108
108
|
raise FileNotFoundError(f"TOML file not found: {file_path}")
|
|
@@ -262,12 +262,12 @@ def validate_config_schema(config_data: dict, schema: dict) -> list:
|
|
|
262
262
|
return errors
|
|
263
263
|
|
|
264
264
|
|
|
265
|
-
def merge_config_files(
|
|
265
|
+
def merge_config_files(config_paths: Union[str, List[str]], format_type: str) -> dict:
|
|
266
266
|
"""Merge multiple configuration files into a single dictionary.
|
|
267
267
|
|
|
268
268
|
Args:
|
|
269
|
-
|
|
270
|
-
format_type: Format of the files ("yaml", "toml", "ini", or
|
|
269
|
+
config_paths: Paths to configuration files (either a single path or list of paths)
|
|
270
|
+
format_type: Format of the files ("yaml", "toml", "ini", or "json")
|
|
271
271
|
|
|
272
272
|
Returns:
|
|
273
273
|
Merged configuration dictionary
|
|
@@ -277,58 +277,29 @@ def merge_config_files(*config_paths: Any, format_type: Optional[str] = None) ->
|
|
|
277
277
|
DataError: If files cannot be read or merged
|
|
278
278
|
|
|
279
279
|
Example:
|
|
280
|
-
>>> merge_config_files("base.yaml", "override.yaml",
|
|
281
|
-
{"database": {"host": "override-host", "port": 5432}}
|
|
282
|
-
>>> merge_config_files(["base.yaml", "override.yaml"], format_type="yaml")
|
|
280
|
+
>>> merge_config_files(["base.yaml", "override.yaml"], "yaml")
|
|
283
281
|
{"database": {"host": "override-host", "port": 5432}}
|
|
282
|
+
>>> merge_config_files("single.yaml", "yaml")
|
|
283
|
+
{"database": {"host": "localhost", "port": 5432}}
|
|
284
284
|
"""
|
|
285
|
-
# Handle both
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
paths = config_paths[0]
|
|
285
|
+
# Handle both single string and list input
|
|
286
|
+
if isinstance(config_paths, str):
|
|
287
|
+
paths = [config_paths]
|
|
289
288
|
else:
|
|
290
|
-
paths =
|
|
289
|
+
paths = config_paths
|
|
291
290
|
|
|
292
291
|
if not paths:
|
|
293
292
|
raise ValueError("No configuration files provided")
|
|
294
293
|
|
|
295
|
-
#
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if path.endswith((".yml", ".yaml")):
|
|
300
|
-
detected_formats.add("yaml")
|
|
301
|
-
elif path.endswith(".toml"):
|
|
302
|
-
detected_formats.add("toml")
|
|
303
|
-
elif path.endswith(".ini"):
|
|
304
|
-
detected_formats.add("ini")
|
|
305
|
-
elif path.endswith(".json"):
|
|
306
|
-
detected_formats.add("json")
|
|
307
|
-
else:
|
|
308
|
-
raise DataError(f"Cannot determine format for file: {path}")
|
|
309
|
-
|
|
310
|
-
if len(detected_formats) > 1:
|
|
311
|
-
raise DataError(
|
|
312
|
-
f"Cannot merge files with different formats: {detected_formats}"
|
|
313
|
-
)
|
|
294
|
+
# Validate format_type
|
|
295
|
+
valid_formats = ["yaml", "toml", "ini", "json"]
|
|
296
|
+
if format_type not in valid_formats:
|
|
297
|
+
raise ValueError(f"format_type must be one of {valid_formats}")
|
|
314
298
|
|
|
315
|
-
merged_config:
|
|
299
|
+
merged_config: dict = {}
|
|
316
300
|
|
|
317
301
|
for config_path in paths:
|
|
318
|
-
|
|
319
|
-
if format_type is None:
|
|
320
|
-
if config_path.endswith((".yml", ".yaml")):
|
|
321
|
-
file_format = "yaml"
|
|
322
|
-
elif config_path.endswith(".toml"):
|
|
323
|
-
file_format = "toml"
|
|
324
|
-
elif config_path.endswith(".ini"):
|
|
325
|
-
file_format = "ini"
|
|
326
|
-
elif config_path.endswith(".json"):
|
|
327
|
-
file_format = "json"
|
|
328
|
-
else:
|
|
329
|
-
raise DataError(f"Cannot determine format for file: {config_path}")
|
|
330
|
-
else:
|
|
331
|
-
file_format = format_type
|
|
302
|
+
file_format = format_type
|
|
332
303
|
|
|
333
304
|
# Read the file
|
|
334
305
|
if file_format == "yaml":
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import gzip
|
|
4
4
|
import json
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import Union, cast
|
|
6
6
|
|
|
7
7
|
from ..exceptions import SerializationError
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def safe_json_serialize(data: dict, indent: int
|
|
10
|
+
def safe_json_serialize(data: Union[dict, list, str, int, float, bool], indent: int) -> str:
|
|
11
11
|
"""Safely serialize data to JSON string with error handling.
|
|
12
12
|
|
|
13
13
|
Args:
|
|
@@ -38,7 +38,7 @@ def safe_json_serialize(data: dict, indent: int = 0) -> str:
|
|
|
38
38
|
raise SerializationError(f"Failed to serialize data to JSON: {e}")
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
def safe_json_deserialize(json_str: str) ->
|
|
41
|
+
def safe_json_deserialize(json_str: str) -> Union[dict, list, str, int, float, bool, None]:
|
|
42
42
|
"""Safely deserialize JSON string to Python object with error handling.
|
|
43
43
|
|
|
44
44
|
Args:
|
|
@@ -61,7 +61,7 @@ def safe_json_deserialize(json_str: str) -> Any:
|
|
|
61
61
|
raise TypeError("Input must be a string")
|
|
62
62
|
|
|
63
63
|
try:
|
|
64
|
-
return json.loads(json_str)
|
|
64
|
+
return cast(Union[dict, list, str, int, float, bool, None], json.loads(json_str))
|
|
65
65
|
except (json.JSONDecodeError, ValueError) as e:
|
|
66
66
|
raise SerializationError(f"Failed to deserialize JSON string: {e}")
|
|
67
67
|
|
|
@@ -91,7 +91,7 @@ def validate_json_string(json_str: str) -> bool:
|
|
|
91
91
|
return False
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
def compress_json_data(data:
|
|
94
|
+
def compress_json_data(data: Union[dict, list, str, int, float, bool]) -> bytes:
|
|
95
95
|
"""Compress JSON data for storage or transmission.
|
|
96
96
|
|
|
97
97
|
Args:
|
|
@@ -110,13 +110,13 @@ def compress_json_data(data: Any) -> bytes:
|
|
|
110
110
|
True
|
|
111
111
|
"""
|
|
112
112
|
try:
|
|
113
|
-
json_str = safe_json_serialize(data)
|
|
113
|
+
json_str = safe_json_serialize(data, 0)
|
|
114
114
|
return gzip.compress(json_str.encode("utf-8"))
|
|
115
115
|
except Exception as e:
|
|
116
116
|
raise SerializationError(f"Failed to compress JSON data: {e}")
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
def decompress_json_data(compressed_data: bytes) ->
|
|
119
|
+
def decompress_json_data(compressed_data: bytes) -> Union[dict, list, str, int, float, bool, None]:
|
|
120
120
|
"""Decompress and deserialize JSON data.
|
|
121
121
|
|
|
122
122
|
Args:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"""Data validation utilities for AI agents."""
|
|
2
2
|
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import Dict, List, Optional, Union
|
|
4
4
|
|
|
5
5
|
from ..exceptions import ValidationError
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def validate_schema_simple(data:
|
|
8
|
+
def validate_schema_simple(data: Union[dict, list, str, int, float, bool], schema: dict) -> bool:
|
|
9
9
|
"""Validate data against a JSON Schema-style schema.
|
|
10
10
|
|
|
11
11
|
Args:
|
|
@@ -34,7 +34,7 @@ def validate_schema_simple(data: Any, schema: Dict[str, Any]) -> bool:
|
|
|
34
34
|
raise
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def _validate_against_schema(data:
|
|
37
|
+
def _validate_against_schema(data: Union[dict, list, str, int, float, bool], schema: dict) -> None:
|
|
38
38
|
"""Internal helper to validate data against schema."""
|
|
39
39
|
schema_type = schema.get("type")
|
|
40
40
|
|
|
@@ -88,7 +88,7 @@ def _validate_against_schema(data: Any, schema: Dict[str, Any]) -> None:
|
|
|
88
88
|
raise ValidationError(f"Expected null, got {type(data).__name__}")
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
def check_required_fields(data:
|
|
91
|
+
def check_required_fields(data: dict, required: List[str]) -> bool:
|
|
92
92
|
"""Check if all required fields are present in data.
|
|
93
93
|
|
|
94
94
|
Args:
|
|
@@ -122,7 +122,7 @@ def check_required_fields(data: Dict[str, Any], required: List[str]) -> bool:
|
|
|
122
122
|
return True
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
def validate_data_types_simple(data:
|
|
125
|
+
def validate_data_types_simple(data: dict, type_map: Dict[str, str]) -> bool:
|
|
126
126
|
"""Check that field types match expectations.
|
|
127
127
|
|
|
128
128
|
Args:
|
|
@@ -219,8 +219,8 @@ def validate_range_simple(
|
|
|
219
219
|
|
|
220
220
|
|
|
221
221
|
def create_validation_report(
|
|
222
|
-
data:
|
|
223
|
-
) ->
|
|
222
|
+
data: dict, rules: dict
|
|
223
|
+
) -> dict:
|
|
224
224
|
"""Create comprehensive validation report for data.
|
|
225
225
|
|
|
226
226
|
Args:
|
|
@@ -303,7 +303,7 @@ def create_validation_report(
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
|
|
306
|
-
def check_required_fields_simple(data:
|
|
306
|
+
def check_required_fields_simple(data: dict, required: List[str]) -> bool:
|
|
307
307
|
"""Check if all required fields are present in data.
|
|
308
308
|
|
|
309
309
|
This is an alias for check_required_fields for LLM agent compatibility.
|
|
@@ -327,8 +327,8 @@ def check_required_fields_simple(data: Dict[str, Any], required: List[str]) -> b
|
|
|
327
327
|
|
|
328
328
|
|
|
329
329
|
def create_validation_report_simple(
|
|
330
|
-
data:
|
|
331
|
-
) ->
|
|
330
|
+
data: dict, rules: dict
|
|
331
|
+
) -> dict:
|
|
332
332
|
"""Create simplified validation report for data.
|
|
333
333
|
|
|
334
334
|
This is an alias for create_validation_report for LLM agent compatibility.
|
|
@@ -150,7 +150,7 @@ def delete_file(file_path: str) -> bool:
|
|
|
150
150
|
raise FileSystemError(f"Failed to delete file {path}: {e}")
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
def delete_directory(directory_path: str, recursive: bool
|
|
153
|
+
def delete_directory(directory_path: str, recursive: bool) -> bool:
|
|
154
154
|
"""Delete a directory.
|
|
155
155
|
|
|
156
156
|
Args:
|
{basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/src/basic_open_agent_tools/helpers.py
RENAMED
|
@@ -166,36 +166,6 @@ def load_data_validation_tools() -> List[Callable[..., Any]]:
|
|
|
166
166
|
return tools
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
def load_data_transformation_tools() -> List[Callable[..., Any]]:
|
|
170
|
-
"""Load data transformation tools as a list of callable functions.
|
|
171
|
-
|
|
172
|
-
Returns:
|
|
173
|
-
List of data transformation tool functions
|
|
174
|
-
|
|
175
|
-
Example:
|
|
176
|
-
>>> transform_tools = load_data_transformation_tools()
|
|
177
|
-
>>> len(transform_tools) == 7
|
|
178
|
-
True
|
|
179
|
-
"""
|
|
180
|
-
from .data import transform
|
|
181
|
-
|
|
182
|
-
tools = []
|
|
183
|
-
transform_function_names = [
|
|
184
|
-
"transform_data",
|
|
185
|
-
"rename_fields",
|
|
186
|
-
"convert_data_types",
|
|
187
|
-
"clean_data",
|
|
188
|
-
"deduplicate_records",
|
|
189
|
-
"normalize_data",
|
|
190
|
-
"pivot_data",
|
|
191
|
-
]
|
|
192
|
-
|
|
193
|
-
for name in transform_function_names:
|
|
194
|
-
func = getattr(transform, name)
|
|
195
|
-
if callable(func):
|
|
196
|
-
tools.append(func)
|
|
197
|
-
|
|
198
|
-
return tools
|
|
199
169
|
|
|
200
170
|
|
|
201
171
|
|
|
@@ -320,116 +290,6 @@ def get_tool_info(tool: Callable[..., Any]) -> Dict[str, Any]:
|
|
|
320
290
|
}
|
|
321
291
|
|
|
322
292
|
|
|
323
|
-
def load_all_read_only_tools() -> List[Callable[..., Any]]:
|
|
324
|
-
"""Load all read-only tools (non-destructive operations) from all modules.
|
|
325
|
-
|
|
326
|
-
This function returns tools that only read, analyze, validate, or transform data
|
|
327
|
-
without modifying files, creating new files, or performing destructive operations.
|
|
328
|
-
Perfect for agents that need to analyze and process information safely.
|
|
329
|
-
|
|
330
|
-
Returns:
|
|
331
|
-
List of all read-only tool functions from file_system, data, and text modules
|
|
332
|
-
|
|
333
|
-
Example:
|
|
334
|
-
>>> read_only_tools = load_all_read_only_tools()
|
|
335
|
-
>>> len(read_only_tools) > 35 # Should have 35+ read-only tools
|
|
336
|
-
True
|
|
337
|
-
"""
|
|
338
|
-
tools = []
|
|
339
|
-
|
|
340
|
-
# File System Read-Only Tools (11 tools)
|
|
341
|
-
fs_read_only = [
|
|
342
|
-
"file_exists",
|
|
343
|
-
"directory_exists",
|
|
344
|
-
"get_file_info",
|
|
345
|
-
"get_file_size",
|
|
346
|
-
"is_empty_directory",
|
|
347
|
-
"read_file_to_string",
|
|
348
|
-
"list_directory_contents",
|
|
349
|
-
"list_all_directory_contents",
|
|
350
|
-
"generate_directory_tree",
|
|
351
|
-
"validate_path",
|
|
352
|
-
"validate_file_content",
|
|
353
|
-
]
|
|
354
|
-
|
|
355
|
-
for name in fs_read_only:
|
|
356
|
-
func = getattr(file_system, name)
|
|
357
|
-
if callable(func):
|
|
358
|
-
tools.append(func)
|
|
359
|
-
|
|
360
|
-
# Text Processing Tools (10 tools - ALL are read-only)
|
|
361
|
-
tools.extend(load_all_text_tools())
|
|
362
|
-
|
|
363
|
-
# Data Read-Only Tools (21 tools)
|
|
364
|
-
from .data import (
|
|
365
|
-
config_processing,
|
|
366
|
-
csv_tools,
|
|
367
|
-
json_tools,
|
|
368
|
-
transform,
|
|
369
|
-
validation,
|
|
370
|
-
)
|
|
371
|
-
|
|
372
|
-
# JSON read-only tools (2)
|
|
373
|
-
data_json_read_only = ["safe_json_deserialize", "validate_json_string"]
|
|
374
|
-
for name in data_json_read_only:
|
|
375
|
-
func = getattr(json_tools, name)
|
|
376
|
-
if callable(func):
|
|
377
|
-
tools.append(func)
|
|
378
|
-
|
|
379
|
-
# CSV read-only tools (4)
|
|
380
|
-
data_csv_read_only = [
|
|
381
|
-
"read_csv_simple",
|
|
382
|
-
"csv_to_dict_list",
|
|
383
|
-
"detect_csv_delimiter",
|
|
384
|
-
"validate_csv_structure",
|
|
385
|
-
]
|
|
386
|
-
for name in data_csv_read_only:
|
|
387
|
-
func = getattr(csv_tools, name)
|
|
388
|
-
if callable(func):
|
|
389
|
-
tools.append(func)
|
|
390
|
-
|
|
391
|
-
# Config read-only tools (4)
|
|
392
|
-
data_config_read_only = [
|
|
393
|
-
"read_yaml_file",
|
|
394
|
-
"read_toml_file",
|
|
395
|
-
"read_ini_file",
|
|
396
|
-
"validate_config_schema",
|
|
397
|
-
]
|
|
398
|
-
for name in data_config_read_only:
|
|
399
|
-
func = getattr(config_processing, name)
|
|
400
|
-
if callable(func):
|
|
401
|
-
tools.append(func)
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
# Validation tools (5 - ALL are read-only)
|
|
407
|
-
data_validation_read_only = [
|
|
408
|
-
"validate_schema_simple",
|
|
409
|
-
"check_required_fields",
|
|
410
|
-
"validate_data_types_simple",
|
|
411
|
-
"validate_range_simple",
|
|
412
|
-
"create_validation_report",
|
|
413
|
-
]
|
|
414
|
-
for name in data_validation_read_only:
|
|
415
|
-
func = getattr(validation, name)
|
|
416
|
-
if callable(func):
|
|
417
|
-
tools.append(func)
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
# Transform read-only tools (4 - analysis/cleaning without modification)
|
|
421
|
-
data_transform_read_only = [
|
|
422
|
-
"clean_data",
|
|
423
|
-
"deduplicate_records",
|
|
424
|
-
"normalize_data",
|
|
425
|
-
"convert_data_types",
|
|
426
|
-
]
|
|
427
|
-
for name in data_transform_read_only:
|
|
428
|
-
func = getattr(transform, name)
|
|
429
|
-
if callable(func):
|
|
430
|
-
tools.append(func)
|
|
431
|
-
|
|
432
|
-
return tools
|
|
433
293
|
|
|
434
294
|
|
|
435
295
|
def list_all_available_tools() -> Dict[str, List[Dict[str, Any]]]:
|
|
@@ -449,5 +309,4 @@ def list_all_available_tools() -> Dict[str, List[Dict[str, Any]]]:
|
|
|
449
309
|
"file_system": [get_tool_info(tool) for tool in load_all_filesystem_tools()],
|
|
450
310
|
"text": [get_tool_info(tool) for tool in load_all_text_tools()],
|
|
451
311
|
"data": [get_tool_info(tool) for tool in load_all_data_tools()],
|
|
452
|
-
"read_only": [get_tool_info(tool) for tool in load_all_read_only_tools()],
|
|
453
312
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: basic-open-agent-tools
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.4
|
|
4
4
|
Summary: An open foundational toolkit providing essential components for building AI agents with minimal dependencies for local (non-HTTP/API) actions.
|
|
5
5
|
Home-page: https://github.com/open-agent-tools/basic-open-agent-tools
|
|
6
6
|
Author: Open Agent Tools
|
|
@@ -16,7 +16,6 @@ src/basic_open_agent_tools/data/__init__.py
|
|
|
16
16
|
src/basic_open_agent_tools/data/config_processing.py
|
|
17
17
|
src/basic_open_agent_tools/data/csv_tools.py
|
|
18
18
|
src/basic_open_agent_tools/data/json_tools.py
|
|
19
|
-
src/basic_open_agent_tools/data/transform.py
|
|
20
19
|
src/basic_open_agent_tools/data/validation.py
|
|
21
20
|
src/basic_open_agent_tools/file_system/__init__.py
|
|
22
21
|
src/basic_open_agent_tools/file_system/info.py
|
|
@@ -31,7 +30,6 @@ src/basic_open_agent_tools/utilities/__init__.py
|
|
|
31
30
|
tests/test_data_config_processing.py
|
|
32
31
|
tests/test_data_csv_tools.py
|
|
33
32
|
tests/test_data_json_tools.py
|
|
34
|
-
tests/test_data_transform.py
|
|
35
33
|
tests/test_data_validation.py
|
|
36
34
|
tests/test_file_system_tools.py
|
|
37
35
|
tests/test_helpers.py
|
{basic_open_agent_tools-0.7.2 → basic_open_agent_tools-0.7.4}/tests/test_data_config_processing.py
RENAMED
|
@@ -12,7 +12,6 @@ from basic_open_agent_tools.data.config_processing import (
|
|
|
12
12
|
validate_config_schema,
|
|
13
13
|
write_ini_file,
|
|
14
14
|
)
|
|
15
|
-
from basic_open_agent_tools.exceptions import DataError
|
|
16
15
|
|
|
17
16
|
# Import optional dependencies if available
|
|
18
17
|
try:
|
|
@@ -229,7 +228,7 @@ class TestMergeConfigFiles:
|
|
|
229
228
|
write_ini_file(config2, temp2_path)
|
|
230
229
|
|
|
231
230
|
# Merge configs
|
|
232
|
-
merged = merge_config_files(temp1_path, temp2_path)
|
|
231
|
+
merged = merge_config_files([temp1_path, temp2_path], "ini")
|
|
233
232
|
|
|
234
233
|
# Verify
|
|
235
234
|
assert merged["server"]["host"] == "localhost"
|
|
@@ -247,7 +246,7 @@ class TestMergeConfigFiles:
|
|
|
247
246
|
def test_merge_config_files_no_paths(self):
|
|
248
247
|
"""Test merging with no config paths."""
|
|
249
248
|
with pytest.raises(ValueError):
|
|
250
|
-
merge_config_files()
|
|
249
|
+
merge_config_files([], "ini")
|
|
251
250
|
|
|
252
251
|
def test_merge_config_files_mixed_formats(self):
|
|
253
252
|
"""Test merging files with different formats."""
|
|
@@ -263,8 +262,8 @@ class TestMergeConfigFiles:
|
|
|
263
262
|
write_ini_file(config, temp1_path)
|
|
264
263
|
|
|
265
264
|
# Try to merge different formats
|
|
266
|
-
with pytest.raises(
|
|
267
|
-
merge_config_files(temp1_path, temp2_path)
|
|
265
|
+
with pytest.raises(ValueError): # Now raises ValueError for invalid format
|
|
266
|
+
merge_config_files([temp1_path, temp2_path], "invalid_format")
|
|
268
267
|
|
|
269
268
|
finally:
|
|
270
269
|
# Clean up
|
|
@@ -18,13 +18,13 @@ class TestSafeJsonSerialize:
|
|
|
18
18
|
def test_serialize_dict(self):
|
|
19
19
|
"""Test serializing a dictionary."""
|
|
20
20
|
data = {"name": "test", "value": 42}
|
|
21
|
-
result = safe_json_serialize(data)
|
|
21
|
+
result = safe_json_serialize(data, 0)
|
|
22
22
|
assert result == '{"name": "test", "value": 42}'
|
|
23
23
|
|
|
24
24
|
def test_serialize_list(self):
|
|
25
25
|
"""Test serializing a list."""
|
|
26
26
|
data = [1, 2, 3]
|
|
27
|
-
result = safe_json_serialize(data)
|
|
27
|
+
result = safe_json_serialize(data, 0)
|
|
28
28
|
assert result == "[1, 2, 3]"
|
|
29
29
|
|
|
30
30
|
def test_serialize_with_indent(self):
|
|
@@ -37,12 +37,12 @@ class TestSafeJsonSerialize:
|
|
|
37
37
|
def test_serialize_unicode(self):
|
|
38
38
|
"""Test serializing Unicode characters."""
|
|
39
39
|
data = {"message": "Hello 世界"}
|
|
40
|
-
result = safe_json_serialize(data)
|
|
40
|
+
result = safe_json_serialize(data, 0)
|
|
41
41
|
assert "世界" in result
|
|
42
42
|
|
|
43
43
|
def test_serialize_none(self):
|
|
44
44
|
"""Test serializing None."""
|
|
45
|
-
result = safe_json_serialize(None)
|
|
45
|
+
result = safe_json_serialize(None, 0)
|
|
46
46
|
assert result == "null"
|
|
47
47
|
|
|
48
48
|
def test_serialize_invalid_indent_type(self):
|
|
@@ -59,7 +59,7 @@ class TestSafeJsonSerialize:
|
|
|
59
59
|
with pytest.raises(
|
|
60
60
|
SerializationError, match="Failed to serialize data to JSON"
|
|
61
61
|
):
|
|
62
|
-
safe_json_serialize({"obj": CustomClass()})
|
|
62
|
+
safe_json_serialize({"obj": CustomClass()}, 0)
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
class TestSafeJsonDeserialize:
|
|
@@ -147,7 +147,7 @@ class TestCompressJsonData:
|
|
|
147
147
|
"""Test compressing larger data for better compression."""
|
|
148
148
|
data = {"repeated": "data" * 100, "numbers": list(range(100))}
|
|
149
149
|
compressed = compress_json_data(data)
|
|
150
|
-
original_json = safe_json_serialize(data)
|
|
150
|
+
original_json = safe_json_serialize(data, 0)
|
|
151
151
|
|
|
152
152
|
# Compressed should be smaller than original for repetitive data
|
|
153
153
|
assert len(compressed) < len(original_json.encode("utf-8"))
|
|
@@ -226,7 +226,7 @@ class TestRoundTripSerialization:
|
|
|
226
226
|
]
|
|
227
227
|
|
|
228
228
|
for original in test_cases:
|
|
229
|
-
serialized = safe_json_serialize(original)
|
|
229
|
+
serialized = safe_json_serialize(original, 0)
|
|
230
230
|
deserialized = safe_json_deserialize(serialized)
|
|
231
231
|
assert deserialized == original
|
|
232
232
|
|
|
File without changes
|