Move config/test/models to daemon TCP protocol, TUI uses .env fallback
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 29s
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:
@@ -496,9 +496,15 @@ Called from handle-submit."
|
||||
(dolist (e (sort entries #'string-lessp :key #'car))
|
||||
(format out "~a=~a~%" (car e) (cdr e)))))))
|
||||
|
||||
(defun daemon-send (action-plist)
|
||||
"Send a message to the daemon if connected. Returns T if sent."
|
||||
(let ((s (st :stream)))
|
||||
(when (and s (open-stream-p s))
|
||||
(send-daemon (list :type :event :payload action-plist))
|
||||
t)))
|
||||
|
||||
(defun cmd-config (text)
|
||||
"Handle /config commands using direct .env file access."
|
||||
"Handle /config commands. Writes .env directly, sends to daemon if connected."
|
||||
(let* ((parts (uiop:split-string text :separator '(#\Space)))
|
||||
(sub (and (>= (length parts) 2) (second parts))))
|
||||
(case (and sub (intern (string-upcase sub) :keyword))
|
||||
@@ -506,17 +512,29 @@ Called from handle-submit."
|
||||
(let ((name (third parts))
|
||||
(key (fourth parts)))
|
||||
(if (and name key)
|
||||
(progn (config-env-set (format nil "~a_API_KEY" (string-upcase name)) key)
|
||||
(add-msg :system (format nil "✓ ~a API key set" name)))
|
||||
(let ((env-key (format nil "~a_API_KEY" (string-upcase name))))
|
||||
(config-env-set env-key key)
|
||||
(daemon-send (list :action :reload-config))
|
||||
(add-msg :system (format nil "✓ ~a API key set" name)))
|
||||
(add-msg :system "Usage: /config provider <name> <apikey>"))))
|
||||
((:test :models :status)
|
||||
(add-msg :system "Run this from the daemon session (Passepartout) — /config only reads/writes .env"))
|
||||
(:test
|
||||
(let ((name (third parts)))
|
||||
(if (and name (daemon-send (list :action :provider-test :name name)))
|
||||
(add-msg :system (format nil "Testing ~a... (response will appear)" name))
|
||||
(add-msg :system "* Daemon not running — start passepartout daemon *"))))
|
||||
(:models
|
||||
(let ((name (third parts)))
|
||||
(if (and name (daemon-send (list :action :provider-models :name name)))
|
||||
(add-msg :system (format nil "Discovering ~a models... (response will appear)" name))
|
||||
(add-msg :system "* Daemon not running — start passepartout daemon *"))))
|
||||
(:cascade
|
||||
(let ((slot (third parts))
|
||||
(cascade (fourth parts)))
|
||||
(if cascade
|
||||
(progn (config-env-set (if slot (format nil "~a_CASCADE" (string-upcase slot)) "PROVIDER_CASCADE") cascade)
|
||||
(add-msg :system (format nil "✓ ~a cascade: ~a" (or slot "global") cascade)))
|
||||
(let ((env-key (if slot (format nil "~a_CASCADE" (string-upcase slot)) "PROVIDER_CASCADE")))
|
||||
(config-env-set env-key cascade)
|
||||
(daemon-send (list :action :reload-config))
|
||||
(add-msg :system (format nil "✓ ~a cascade: ~a" (or slot "global") cascade)))
|
||||
(add-msg :system (format nil "Cascade: ~a" (or (cdr (assoc "PROVIDER_CASCADE" (config-env-read) :test #'string-equal)) "not set"))))))
|
||||
(:proxy
|
||||
(let ((url (third parts)))
|
||||
@@ -537,7 +555,7 @@ Called from handle-submit."
|
||||
(progn (config-env-set key path)
|
||||
(add-msg :system (format nil "✓ ~a set" key)))
|
||||
(add-msg :system (format nil "~a: ~a" key (or (cdr (assoc key (config-env-read) :test #'string-equal)) "not set"))))))
|
||||
(t (add-msg :system "Usage: /config provider <name> <key> | /config cascade <slot> <providers> | /config proxy <url> | /config timeout <n> | /config folder <key> <path>")))))
|
||||
(t (add-msg :system "Usage: /config provider <name> <key> | /config cascade <slot> <providers> | /config proxy <url> | /config timeout <n> | /config folder <key> <path> | /config test <name> | /config models <name>")))))
|
||||
|
||||
(defun cmd-identity (text)
|
||||
"Handle /identity: show or load identity from IDENTITY.org directly."
|
||||
|
||||
Reference in New Issue
Block a user