Files
passepartout/skills/org-skill-shell-actuator.org

1.1 KiB

SKILL: Shell Actuator (org-skill-shell-actuator.org)

Overview

The Shell Actuator provides the agent with the capability to execute bash commands.

Implementation

Package Context

(in-package :opencortex)

Shell Execution (shell-execute)

(defun shell-execute (action context)
  "Executes a bash command and returns the output."
  (declare (ignore context))
  (let* ((payload (getf action :payload))
         (cmd (getf payload :cmd)))
    (harness-log "ACT [Shell]: ~a" cmd)
    (multiple-value-bind (out err code)
        (uiop:run-program (list "bash" "-c" cmd) :output :string :error-output :string :ignore-error-status t)
      (if (= code 0)
          out
          (format nil "ERROR [~a]: ~a" code err)))))

Skill Registration

(register-actuator :shell #'shell-execute)

(defskill :skill-shell-actuator
  :priority 50
  :trigger (lambda (ctx) (declare (ignore ctx)) nil))