ARCH: Finalize Microkernel Decoupling - Move behavioral skills to dynamic user-space
This commit is contained in:
@@ -38,28 +38,27 @@ The gateway operates as an autonomous background service. It uses `dexador` for
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Package Context
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
(in-package :org-agent)
|
||||
#+begin_src lisp
|
||||
#+end_src
|
||||
|
||||
** State: Update Tracking
|
||||
Tracks the last processed message ID to prevent duplicates.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defvar *telegram-last-update-id* 0)
|
||||
#+end_src
|
||||
|
||||
** State: Polling Thread
|
||||
Reference to the background thread responsible for message reception.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defvar *telegram-polling-thread* nil)
|
||||
#+end_src
|
||||
|
||||
** State: Authorized Chats
|
||||
Whitelist of chat IDs permitted to interact with the agent.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defvar *telegram-authorized-chats* nil
|
||||
"List of chat IDs allowed to interact with the bot. Hydrated from environment.")
|
||||
#+end_src
|
||||
@@ -67,12 +66,12 @@ Whitelist of chat IDs permitted to interact with the agent.
|
||||
** Token Retrieval
|
||||
Fetches the Bot API token from the secure vault.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defun get-telegram-token () (vault-get-secret :telegram))
|
||||
#+end_src
|
||||
|
||||
** Actuator: sendMessage
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defun execute-telegram-action (action context)
|
||||
"Sends a message back to Telegram."
|
||||
(declare (ignore context))
|
||||
@@ -92,7 +91,7 @@ Fetches the Bot API token from the secure vault.
|
||||
#+end_src
|
||||
|
||||
** Sensor: getUpdates & Injection
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defun telegram-process-updates ()
|
||||
"Polls for new messages and injects them into the harness."
|
||||
(let* ((token (get-telegram-token))
|
||||
@@ -124,7 +123,7 @@ Fetches the Bot API token from the secure vault.
|
||||
** Start Polling
|
||||
Initializes the Telegram background thread.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defun start-telegram-gateway ()
|
||||
"Initializes the Telegram background thread."
|
||||
(unless (and *telegram-polling-thread* (bt:thread-alive-p *telegram-polling-thread*))
|
||||
@@ -141,7 +140,7 @@ Initializes the Telegram background thread.
|
||||
** Stop Polling
|
||||
Gracefully terminates the background thread.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defun stop-telegram-gateway ()
|
||||
(when (and *telegram-polling-thread* (bt:thread-alive-p *telegram-polling-thread*))
|
||||
(bt:destroy-thread *telegram-polling-thread*)
|
||||
@@ -151,14 +150,14 @@ Gracefully terminates the background thread.
|
||||
** Registration: Actuator
|
||||
Register the Telegram channel as a physical actuator.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(register-actuator :telegram #'execute-telegram-action)
|
||||
#+end_src
|
||||
|
||||
** Registration: Skill
|
||||
Define the passive skill entry for the gateway.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(defskill :skill-gateway-telegram
|
||||
:priority 150
|
||||
:trigger (lambda (ctx) (declare (ignore ctx)) nil) ;; Passive, handles its own loop
|
||||
@@ -169,6 +168,6 @@ Define the passive skill entry for the gateway.
|
||||
** Initialization
|
||||
Trigger the polling loop upon loading.
|
||||
|
||||
#+begin_src lisp :tangle ../src/gateway-telegram.lisp
|
||||
#+begin_src lisp
|
||||
(start-telegram-gateway)
|
||||
#+end_src
|
||||
|
||||
Reference in New Issue
Block a user