From f8c6d45755acb5abf9ac68931268b7945da0fae0 Mon Sep 17 00:00:00 2001 From: t Date: Mon, 15 Jun 2026 22:11:53 -0600 Subject: display fixes: markdown rendering, tool-specific components --- agent/tools/shell.lua | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'agent/tools/shell.lua') diff --git a/agent/tools/shell.lua b/agent/tools/shell.lua index f9be58b..6c0a37c 100644 --- a/agent/tools/shell.lua +++ b/agent/tools/shell.lua @@ -26,12 +26,32 @@ -- a string-returning tool result is shaped). Most shell commands the -- agent runs interleave the two anyway. +local panto = require("panto") local uv = require("luv") local MAX_BYTES = 50 * 1024 -- 50 KB, same as `read` local DEFAULT_TIMEOUT_S = 300 -- 5 minutes local SIGKILL_GRACE_MS = 250 +local tool = { + name = "std.shell", + description = string.format("Execute a shell command via `/bin/sh -c`. Returns merged stdout+stderr after the command exits, prefixed with an exit-status header. Output is truncated to the last %dKB; on truncation the full transcript is saved to `$PANTO_HOME/shell-output/` and its path is included for follow-up `read` calls. Default timeout 5 minutes.", MAX_BYTES / 1024), + schema = { + type = "object", + properties = { + command = { type = "string", description = "Shell command. Passed to `sh -c` verbatim; pipes, redirections, etc. work." }, + cwd = { type = "string", description = "Working directory (default: cwd)." }, + timeout = { type = "integer", description = "Hard timeout in seconds (default: " .. tostring(DEFAULT_TIMEOUT_S) .. ").", minimum = 1 }, + }, + required = { "command" }, + }, +} + +panto.ext.on("tool", function(e) + if e.tool_name ~= tool.name then return end + e:set_component(e:get_component()) +end) + -- --------------------------------------------------------------------------- -- Coroutine-synchronous coordination. -- @@ -128,20 +148,7 @@ end -- --------------------------------------------------------------------------- -- Tool body -- --------------------------------------------------------------------------- - -return { - name = "std.shell", - description = string.format("Execute a shell command via `/bin/sh -c`. Returns merged stdout+stderr after the command exits, prefixed with an exit-status header. Output is truncated to the last %dKB; on truncation the full transcript is saved to `$PANTO_HOME/shell-output/` and its path is included for follow-up `read` calls. Default timeout 5 minutes.", MAX_BYTES / 1024), - schema = { - type = "object", - properties = { - command = { type = "string", description = "Shell command. Passed to `sh -c` verbatim; pipes, redirections, etc. work." }, - cwd = { type = "string", description = "Working directory (default: cwd)." }, - timeout = { type = "integer", description = "Hard timeout in seconds (default: " .. tostring(DEFAULT_TIMEOUT_S) .. ").", minimum = 1 }, - }, - required = { "command" }, - }, - handler = function(input) +tool.handler = function(input) local command = input.command if type(command) ~= "string" or command == "" then return "Error: `command` must be a non-empty string." @@ -427,5 +434,6 @@ return { end end return table.concat(parts, "\n") - end, -} + end + +return tool -- cgit v1.3