- ROADMAP: consolidate all TUI work under v0.8.0 (removed premature v0.9.0/v0.10.x labels), restored original v0.9.0 eval harness plan - channel-tui-view.org: Emacs-style reverse-video cursor (swap fg/bg instead of drawing █), hint bar now shows F:focus/MCP:count on left and token gauge + keybindings on right, sidebar reorganized to show GATE TRACE, RULES + BLOCK COUNT, COST, FILES panels - channel-tui-main.org: command palette selection now uses reverse-video highlight (bg-input fg on input-fg bg, matching cursor style), fixed cond order so sel-p is checked before cat (all items had :category making sel-p unreachable), added session-cost extraction from daemon - passepartout: export COLORTERM=truecolor for modern backend detection
46 lines
2.3 KiB
Common Lisp
46 lines
2.3 KiB
Common Lisp
(in-package :passepartout)
|
|
(defun slack-get-token ()
|
|
(vault-get-secret :slack))
|
|
|
|
(defun slack-send (action context)
|
|
"Sends a message via Slack Web API."
|
|
(declare (ignore context))
|
|
(let* ((payload (getf action :payload))
|
|
(meta (getf action :meta))
|
|
(channel (or (getf meta :channel-id) (getf payload :chat-id)))
|
|
(text (or (getf payload :text) (getf action :text)))
|
|
(token (slack-get-token)))
|
|
(when (and token channel text)
|
|
(handler-case
|
|
(dex:post "https://slack.com/api/chat.postMessage"
|
|
:headers `(("Authorization" . ,(format nil "Bearer ~a" token))
|
|
("Content-Type" . "application/json; charset=utf-8"))
|
|
:content (cl-json:encode-json-to-string
|
|
`((channel . ,channel) (text . ,text))))
|
|
(error (c) (log-message "SLACK ERROR: ~a" c))))))
|
|
|
|
(defun slack-poll ()
|
|
"Polls Slack for new messages via conversations.history."
|
|
(let* ((token (slack-get-token)))
|
|
(when token
|
|
(dolist (channel '("general")) ;; configured channel IDs
|
|
(handler-case
|
|
(let* ((url (format nil "https://slack.com/api/conversations.history?channel=~a&limit=5" channel))
|
|
(response (dex:get url :headers
|
|
`(("Authorization" . ,(format nil "Bearer ~a" token))))))
|
|
(let* ((json (ignore-errors (cl-json:decode-json-from-string response)))
|
|
(ok (cdr (assoc :ok json)))
|
|
(messages (cdr (assoc :messages json))))
|
|
(when (and ok messages (listp messages))
|
|
(dolist (msg messages)
|
|
(let* ((text (cdr (assoc :text msg)))
|
|
(user (cdr (assoc :user msg)))
|
|
(ts (cdr (assoc :ts msg))))
|
|
(when (and text user (not (string= user "USLACKBOT")))
|
|
(unless (ignore-errors (hitl-handle-message text :slack))
|
|
(stimulus-inject
|
|
(list :type :EVENT
|
|
:meta (list :source :slack :chat-id channel)
|
|
:payload (list :sensor :user-input :text text))))))))))
|
|
(error (c) (log-message "SLACK POLL ERROR: ~a" c)))))))
|