Merge branch 'release/v1.2'

This commit is contained in:
Cyber MacGeddon 2025-08-26 19:18:01 +01:00
commit 0bff629f87
28 changed files with 3881 additions and 111 deletions

View file

@ -78,6 +78,10 @@ tg-unload-kg-core = "trustgraph.cli.unload_kg_core:main"
tg-start-library-processing = "trustgraph.cli.start_library_processing:main"
tg-stop-flow = "trustgraph.cli.stop_flow:main"
tg-stop-library-processing = "trustgraph.cli.stop_library_processing:main"
tg-list-config-items = "trustgraph.cli.list_config_items:main"
tg-get-config-item = "trustgraph.cli.get_config_item:main"
tg-put-config-item = "trustgraph.cli.put_config_item:main"
tg-delete-config-item = "trustgraph.cli.delete_config_item:main"
[tool.setuptools.packages.find]
include = ["trustgraph*"]

View file

@ -0,0 +1,61 @@
"""
Deletes a configuration item
"""
import argparse
import os
from trustgraph.api import Api
from trustgraph.api.types import ConfigKey
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
def delete_config_item(url, config_type, key):
api = Api(url).config()
config_key = ConfigKey(type=config_type, key=key)
api.delete([config_key])
print(f"Configuration item deleted: {config_type}/{key}")
def main():
parser = argparse.ArgumentParser(
prog='tg-delete-config-item',
description=__doc__,
)
parser.add_argument(
'--type',
required=True,
help='Configuration type',
)
parser.add_argument(
'--key',
required=True,
help='Configuration key',
)
parser.add_argument(
'-u', '--api-url',
default=default_url,
help=f'API URL (default: {default_url})',
)
args = parser.parse_args()
try:
delete_config_item(
url=args.api_url,
config_type=args.type,
key=args.key,
)
except Exception as e:
print("Exception:", e, flush=True)
if __name__ == "__main__":
main()

View file

@ -0,0 +1,78 @@
"""
Gets a specific configuration item
"""
import argparse
import os
import json
from trustgraph.api import Api
from trustgraph.api.types import ConfigKey
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
def get_config_item(url, config_type, key, format_type):
api = Api(url).config()
config_key = ConfigKey(type=config_type, key=key)
values = api.get([config_key])
if not values:
raise Exception(f"Configuration item not found: {config_type}/{key}")
value = values[0].value
if format_type == "json":
print(json.dumps(value))
else:
print(value)
def main():
parser = argparse.ArgumentParser(
prog='tg-get-config-item',
description=__doc__,
)
parser.add_argument(
'--type',
required=True,
help='Configuration type',
)
parser.add_argument(
'--key',
required=True,
help='Configuration key',
)
parser.add_argument(
'--format',
choices=['text', 'json'],
default='text',
help='Output format (default: text)',
)
parser.add_argument(
'-u', '--api-url',
default=default_url,
help=f'API URL (default: {default_url})',
)
args = parser.parse_args()
try:
get_config_item(
url=args.api_url,
config_type=args.type,
key=args.key,
format_type=args.format,
)
except Exception as e:
print("Exception:", e, flush=True)
if __name__ == "__main__":
main()

View file

@ -0,0 +1,65 @@
"""
Lists configuration items for a specified type
"""
import argparse
import os
import json
from trustgraph.api import Api
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
def list_config_items(url, config_type, format_type):
api = Api(url).config()
keys = api.list(config_type)
if format_type == "json":
print(json.dumps(keys))
else:
for key in keys:
print(key)
def main():
parser = argparse.ArgumentParser(
prog='tg-list-config-items',
description=__doc__,
)
parser.add_argument(
'--type',
required=True,
help='Configuration type to list',
)
parser.add_argument(
'--format',
choices=['text', 'json'],
default='text',
help='Output format (default: text)',
)
parser.add_argument(
'-u', '--api-url',
default=default_url,
help=f'API URL (default: {default_url})',
)
args = parser.parse_args()
try:
list_config_items(
url=args.api_url,
config_type=args.type,
format_type=args.format,
)
except Exception as e:
print("Exception:", e, flush=True)
if __name__ == "__main__":
main()

View file

@ -0,0 +1,80 @@
"""
Sets a configuration item
"""
import argparse
import os
import sys
from trustgraph.api import Api
from trustgraph.api.types import ConfigValue
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
def put_config_item(url, config_type, key, value):
api = Api(url).config()
config_value = ConfigValue(type=config_type, key=key, value=value)
api.put([config_value])
print(f"Configuration item set: {config_type}/{key}")
def main():
parser = argparse.ArgumentParser(
prog='tg-put-config-item',
description=__doc__,
)
parser.add_argument(
'--type',
required=True,
help='Configuration type',
)
parser.add_argument(
'--key',
required=True,
help='Configuration key',
)
value_group = parser.add_mutually_exclusive_group(required=True)
value_group.add_argument(
'--value',
help='Configuration value',
)
value_group.add_argument(
'--stdin',
action='store_true',
help='Read configuration value from standard input',
)
parser.add_argument(
'-u', '--api-url',
default=default_url,
help=f'API URL (default: {default_url})',
)
args = parser.parse_args()
try:
if args.stdin:
value = sys.stdin.read()
else:
value = args.value
put_config_item(
url=args.api_url,
config_type=args.type,
key=args.key,
value=value,
)
except Exception as e:
print("Exception:", e, flush=True)
if __name__ == "__main__":
main()

View file

@ -9,6 +9,10 @@ This script allows you to define agent tools with various types including:
Tools are stored in the 'tool' configuration group and can include
argument specifications for parameterized execution.
IMPORTANT: The tool 'name' is used by agents to invoke the tool and must
be a valid function identifier (use snake_case, no spaces or special chars).
The 'description' provides human-readable information about the tool.
"""
from typing import List
@ -114,14 +118,15 @@ def main():
number - Numeric parameter
Examples:
%(prog)s --id weather --name "Weather lookup" \\
%(prog)s --id weather_tool --name get_weather \\
--type knowledge-query \\
--description "Get weather information" \\
--description "Get weather information for a location" \\
--argument location:string:"Location to query" \\
--argument units:string:"Temperature units (C/F)"
%(prog)s --id calculator --name "Calculator" --type mcp-tool \\
--description "Perform calculations" \\
%(prog)s --id calc_tool --name calculate --type mcp-tool \\
--description "Perform mathematical calculations" \\
--mcp-tool calculator \\
--argument expression:string:"Mathematical expression"
''').strip(),
formatter_class=argparse.RawDescriptionHelpFormatter
@ -140,7 +145,7 @@ def main():
parser.add_argument(
'--name',
help=f'Human-readable tool name',
help=f'Tool name used by agents to invoke this tool (use snake_case, e.g., get_weather)',
)
parser.add_argument(
@ -221,4 +226,4 @@ def main():
print("Exception:", e, flush=True)
if __name__ == "__main__":
main()
main()