Move config/test/models to daemon TCP protocol, TUI uses .env fallback
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 29s

- Daemon: add handle-client-config inline handler for :config-get,
  :config-set, :config-list, :provider-test, :provider-models
- TUI cmd-config: write .env directly, send reload to daemon if connected
- TUI: /config test and /config models send TCP to daemon (fallback:
  daemon-not-running message)
- Add Test Provider and Discover Models to Ctrl+P daemon commands
This commit is contained in:
2026-05-20 16:55:55 -04:00
parent 084abc0644
commit a0694d6489
3 changed files with 63 additions and 8 deletions

View File

@@ -171,10 +171,45 @@ The daemon sends a handshake message on connection, then enters a read loop, inj
nil))))
(format stream "~a" (frame-message health-msg))
(finish-output stream)))
((member (getf (getf msg :payload) :action)
'(:config-get :config-set :config-list
:provider-test :provider-models))
(handle-client-config msg stream))
(t (stimulus-inject msg :stream stream))))))
(error (c) (log-message "CLIENT ERROR: ~a" c)))
(ignore-errors (usocket:socket-close socket))))
(defun handle-client-config (msg stream)
"Handle config/provider commands inline (not through the cognitive pipeline)."
(let* ((payload (getf msg :payload))
(action (getf payload :action))
(name (getf payload :name))
(key (getf payload :key))
(value (getf payload :value))
(result nil))
(case action
(:config-list
(setf result (with-output-to-string (out)
(dolist (e (sort (config-read) #'string-lessp :key #'car))
(format out "~a=~a~%" (car e) (cdr e))))))
(:config-get
(let ((val (config-get (intern (string-upcase key) :keyword))))
(setf result (format nil "~a: ~:[not set~;~:*~a~]" key val))))
(:config-set
(config-set (intern (string-upcase key) :keyword) value)
(setf result (format nil "✓ ~a set" key)))
(:provider-test
(let ((ok (ignore-errors (test-provider-connection
(intern (string-downcase name) :keyword)))))
(setf result (format nil "~a: ~:[✗ failed~;✓ connected~]" name ok))))
(:provider-models
(let ((models (ignore-errors (test-provider-connection
(intern (string-downcase name) :keyword)))))
(setf result (format nil "~a models: ~a" name (or models "unavailable"))))))
(when result
(format stream "~a" (frame-message (list :type :event :payload (list :text result))))
(finish-output stream))))
(defun start-daemon (&key (port 9105) (max-retries 10))
"Starts the network listener for TUI/CLI clients.
If PORT is taken, tries subsequent ports up to PORT+MAX-RETRIES."