PSF: Complete 'Thin Harness' refactor and move kernel logic to skills
This commit is contained in:
@@ -79,6 +79,7 @@ Interfaces for secure system calls. State is event-driven via the core kernel bu
|
||||
Whitelist of permitted host binaries.
|
||||
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(defparameter *allowed-commands* '("ls" "git" "rg" "grep" "date" "echo" "cat" "node" "python3" "sbcl"))
|
||||
#+end_src
|
||||
|
||||
@@ -86,6 +87,7 @@ Whitelist of permitted host binaries.
|
||||
Dangerous characters that are banned to prevent command injection.
|
||||
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(defparameter *shell-metacharacters* '(#\; #\& #\| #\> #\< #\$ #\` #\\ #\!)
|
||||
"Characters that are banned in shell commands to prevent injection.")
|
||||
#+end_src
|
||||
@@ -94,6 +96,7 @@ Dangerous characters that are banned to prevent command injection.
|
||||
Predicate to verify a command string is free of metacharacters.
|
||||
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(defun shell-command-safe-p (cmd-string)
|
||||
"Returns T if the command string contains no dangerous metacharacters."
|
||||
(not (some (lambda (char) (find char cmd-string)) *shell-metacharacters*)))
|
||||
@@ -103,6 +106,7 @@ Predicate to verify a command string is free of metacharacters.
|
||||
The primary secure actuator for host system calls.
|
||||
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(defun execute-shell-safely (action context)
|
||||
(let* ((cmd-string (getf (getf action :payload) :cmd))
|
||||
(executable (car (uiop:split-string (string-trim " " cmd-string) :separator '(#\Space)))))
|
||||
@@ -133,6 +137,7 @@ The primary secure actuator for host system calls.
|
||||
Executes a synthesized script (Python/Lisp/JS) in a controlled directory.
|
||||
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(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."
|
||||
@@ -162,6 +167,7 @@ Executes a synthesized script (Python/Lisp/JS) in a controlled directory.
|
||||
Hardware-Level Isolation for future security evolution.
|
||||
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(defun provision-microvm (id &key (cpu 1) (ram 512))
|
||||
"Hardware-Level Isolation: Provisions an ephemeral Firecracker MicroVM.
|
||||
This is the high-security evolution of directory-based sandboxing."
|
||||
@@ -172,6 +178,7 @@ Hardware-Level Isolation for future security evolution.
|
||||
|
||||
** Feedback Perception
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(defun trigger-skill-shell-actuator (context)
|
||||
(let ((type (getf context :type))
|
||||
(payload (getf context :payload)))
|
||||
@@ -181,6 +188,7 @@ Hardware-Level Isolation for future security evolution.
|
||||
|
||||
** Neuro-Cognitive Analysis
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(defun neuro-skill-shell-actuator (context)
|
||||
(let* ((p (getf context :payload))
|
||||
(cmd (getf p :cmd))
|
||||
@@ -199,7 +207,19 @@ Hardware-Level Isolation for future security evolution.
|
||||
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)
|
||||
(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"
|
||||
(let ((result-text (format nil "* Shell Command Result
|
||||
- Command: ~a
|
||||
- Exit Code: ~a
|
||||
|
||||
** STDOUT
|
||||
#+begin_example
|
||||
~a
|
||||
#+end_example
|
||||
|
||||
** STDERR
|
||||
#+begin_example
|
||||
~a
|
||||
#+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
|
||||
@@ -210,6 +230,7 @@ Hardware-Level Isolation for future security evolution.
|
||||
Register the shell channel as a physical actuator.
|
||||
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(org-agent:register-actuator :shell #'execute-shell-safely)
|
||||
#+end_src
|
||||
|
||||
@@ -217,6 +238,7 @@ Register the shell channel as a physical actuator.
|
||||
Define the skill entry for the shell actuator.
|
||||
|
||||
#+begin_src lisp :tangle ../src/shell-logic.lisp
|
||||
(in-package :org-agent)
|
||||
(defskill :skill-shell-actuator
|
||||
:priority 80
|
||||
:trigger #'trigger-skill-shell-actuator
|
||||
|
||||
Reference in New Issue
Block a user