Class LocalShell

java.lang.Object
uno.anahata.ai.tools.spi.LocalShell

public class LocalShell extends Object
A tool provider that allows the AI model to execute commands in the local bash shell.

This tool is powerful and should be used with caution. It captures standard output, standard error, and execution metadata.

  • Constructor Details

    • LocalShell

      public LocalShell()
  • Method Details

    • runShell

      public static Map<String,Object> runShell(String command) throws Exception
      Executes a shell command using bash -c.
      Parameters:
      command - The shell command to execute.
      Returns:
      A map containing execution results:
      • threadId: The name of the thread that initiated the command.
      • pid: The process ID of the shell command.
      • startTime: ISO-8601 start timestamp.
      • endTime: ISO-8601 end timestamp.
      • executionTimeMs: Total duration in milliseconds.
      • exitCode: The process exit code (0 for success).
      • stdout: The captured standard output.
      • stderr: The captured standard error.
      Throws:
      Exception - if the command fails to start or execution is interrupted.