Class SystemTools

java.lang.Object
com.tnsai.tools.system.SystemTools

public class SystemTools extends Object
Function-shape system tools — generic HTTP client + tool-search meta-tool. Replaces the legacy GenericHttpTool and ToolSearchTool.

Two typed @Tool methods:

MethodPurposeIdempotent
httpRequest(java.lang.String, java.lang.String, java.util.Map<java.lang.String, java.lang.String>, java.lang.Object)Generic REST client (GET/POST/PUT/PATCH/DELETE), http/https only, max 500 KB bodyfalse (depends on method/server)
toolSearch(java.lang.String)Discover other tools in the same registrytrue

tool_search reflects on a ToolMethodRegistry that the caller wires in via constructor or setRegistry(ToolMethodRegistry). The chicken-and-egg pattern (the registry contains this very POJO) is solved by late-binding: build SystemTools first, build the registry over it, then call setRegistry. The default no-arg constructor returns a friendly "no registry configured" message until wired.

Since:
0.5.7 (Phase 2 batch 10 — built-in tool migration to function shape, see #188)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor — no registry wired (tool_search returns help text until set).
    SystemTools(com.tnsai.tools.method.ToolMethodRegistry registry)
    Wire a registry up-front (only viable when SystemTools is NOT in the registry itself).
    SystemTools(com.tnsai.tools.method.ToolMethodRegistry registry, okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper)
    Full constructor for tests / shared HTTP.
  • Method Summary

    Modifier and Type
    Method
    Description
    allowPrivateNetwork(boolean allow)
    Opt out of the SSRF guard so http_request may reach private, loopback, or link-local addresses (e.g. a self-hosted assistant calling localhost services).
    httpRequest(String method, String url, Map<String,String> headers, Object body)
     
    setRegistry(com.tnsai.tools.method.ToolMethodRegistry registry)
    Late-bind the registry so that SystemTools can appear in the same registry it searches over (the typical agent setup):
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SystemTools

      public SystemTools()
      Default constructor — no registry wired (tool_search returns help text until set).
    • SystemTools

      public SystemTools(com.tnsai.tools.method.ToolMethodRegistry registry)
      Wire a registry up-front (only viable when SystemTools is NOT in the registry itself).
    • SystemTools

      public SystemTools(com.tnsai.tools.method.ToolMethodRegistry registry, okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper)
      Full constructor for tests / shared HTTP.
  • Method Details

    • allowPrivateNetwork

      public SystemTools allowPrivateNetwork(boolean allow)
      Opt out of the SSRF guard so http_request may reach private, loopback, or link-local addresses (e.g. a self-hosted assistant calling localhost services). Off by default; also enabled by the TNSAI_HTTP_ALLOW_PRIVATE=1 environment variable.
      Returns:
      this for chaining
    • setRegistry

      public SystemTools setRegistry(com.tnsai.tools.method.ToolMethodRegistry registry)
      Late-bind the registry so that SystemTools can appear in the same registry it searches over (the typical agent setup):
      
       SystemTools sys = new SystemTools();
       ToolMethodRegistry reg = new ToolMethodRegistry(List.of(sys, csv, json, ...));
       sys.setRegistry(reg);
       
      Returns:
      this for chaining
    • httpRequest

      @Tool(name="http_request", description="Make an HTTP request (GET/POST/PUT/PATCH/DELETE) to a given URL. Optional headers map and JSON body. http/https schemes only; max body size 500 KB. Returns a string of the form \"Status: <code>\\nBody:\\n<body>\". Note: this tool is NOT idempotent \u2014 POST/PUT/PATCH/DELETE may mutate remote state on every call.", keywords={"http","rest","api","request","webhook","fetch","curl"}, idempotent=false) public String httpRequest(@ToolParam(description="HTTP method: GET, POST, PUT, PATCH, or DELETE") String method, @ToolParam(description="Full http(s) URL") String url, @ToolParam(description="Optional request headers as a name\u2192value map",required=false) Map<String,String> headers, @ToolParam(description="Optional JSON body (object or array). Ignored for GET/DELETE.",required=false) Object body) throws IOException
      Throws:
      IOException
    • toolSearch

      @Tool(name="tool_search", description="Discover available tools in the agent\'s registry. Pass a free-text {query} to keyword-match against tool name / description / keywords. Special queries: blank \u2192 help text; \"list\" or \"all\" \u2192 list every tool; \"info:<name>\" \u2192 detailed info for a specific tool.", keywords={"find tool","discover","available tools","list tools","which tool"}, idempotent=true) public String toolSearch(@ToolParam(description="Free-text query, \"list\", or \"info:<tool_name>\"; blank returns help",required=false,defaultValue="") String query)