65 lines
2.8 KiB
Org Mode
65 lines
2.8 KiB
Org Mode
#+TITLE: Org-Native Delivery Skill
|
|
#+AUTHOR: org-agent
|
|
#+SKILL_NAME: skill-org-delivery
|
|
|
|
This skill provides the Actuator for external messaging by appending structured headlines to a central Org-mode delivery queue.
|
|
|
|
* Helper Functions
|
|
#+begin_src lisp
|
|
(defun format-universal-time-org (ut)
|
|
"Format universal time as a standard Org-mode timestamp string."
|
|
(multiple-value-bind (second minute hour day month year day-of-week)
|
|
(decode-universal-time ut)
|
|
(declare (ignore second day-of-week))
|
|
(format nil "~4,'0d-~2,'0d-~2,'0d ~a ~2,'0d:~2,'0d"
|
|
year month day
|
|
(nth (nth-value 6 (decode-universal-time ut)) '("Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"))
|
|
hour minute)))
|
|
#+end_src
|
|
|
|
* Sensor & State (Actuator Registration)
|
|
When this skill loads, it registers itself to handle `:delivery` actions.
|
|
|
|
#+begin_src lisp
|
|
(defun execute-org-delivery (action)
|
|
"Appends the message intent to the native Org-mode delivery file."
|
|
(let* ((payload (getf action :payload))
|
|
(text (getf payload :text))
|
|
(channel (or (getf payload :channel) :signal))
|
|
;; Support Telegram and Discord identifiers if provided
|
|
(to (or (getf payload :to)
|
|
(case (or (getf payload :channel) :signal)
|
|
(:telegram (org-agent::get-env "TELEGRAM_CHAT_ID"))
|
|
(:discord (org-agent::get-env "DISCORD_WEBHOOK_URL"))
|
|
(t (org-agent::get-env "RECIPIENT_ID")))))
|
|
(timestamp (format-universal-time-org (get-universal-time)))
|
|
(system-dir (org-agent::get-env "SYSTEM_DIR" "system/"))
|
|
(delivery-file (format nil "~a/delivery.org" system-dir)))
|
|
|
|
(kernel-log "ACTUATOR [Org-Delivery] - Enqueueing ~a message for ~a..." channel to)
|
|
|
|
(let ((entry (format nil "* TODO Message to ~a~% :PROPERTIES:~% :CHANNEL: ~a~% :ENQUEUED_AT: [~a]~% :STATUS: pending~% :END:~%~% ~a~%~%"
|
|
to channel timestamp text)))
|
|
|
|
(handler-case
|
|
(with-open-file (out delivery-file
|
|
:direction :output
|
|
:if-exists :append
|
|
:if-does-not-exist :create)
|
|
(write-string entry out)
|
|
(kernel-log "ACTUATOR [Org-Delivery] - Entry appended to ~a" delivery-file))
|
|
(error (c)
|
|
(kernel-log "ACTUATOR [Org-Delivery] ERROR - Failed to write to file - ~a" c))))))
|
|
|
|
;; Register the actuator with the core Event Bus
|
|
(org-agent:register-actuator :delivery #'execute-org-delivery)
|
|
#+end_src
|
|
|
|
* Registration
|
|
#+begin_src lisp
|
|
(defskill :skill-org-delivery
|
|
:priority 100 ; Actuators are high priority
|
|
:trigger (lambda (context) nil) ; No cognitive trigger, actuator only
|
|
:neuro (lambda (context) nil)
|
|
:symbolic (lambda (action context) action))
|
|
#+end_src |