Commit5221a5bfRecorded30 Jun 2026Repositorycourier
Add COURIER_TELEGRAM_API_URL override (test hook for send-path repro)
Message
Optional env override for the Telegram API base URL, wired into the send-message tool's tg-client. #f = the real https://api.telegram.org (default unchanged). Lets a test courier be pointed at a local mock endpoint to reproduce the send path without touching the live API. Investigation branch only; not for ship until reviewed.
Changed
src/courier/config.sgl | 7 +++++++
src/courier/telegram.sgl | 5 ++++-
2 files changed, 11 insertions(+), 1 deletion(-)Diff
src/courier/config.sglmodified
@@ -15,6 +15,7 @@
15
courier-config? 16
courier-config-telegram-token 17
courier-config-telegram-chat-id+18
courier-config-telegram-api-url 19
courier-config-allowed-senders 20
21
load-courier-config)@@ -27,6 +28,10 @@
28
(define-struct courier-config 29
(telegram-token default: #f) 30
(telegram-chat-id default: #f)+31
;; Optional Telegram API base URL override (COURIER_TELEGRAM_API_URL).+32
;; #f = the real https://api.telegram.org. Used to point a test+33
;; courier at a local mock endpoint (never the live API).+34
(telegram-api-url default: #f) 35
(allowed-senders default: '())) 36
37
;; ============================================================@@ -47,10 +52,12 @@
52
(let* ((token (getenv "COURIER_TELEGRAM_TOKEN")) 53
(chat-id-str (getenv "COURIER_TELEGRAM_CHAT_ID")) 54
(chat-id (and chat-id-str (string->number chat-id-str)))+55
(api-url (getenv "COURIER_TELEGRAM_API_URL")) 56
(yaml (load-config-file))) 57
(courier-config 58
telegram-token: token 59
telegram-chat-id: chat-id+60
telegram-api-url: api-url 61
allowed-senders: (parse-allowed-senders yaml)))) 62
63
;; ============================================================src/courier/telegram.sglmodified
@@ -49,7 +49,9 @@
49
(define (register-send-message-tool! server config relay-st worker-mode?) 50
(: mcp-server? courier-config? relay-state? boolean? -> void?) 51
(let ((token (courier-config-telegram-token config))−52
(default-chat-id (courier-config-telegram-chat-id config)))+52
(default-chat-id (courier-config-telegram-chat-id config))+53
(api-url (or (courier-config-telegram-api-url config)+54
"https://api.telegram.org"))) 55
(mcp-server-register-tool! server 56
"send-message" "Send a message to a recipient (relay name, chat ID, or 'leader')" 57
'((type . "object")@@ -79,6 +81,7 @@
81
(begin 82
(tg-send-message 83
(tg-client token: token+84
api-url: api-url 85
request-timeout: *send-request-timeout* 86
connect-timeout: *send-connect-timeout*) 87
chat-id text)