fix(protocol): Synchronize uppercase keywords for TUI and CLI Gateway
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 3s

This commit is contained in:
2026-04-19 15:27:33 -04:00
parent 22726047a1
commit 455a1a62b2
4 changed files with 54 additions and 8 deletions

46
final_test.py Normal file
View File

@@ -0,0 +1,46 @@
import pty, os, time, socket
# 1. Wait for daemon to be ready
print("Waiting for port 9105...")
for i in range(30):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost", 9105))
s.close()
print("Daemon is up!")
break
except:
time.sleep(1)
else:
print("Daemon failed to start.")
exit(1)
# 2. Run TUI in pty and inject "Hi\n"
pid, fd = pty.fork()
if pid == 0:
# Child: Run TUI
os.environ["TERM"] = "xterm"
os.environ["SCRIPT_DIR"] = os.getcwd()
os.execvp("sbcl", ["sbcl", "--disable-debugger",
"--eval", "(load (merge-pathnames \"quicklisp/setup.lisp\" (user-homedir-pathname)))",
"--eval", "(push (truename (uiop:getenv \"SCRIPT_DIR\")) asdf:*central-registry*)",
"--eval", "(ql:quickload :opencortex/tui)",
"--eval", "(opencortex.tui:main)"])
else:
# Parent: Inject keys
time.sleep(5) # Wait for TUI to load
os.write(fd, b"Hi\r") # \r for Enter in many TUIs
time.sleep(5) # Wait for response
# Read output and look for "Cascade Failure" or similar
try:
output = os.read(fd, 8192).decode(errors='ignore')
print("TUI OUTPUT CAPTURED:")
print(output)
if "Neural Cascade Failure" in output or "Providers exhausted" in output or "Hi" in output:
print("SUCCESS: UI correctly rendered input and response.")
else:
print("FAILURE: UI did not show expected text.")
except:
pass
os.kill(pid, 9)
os.waitpid(pid, 0)

View File

@@ -49,11 +49,11 @@ The OpenCortex TUI Client is a standalone Common Lisp application built on **Cro
(let ((payload (getf msg :payload))) (let ((payload (getf msg :payload)))
(when (eq (getf payload :action) :handshake) (when (eq (getf payload :action) :handshake)
(setf *status-text* "Ready")))) (setf *status-text* "Ready"))))
((and (listp msg) (eq (getf msg :type) :status)) ((and (listp msg) (eq (getf msg :type) :STATUS))
(setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]" (setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]"
(getf msg :scribe) (getf msg :scribe)
(getf msg :gardener)))) (getf msg :gardener))))
((and (listp msg) (eq (getf msg :type) :chat)) ((and (listp msg) (eq (getf msg :type) :CHAT))
(enqueue-msg (getf msg :text))) (enqueue-msg (getf msg :text)))
(t (enqueue-msg (format nil "~s" msg)))))) (t (enqueue-msg (format nil "~s" msg))))))
(error (c) (setf *status-text* (format nil "Net Error: ~a" c)) (setf *is-running* nil))) (error (c) (setf *status-text* (format nil "Net Error: ~a" c)) (setf *is-running* nil)))

View File

@@ -61,9 +61,9 @@ The CLI actuator writes the agent's response back to the client's network stream
(handler-case (handler-case
(if (and stream (open-stream-p stream)) (if (and stream (open-stream-p stream))
(progn (progn
(format stream "~a" (frame-message (format nil "~s" (list :type :chat :text text)))) (format stream "~a" (frame-message (format nil "~s" (list :type :CHAT :text text))))
(finish-output stream) (finish-output stream)
(format stream "~a" (frame-message (format nil "~s" '(:type :status :scribe :idle :gardener :sleeping)))) (format stream "~a" (frame-message (format nil "~s" '(:TYPE :STATUS :scribe :idle :gardener :sleeping))))
(finish-output stream)) (finish-output stream))
(harness-log "CLI ERROR: No active or open reply stream for signal.")) (harness-log "CLI ERROR: No active or open reply stream for signal."))
(error (c) (harness-log "CLI ACTUATOR ERROR: ~a" c))))) (error (c) (harness-log "CLI ACTUATOR ERROR: ~a" c)))))
@@ -77,7 +77,7 @@ Handles an individual TCP connection. It reads lines until the connection is clo
"Handles TUI slash commands by returning structured Lisp s-expressions." "Handles TUI slash commands by returning structured Lisp s-expressions."
(cond (cond
((string= cmd "/status") ((string= cmd "/status")
(format stream "~a" (frame-message (format nil "~s" '(:type :status :scribe :idle :gardener :sleeping)))) (format stream "~a" (frame-message (format nil "~s" '(:TYPE :STATUS :scribe :idle :gardener :sleeping))))
(finish-output stream)) (finish-output stream))
((string= cmd "/exit") ((string= cmd "/exit")
(prin1 '(:type :info :text "Goodbye!") stream) (prin1 '(:type :info :text "Goodbye!") stream)
@@ -95,7 +95,7 @@ Handles an individual TCP connection. It reads lines until the connection is clo
;; 1. Send Handshake ;; 1. Send Handshake
(format stream "~a" (frame-message (format nil "~s" (make-hello-message "0.1.0")))) (format stream "~a" (frame-message (format nil "~s" (make-hello-message "0.1.0"))))
(finish-output stream) (finish-output stream)
(format stream "~a" (frame-message (format nil "~s" '(:type :status :scribe :idle :gardener :sleeping)))) (format stream "~a" (frame-message (format nil "~s" '(:TYPE :STATUS :scribe :idle :gardener :sleeping))))
(finish-output stream) (finish-output stream)
;; 2. Communication Loop ;; 2. Communication Loop

View File

@@ -36,11 +36,11 @@
(let ((payload (getf msg :payload))) (let ((payload (getf msg :payload)))
(when (eq (getf payload :action) :handshake) (when (eq (getf payload :action) :handshake)
(setf *status-text* "Ready")))) (setf *status-text* "Ready"))))
((and (listp msg) (eq (getf msg :type) :status)) ((and (listp msg) (eq (getf msg :type) :STATUS))
(setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]" (setf *status-text* (format nil "[Scribe: ~a] [Gardener: ~a]"
(getf msg :scribe) (getf msg :scribe)
(getf msg :gardener)))) (getf msg :gardener))))
((and (listp msg) (eq (getf msg :type) :chat)) ((and (listp msg) (eq (getf msg :type) :CHAT))
(enqueue-msg (getf msg :text))) (enqueue-msg (getf msg :text)))
(t (enqueue-msg (format nil "~s" msg)))))) (t (enqueue-msg (format nil "~s" msg))))))
(error (c) (setf *status-text* (format nil "Net Error: ~a" c)) (setf *is-running* nil))) (error (c) (setf *status-text* (format nil "Net Error: ~a" c)) (setf *is-running* nil)))