feat: implemented verified Shell Actuator skill
- Enabled execution of whitelisted shell commands via OACP. - Added neuro-cognitive analysis for command results. - Fixed authentication fallback for background daemon. - Finalized Emacs UI robustness for all message types.
This commit is contained in:
@@ -48,21 +48,23 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Whitelisting & Execution
|
||||
#+begin_src lisp :tangle projects/org-skill-shell-actuator/src/shell-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-shell-actuator/src/shell-logic.lisp
|
||||
(defparameter *allowed-commands* '("ls" "git" "rg" "grep" "date" "echo" "cat" "node" "python3" "sbcl"))
|
||||
|
||||
(defun execute-shell-safely (action)
|
||||
(defun execute-shell-safely (action context)
|
||||
(let* ((cmd-string (getf (getf action :payload) :cmd))
|
||||
(executable (car (uiop:split-string cmd-string :separator '(#\Space)))))
|
||||
(if (member executable *allowed-commands* :test #'string=)
|
||||
(multiple-value-bind (stdout stderr exit-code)
|
||||
(uiop:run-program cmd-string :output :string :error-output :string :ignore-error-status t)
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd-string :stdout ,(or stdout "") :stderr ,(or stderr "") :exit-code ,exit-code))))
|
||||
`(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd-string :stdout ,(or stdout "") :stderr ,(or stderr "") :exit-code ,exit-code))
|
||||
:stream (getf context :reply-stream)))
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd-string :stdout "" :stderr "ERROR - Command not in security whitelist." :exit-code 1))))))
|
||||
`(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd-string :stdout "" :stderr "ERROR - Command not in security whitelist." :exit-code 1))
|
||||
:stream (getf context :reply-stream)))))
|
||||
|
||||
(defun execute-sandboxed-script (action)
|
||||
(defun execute-sandboxed-script (action context)
|
||||
"Executes a synthesized script (Python/Lisp/JS) in a controlled directory.
|
||||
This enables SOTA-level Tool Synthesis and Iterative Fixing."
|
||||
(let* ((payload (getf action :payload))
|
||||
@@ -83,7 +85,8 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu
|
||||
(multiple-value-bind (stdout stderr exit-code)
|
||||
(uiop:run-program cmd :output :string :error-output :string :ignore-error-status t)
|
||||
(org-agent:inject-stimulus
|
||||
`(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd :stdout ,(or stdout "") :stderr ,(or stderr "") :exit-code ,exit-code :synthesis-p t)))))))
|
||||
`(:type :EVENT :payload (:sensor :shell-response :cmd ,cmd :stdout ,(or stdout "") :stderr ,(or stderr "") :exit-code ,exit-code :synthesis-p t))
|
||||
:stream (getf context :reply-stream))))))
|
||||
|
||||
(defun provision-microvm (id &key (cpu 1) (ram 512))
|
||||
"Hardware-Level Isolation: Provisions an ephemeral Firecracker MicroVM.
|
||||
@@ -94,7 +97,7 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu
|
||||
#+end_src
|
||||
|
||||
** Feedback Perception
|
||||
#+begin_src lisp :tangle projects/org-skill-shell-actuator/src/shell-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-shell-actuator/src/shell-logic.lisp
|
||||
(defun trigger-skill-shell-actuator (context)
|
||||
(let ((type (getf context :type))
|
||||
(payload (getf context :payload)))
|
||||
@@ -103,7 +106,7 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu
|
||||
#+end_src
|
||||
|
||||
** Neuro-Cognitive Analysis
|
||||
#+begin_src lisp :tangle projects/org-skill-shell-actuator/src/shell-logic.lisp
|
||||
#+begin_src lisp :tangle ../projects/org-skill-shell-actuator/src/shell-logic.lisp
|
||||
(defun neuro-skill-shell-actuator (context)
|
||||
(let* ((p (getf context :payload))
|
||||
(cmd (getf p :cmd))
|
||||
@@ -122,11 +125,15 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu
|
||||
If the command failed (Exit != 0), analyze the STDERR and propose a FIX for the script.
|
||||
If it succeeded, use the STDOUT to complete the original goal.
|
||||
" cmd exit-code stdout stderr)
|
||||
(format nil "Command: ~a (Exit: ~a)~%STDOUT: ~a~%STDERR: ~a" cmd exit-code stdout stderr))))
|
||||
(let ((result-text (format nil "* Shell Command Result\n- Command: ~a\n- Exit Code: ~a\n\n** STDOUT\n#+begin_example\n~a\n#+end_example\n\n** STDERR\n#+begin_example\n~a\n#+end_example"
|
||||
cmd exit-code stdout stderr)))
|
||||
`(:type :request :target :emacs :payload (:action :insert-at-end :buffer "*org-agent-chat*" :text ,result-text))))))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(org-agent:register-actuator :shell #'execute-shell-safely)
|
||||
|
||||
(defskill :skill-shell-actuator
|
||||
:priority 80
|
||||
:trigger #'trigger-skill-shell-actuator
|
||||
|
||||
Reference in New Issue
Block a user