aiden-runtime 4.0.2 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +19 -11
  2. package/config/hardware.json +2 -2
  3. package/dist/api/server.js +50 -52
  4. package/dist/cli/v4/aidenCLI.js +424 -7
  5. package/dist/cli/v4/aidenPrompt.js +317 -0
  6. package/dist/cli/v4/box.js +105 -39
  7. package/dist/cli/v4/callbacks.js +39 -6
  8. package/dist/cli/v4/chatSession.js +256 -55
  9. package/dist/cli/v4/citationFooter.js +97 -0
  10. package/dist/cli/v4/commands/channel.js +656 -0
  11. package/dist/cli/v4/commands/clear.js +1 -1
  12. package/dist/cli/v4/commands/compress.js +1 -1
  13. package/dist/cli/v4/commands/cron.js +44 -16
  14. package/dist/cli/v4/commands/fanout.js +236 -0
  15. package/dist/cli/v4/commands/help.js +15 -4
  16. package/dist/cli/v4/commands/history.js +84 -0
  17. package/dist/cli/v4/commands/index.js +16 -1
  18. package/dist/cli/v4/commands/mcp.js +358 -0
  19. package/dist/cli/v4/commands/show.js +43 -0
  20. package/dist/cli/v4/commands/skills.js +169 -4
  21. package/dist/cli/v4/commands/status.js +84 -0
  22. package/dist/cli/v4/commands/subagent.js +78 -0
  23. package/dist/cli/v4/commands/verbose.js +1 -1
  24. package/dist/cli/v4/commands/voice.js +218 -0
  25. package/dist/cli/v4/cronCli.js +103 -0
  26. package/dist/cli/v4/display.js +297 -13
  27. package/dist/cli/v4/doctor.js +102 -1
  28. package/dist/cli/v4/doctorLiveness.js +329 -0
  29. package/dist/cli/v4/envSources.js +105 -0
  30. package/dist/cli/v4/ghostMatch.js +74 -0
  31. package/dist/cli/v4/historyStore.js +163 -0
  32. package/dist/cli/v4/pasteCompression.js +124 -0
  33. package/dist/cli/v4/pasteIntercept.js +203 -0
  34. package/dist/cli/v4/replyRenderer.js +209 -0
  35. package/dist/cli/v4/resizeGuard.js +92 -0
  36. package/dist/cli/v4/shellInterpolation.js +139 -0
  37. package/dist/cli/v4/skinEngine.js +21 -1
  38. package/dist/cli/v4/streamingPrefix.js +121 -0
  39. package/dist/cli/v4/syntaxHighlight.js +345 -0
  40. package/dist/cli/v4/table.js +216 -0
  41. package/dist/cli/v4/themeDetect.js +81 -0
  42. package/dist/cli/v4/uiBuild.js +74 -0
  43. package/dist/cli/v4/voiceCli.js +113 -0
  44. package/dist/cli/v4/voicePromptApi.js +196 -0
  45. package/dist/core/channels/discord.js +16 -10
  46. package/dist/core/channels/email.js +13 -9
  47. package/dist/core/channels/imessage.js +13 -9
  48. package/dist/core/channels/manager.js +25 -7
  49. package/dist/core/channels/pdf-extract.js +180 -0
  50. package/dist/core/channels/photo-vision.js +157 -0
  51. package/dist/core/channels/signal.js +11 -7
  52. package/dist/core/channels/slack.js +13 -10
  53. package/dist/core/channels/telegram-commands.js +154 -0
  54. package/dist/core/channels/telegram-groups.js +198 -0
  55. package/dist/core/channels/telegram-rate-limit.js +124 -0
  56. package/dist/core/channels/telegram.js +1980 -0
  57. package/dist/core/channels/twilio.js +11 -7
  58. package/dist/core/channels/webhook.js +9 -5
  59. package/dist/core/channels/whatsapp.js +15 -11
  60. package/dist/core/channels/whisper-transcribe.js +163 -0
  61. package/dist/core/cronManager.js +33 -294
  62. package/dist/core/gateway.js +29 -8
  63. package/dist/core/playwrightBridge.js +90 -0
  64. package/dist/core/v4/aidenAgent.js +35 -0
  65. package/dist/core/v4/auxiliaryClient.js +2 -2
  66. package/dist/core/v4/cron/atomicWrite.js +18 -4
  67. package/dist/core/v4/cron/cronExecute.js +300 -0
  68. package/dist/core/v4/cron/cronManager.js +502 -0
  69. package/dist/core/v4/cron/cronState.js +314 -0
  70. package/dist/core/v4/cron/cronTick.js +90 -0
  71. package/dist/core/v4/cron/diagnostics.js +104 -0
  72. package/dist/core/v4/cron/graceWindow.js +79 -0
  73. package/dist/core/v4/logger/factory.js +110 -0
  74. package/dist/core/v4/logger/index.js +22 -0
  75. package/dist/core/v4/logger/logger.js +101 -0
  76. package/dist/core/v4/logger/sinks/fileSink.js +110 -0
  77. package/dist/core/v4/logger/sinks/multiSink.js +43 -0
  78. package/dist/core/v4/logger/sinks/nullSink.js +53 -0
  79. package/dist/core/v4/logger/sinks/stdSink.js +81 -0
  80. package/dist/core/v4/mcp/server/diagnostics.js +40 -0
  81. package/dist/core/v4/mcp/server/skillBridge.js +94 -0
  82. package/dist/core/v4/mcp/server/stdioServer.js +119 -0
  83. package/dist/core/v4/mcp/server/toolBridge.js +168 -0
  84. package/dist/core/v4/platformPaths.js +105 -0
  85. package/dist/core/v4/providerFallback.js +25 -0
  86. package/dist/core/v4/skillLoader.js +21 -5
  87. package/dist/core/v4/skillMining/candidateStore.js +164 -0
  88. package/dist/core/v4/skillMining/extractorPrompt.js +118 -0
  89. package/dist/core/v4/skillMining/proposalBuilder.js +140 -0
  90. package/dist/core/v4/skillMining/skillMiner.js +191 -0
  91. package/dist/core/v4/skillMining/traceFingerprint.js +51 -0
  92. package/dist/core/v4/subagent/budget.js +76 -0
  93. package/dist/core/v4/subagent/diagnostics.js +22 -0
  94. package/dist/core/v4/subagent/fanout.js +216 -0
  95. package/dist/core/v4/subagent/merger.js +148 -0
  96. package/dist/core/v4/subagent/providerRotation.js +54 -0
  97. package/dist/core/v4/voice/audioStream.js +373 -0
  98. package/dist/core/v4/voice/cliVoice.js +393 -0
  99. package/dist/core/v4/voice/diagnostics.js +66 -0
  100. package/dist/core/v4/voice/ttsStream.js +193 -0
  101. package/dist/core/version.js +1 -1
  102. package/dist/core/visionAnalyze.js +291 -90
  103. package/dist/core/voice/audio.js +61 -5
  104. package/dist/core/voice/audioBackend.js +134 -0
  105. package/dist/core/voice/stt.js +61 -6
  106. package/dist/core/voice/tts.js +19 -3
  107. package/dist/moat/dangerousPatterns.js +1 -1
  108. package/dist/providers/v4/codexResponsesAdapter.js +7 -2
  109. package/dist/providers/v4/errors.js +51 -1
  110. package/dist/providers/v4/ollamaPromptToolsAdapter.js +9 -2
  111. package/dist/tools/v4/index.js +32 -1
  112. package/dist/tools/v4/subagent/subagentFanout.js +190 -0
  113. package/package.json +11 -2
package/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ <img width="1672" height="941" alt="AIDEN BOOTUP LOGO" src="https://github.com/user-attachments/assets/c0809009-73e2-4d58-9292-12fbd0324952" />
2
+
3
+
4
+
5
+
1
6
  ```
2
7
  █████╗ ██╗██████╗ ███████╗███╗ ██╗
3
8
  ██╔══██╗██║██╔══██╗██╔════╝████╗ ██║
@@ -8,7 +13,7 @@
8
13
 
9
14
  Autonomous AI Engine
10
15
 
11
- 19 providers · 68 skills · 42 tools · 8 channels · AGPL-3.0
16
+ 72 skills · 42 tools · 19 providers · 9 channels · AGPL-3.0
12
17
 
13
18
  Windows · Linux · WSL · macOS (API Mode)
14
19
 
@@ -16,12 +21,13 @@ Local-first · Self-healing routing · Browser & terminal control · Persistent
16
21
  ```
17
22
 
18
23
  <p align="center">
19
- <a href="https://github.com/taracodlabs/aiden-releases/releases/latest"><img src="https://img.shields.io/github/v/release/taracodlabs/aiden-releases?color=f97316&label=version&style=for-the-badge" alt="Latest version" /></a>
20
- <a href="https://github.com/taracodlabs/aiden-releases/releases"><img src="https://img.shields.io/github/downloads/taracodlabs/aiden-releases/total?color=f97316&label=downloads&style=for-the-badge" alt="Downloads" /></a>
24
+ <a href="https://github.com/taracodlabs/aiden/releases/latest"><img src="https://img.shields.io/github/v/release/taracodlabs/aiden?color=f97316&label=version&style=for-the-badge" alt="Latest version" /></a>
25
+ <a href="https://github.com/taracodlabs/aiden/releases"><img src="https://img.shields.io/github/downloads/taracodlabs/aiden/total?color=f97316&label=downloads&style=for-the-badge" alt="Downloads" /></a>
21
26
  <a href="https://discord.gg/gMZ3hUnQTm"><img src="https://img.shields.io/badge/chat-discord-7289da?logo=discord&logoColor=white&style=for-the-badge" alt="Discord" /></a>
22
27
  <a href="./LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0-orange?style=for-the-badge" alt="License: AGPL-3.0" /></a>
23
28
  <a href="https://github.com/taracodlabs/aiden/stargazers"><img src="https://img.shields.io/github/stars/taracodlabs/aiden?style=for-the-badge&color=f9d71c" alt="Stars" /></a>
24
29
  <a href="https://www.npmjs.com/package/aiden-runtime"><img src="https://img.shields.io/npm/v/aiden-runtime?color=f97316&label=npm&style=for-the-badge" alt="npm" /></a>
30
+ <a href="https://amzn.to/4tpiXwM"><img src="https://img.shields.io/badge/book-Omega-ff9900?logo=amazon&logoColor=white&style=for-the-badge" alt="Book: Omega" /></a>
25
31
  </p>
26
32
 
27
33
  <p align="center">
@@ -93,7 +99,7 @@ Local-first · Self-healing routing · Browser & terminal control · Persistent
93
99
  <img src="https://img.shields.io/badge/providers-19-f97316?style=for-the-badge" alt="19 providers" />
94
100
  <img src="https://img.shields.io/badge/skills-68-43853d?style=for-the-badge" alt="68 skills" />
95
101
  <img src="https://img.shields.io/badge/tools-42-blueviolet?style=for-the-badge" alt="42 tools" />
96
- <img src="https://img.shields.io/badge/channels-8-5865f2?style=for-the-badge" alt="8 channels" />
102
+ <img src="https://img.shields.io/badge/channels-9-5865f2?style=for-the-badge" alt="9 channels" />
97
103
  <img src="https://img.shields.io/badge/offline-Ollama-22c55e?style=for-the-badge" alt="offline" />
98
104
  <img src="https://img.shields.io/badge/OAuth-Claude%20Pro%20%2B%20ChatGPT%20Plus-9333ea?style=for-the-badge" alt="OAuth subscriptions" />
99
105
  <img src="https://img.shields.io/badge/local--first-yes-00aaaa?style=for-the-badge" alt="local-first" />
@@ -103,13 +109,14 @@ Local-first · Self-healing routing · Browser & terminal control · Persistent
103
109
  <a href="https://aiden.taracod.com"><b>Website</b></a> &nbsp;·&nbsp;
104
110
  <a href="https://aiden.taracod.com/contact"><b>Contact</b></a> &nbsp;·&nbsp;
105
111
  <a href="https://discord.gg/gMZ3hUnQTm"><b>Discord</b></a> &nbsp;·&nbsp;
106
- <a href="https://github.com/taracodlabs/aiden-releases/releases/latest"><b>Download</b></a>
112
+ <a href="https://github.com/taracodlabs/aiden/releases/latest"><b>Download</b></a> &nbsp;·&nbsp;
113
+ <a href="https://amzn.to/4tpiXwM"><b>Book</b></a>
107
114
  </p>
108
115
 
109
116
  ---
110
117
 
111
- > **v4.0.0 "REWRITE" clean-room core · 19 providers · single-loop agent · cron scheduler · neofetch boot card · OAuth subscriptions · honest failures**
112
- > v4 is a from-scratch rewrite: every adapter, every prompt slot, every loop. Provider OAuth (Claude Pro, ChatGPT Plus) routes to subscription quota instead of pay-as-you-go. Sub-second provider fallback. 28 slash commands. See [changelog](#changelog) below.
118
+ > **v4.1.0 — Multi-channel autonomous AI engine**
119
+ > Telegram + MCP server + subagent fanout + voice CLI + skill mining. Hardened cron, structured markdown, cross-platform CI. See [changelog](#changelog) below.
113
120
 
114
121
  ---
115
122
 
@@ -325,12 +332,14 @@ We're shipping honest. Things that work, things that don't:
325
332
 
326
333
  **Not in v4.0:**
327
334
 
328
- - Subagent fanout / parallel agent swarm — single-loop only; deferred to v4.x
329
335
  - OCR — not bundled (vision-loop screen capture works, but no Tesseract)
330
336
  - Full agentskills.io ecosystem install — held pending license review
331
- - Telegram channel adapter — Discord/Slack/WhatsApp/Email/Webhook/Twilio/iMessage/Signal working
332
337
  - Docker sandbox backend — dropped in v4 rewrite
333
338
 
339
+ **Landed in v4.1:**
340
+
341
+ - Telegram channel adapter (DM polling + per-chat memory) — see [docs/channels/telegram.md](docs/channels/telegram.md)
342
+
334
343
  **Beta features:**
335
344
 
336
345
  - OAuth providers — provider-side gates may apply, use API keys as fallback
@@ -441,7 +450,7 @@ Multi-layer memory visualised — every conversation, task, and learned pattern
441
450
  | **68 bundled skills** | Composable workflows each with a `SKILL.md` prompt, optional helper scripts, and tool requirements. Includes: GitHub PR/issue workflows, NSE / Upstox / Zerodha trading, Censys / Shodan / VirusTotal lookups, Windows Defender / Task Scheduler, Docker management, YouTube content tools, ASCII art, and more. |
442
451
  | **6-layer memory** | `MEMORY.md` (declarative facts), conversation/session/workspace memory, semantic search (BM25 + embeddings), learning memory (`LESSONS.md`), structured user profile. Dirty-bit invalidation rebuilds the prompt when files change mid-session. |
443
452
  | **Voice** | Edge TTS / Windows SAPI text-to-speech, speech-to-text helpers. |
444
- | **Channel adapters** | Discord, Slack, WhatsApp, Email (IMAP+SMTP), Webhook, Twilio SMS, iMessage (macOS), Signal — any channel triggers the same agent loop. |
453
+ | **Channel adapters** | Discord, Slack, Telegram, WhatsApp, Email (IMAP+SMTP), Webhook, Twilio SMS, iMessage (macOS), Signal — any channel triggers the same agent loop. |
445
454
  | **Computer use** | Screenshot capture, screen-state vision loop, browser automation. Mouse/keyboard automation partial. |
446
455
  | **Cron scheduler** | Persistent recurring tasks via the `croner` engine. Atomic state writes, output capture, 5/6-field cron + `@daily`/`@hourly` shortcodes. |
447
456
  | **Plugins** | Three bundled plugins: Chrome DevTools Protocol bridge, Claude Pro OAuth, ChatGPT Plus OAuth. Plugin system with permission-state machine (pending-grant / loaded / suspended). |
@@ -723,7 +732,6 @@ aiden # CLI
723
732
 
724
733
  - **npm package renamed** — `aiden-os` → `aiden-runtime`. Run `npm uninstall -g aiden-os && npm install -g aiden-runtime`.
725
734
  - **Slash commands consolidated** — v3's `/switch`, `/budget`, `/memory`, `/profile`, `/permissions`, `/sandbox`, `/retry`, `/failed`, `/publish` are gone. Use `/model`, `/usage`, `/identity`, `/yolo` for equivalent functionality. See `/help` for the v4 list.
726
- - **Subagent fanout removed** — v4 is single-loop only; subagent support deferred to v4.x.
727
735
  - **Docker sandbox dropped** — `AIDEN_SANDBOX_MODE` no longer applies. Tools run on the host. The `tirithScanner` secret/PII guard, `ssrfProtection`, and tiered approval engine remain as the safety layer.
728
736
  - **Skill registry install changed** — auto-fetch from external repos held pending license review. Skills install via `/skills install <local-path-or-url>` only at v4.0.
729
737
  - **Config compatible** — most environment variables (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GROQ_API_KEY`, etc.) are recognised as-is. Copy your existing `.env` and Aiden picks them up.
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "gpu": "NVIDIA GeForce GTX 1060 6GB",
3
3
  "vramGB": 6,
4
- "ramGB": 32,
4
+ "ramGB": 16,
5
5
  "platform": "windows",
6
6
  "cudaAvailable": true,
7
7
  "appleSilicon": false,
8
- "detectedAt": "2026-05-03T13:08:55.885Z"
8
+ "detectedAt": "2026-05-07T19:19:32.778Z"
9
9
  }
@@ -132,7 +132,11 @@ const aidenIdentity_1 = require("../core/aidenIdentity");
132
132
  const eventBus_1 = require("../core/eventBus");
133
133
  const workflowTracker_1 = require("../core/workflowTracker");
134
134
  const hooks_1 = require("../core/hooks");
135
- const telegramBot_1 = require("../core/telegramBot");
135
+ // Phase v4.1-1 — Telegram migrated to the standard ChannelAdapter
136
+ // pattern. The legacy raw-fetch TelegramBot class in core/telegramBot.ts
137
+ // is retained only for its `TelegramConfig` shape, still consumed by
138
+ // the dashboard settings endpoint below.
139
+ const telegram_1 = require("../core/channels/telegram");
136
140
  const callbackSystem_1 = require("../core/callbackSystem");
137
141
  const memoryDistiller_1 = require("../core/memoryDistiller");
138
142
  const failureAnalyzer_1 = require("../core/failureAnalyzer");
@@ -157,7 +161,6 @@ const email_1 = require("../core/channels/email");
157
161
  const dashboard_1 = require("./dashboard");
158
162
  // —— Sprint 25: module-level WebSocket clients registry (shared between createApiServer routes and startApiServer WS setup)
159
163
  let wsBroadcastClients = new Set();
160
- let activeTelegramBot = null;
161
164
  const lastExchangeBySession = new Map();
162
165
  // ── Bookmarklet — clip selected text from any page ────────────
163
166
  const BOOKMARKLET = `javascript:void(fetch('http://localhost:4200/api/clip',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({content:window.getSelection().toString()||document.title,source:window.location.href,title:document.title})}).then(()=>alert('Clipped!')))`;
@@ -2737,13 +2740,10 @@ function createApiServer() {
2737
2740
  };
2738
2741
  cfg.telegram = newTg;
2739
2742
  (0, index_1.saveConfig)(cfg);
2740
- // Restart bot if running, or start if newly enabled
2741
- if (activeTelegramBot) {
2742
- activeTelegramBot.stop();
2743
- activeTelegramBot = null;
2744
- }
2745
- // Note: full restart handled on next server restart — live reload intentionally omitted
2746
- // to avoid async complexity inside a sync express handler
2743
+ // Phase v4.1-1: live reload remains intentionally omitted config
2744
+ // is persisted, channelManager picks it up on the next server boot.
2745
+ // (Live restart through `channelManager.restart('telegram')` could
2746
+ // land in Phase 2 once env-var → config bridging is wired.)
2747
2747
  res.json({ ok: true });
2748
2748
  }
2749
2749
  catch (e) {
@@ -6185,56 +6185,53 @@ function startApiServer(portArg) {
6185
6185
  console.log(`[AgentShield] ✅ Scan complete — risk score ${scan.riskScore}/100`);
6186
6186
  }
6187
6187
  }).catch((e) => console.error('[AgentShield] Scan failed:', e.message));
6188
- // ── Telegram Bot ─────────────────────────────────────────────
6188
+ // ── Channel adapters (all 9 channels) ───────────────────────────
6189
+ // Phase v4.1-1 — Telegram is now a first-class ChannelAdapter,
6190
+ // gated on `TELEGRAM_BOT_TOKEN` like the other env-driven channels.
6191
+ //
6192
+ // Back-compat bridge: users who configured Telegram via the
6193
+ // dashboard (Settings → Channels → Telegram) wrote their token into
6194
+ // the YAML config, not the environment. Promote it to
6195
+ // `process.env.TELEGRAM_BOT_TOKEN` before adapter construction so
6196
+ // their bot keeps working after the Phase 1 migration. Env always
6197
+ // wins if it is already set.
6189
6198
  try {
6190
6199
  const tgCfg = (0, index_1.loadConfig)().telegram;
6191
- if (tgCfg?.enabled && tgCfg?.botToken) {
6192
- const startupTime = Date.now();
6193
- activeTelegramBot = new telegramBot_1.TelegramBot(tgCfg);
6194
- activeTelegramBot.startPolling(async (chatId, text) => {
6195
- // ── Bot commands ─────────────────────────────────────
6196
- if (text === '/start') {
6197
- return `👋 Hey! I'm Aiden, your personal AI.\n\nYour chat ID is: \`${chatId}\`\nAdd this to Aiden Settings → Channels → Telegram → Allowed Chat IDs.\n\nThen just message me anything — I can research, code, manage files, check stocks, and more.`;
6198
- }
6199
- if (text === '/help') {
6200
- return `🤖 Aiden Commands:\n\nJust type naturally — I understand:\n• "Check NIFTY price"\n• "Research top AI tools"\n• "Write a Python script for..."\n• "What's the weather in Mumbai?"\n• "Schedule a reminder for 5pm"\n\n/status — Check Aiden health\n/stop — Cancel current task`;
6201
- }
6202
- if (text === '/status') {
6203
- const uptimeSec = Math.floor((Date.now() - startupTime) / 1000);
6204
- const uptimeStr = uptimeSec > 3600
6205
- ? `${Math.floor(uptimeSec / 3600)}h ${Math.floor((uptimeSec % 3600) / 60)}m`
6206
- : `${Math.floor(uptimeSec / 60)}m ${uptimeSec % 60}s`;
6207
- const activeCfg = (0, index_1.loadConfig)();
6208
- const provider = activeCfg.model?.active || 'unknown';
6209
- const semStats = semanticMemory_1.semanticMemory.getStats();
6210
- return `✅ Aiden is online\nMode: auto\nProvider: ${provider}\nMemory: ${semStats.total} entries\nUptime: ${uptimeStr}`;
6211
- }
6212
- // ── Normal message — route through unified gateway ──────
6213
- return await gateway_1.gateway.routeMessage({
6214
- channel: 'telegram',
6215
- channelId: chatId,
6216
- userId: `telegram_${chatId}`,
6217
- text,
6218
- timestamp: Date.now(),
6219
- });
6220
- }).catch((e) => console.error('[Telegram] Polling error:', e.message));
6221
- // Register Telegram delivery so gateway.deliver() / broadcast() can send back
6222
- const _tgBot = activeTelegramBot;
6223
- (0, telegramBot_1.registerTelegramCallbacks)(_tgBot);
6224
- gateway_1.gateway.registerChannel('telegram', async (msg) => {
6225
- await _tgBot.sendMessage(msg.channelId, msg.text);
6226
- return true;
6227
- });
6228
- console.log('[Telegram] Bot connected and polling');
6200
+ if (tgCfg?.enabled &&
6201
+ typeof tgCfg.botToken === 'string' &&
6202
+ tgCfg.botToken.length > 0 &&
6203
+ !process.env.TELEGRAM_BOT_TOKEN) {
6204
+ process.env.TELEGRAM_BOT_TOKEN = tgCfg.botToken;
6229
6205
  }
6230
- else {
6231
- console.log('[Telegram] Bot disabled or no token configured — skipping');
6206
+ if (tgCfg?.allowedChatIds?.length &&
6207
+ !process.env.TELEGRAM_ALLOWED_CHATS) {
6208
+ process.env.TELEGRAM_ALLOWED_CHATS = tgCfg.allowedChatIds.join(',');
6232
6209
  }
6233
6210
  }
6211
+ catch {
6212
+ // Config read failure is non-fatal — adapter falls through to env-only.
6213
+ }
6214
+ // Phase v4.1-1.3a — attach a `serve`-mode logger so adapter / gateway
6215
+ // diagnostics emit as NDJSON to stdout (systemd / docker capture) and
6216
+ // mirror to <root>/logs/aiden.log. Singleton attach happens once
6217
+ // before any startAll / register call has a chance to log.
6218
+ try {
6219
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
6220
+ const { resolveAidenPaths } = require('../core/v4/paths');
6221
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
6222
+ const { createBootLogger } = require('../core/v4/logger');
6223
+ const paths = resolveAidenPaths();
6224
+ const { logger: serveLogger } = createBootLogger({
6225
+ mode: 'serve',
6226
+ logsDir: paths.logsDir,
6227
+ });
6228
+ gateway_1.gateway.attachLogger(serveLogger.child('gateway'));
6229
+ manager_1.channelManager.attachLogger(serveLogger.child('channels'));
6230
+ }
6234
6231
  catch (e) {
6235
- console.error('[Telegram] Failed to start bot:', e.message);
6232
+ // Logger wiring is best-effort during boot; never block the server.
6233
+ console.error('[ChannelManager] Logger wiring failed:', e?.message);
6236
6234
  }
6237
- // ── Channel adapters (all 9 channels) ───────────────────────────
6238
6235
  manager_1.channelManager.register(new discord_1.DiscordAdapter());
6239
6236
  manager_1.channelManager.register(new slack_1.SlackAdapter());
6240
6237
  manager_1.channelManager.register(new webhook_1.WebhookAdapter(app));
@@ -6243,6 +6240,7 @@ function startApiServer(portArg) {
6243
6240
  manager_1.channelManager.register(new twilio_1.TwilioAdapter(app));
6244
6241
  manager_1.channelManager.register(new imessage_1.IMessageAdapter());
6245
6242
  manager_1.channelManager.register(new email_1.EmailAdapter());
6243
+ manager_1.channelManager.register(new telegram_1.TelegramAdapter());
6246
6244
  manager_1.channelManager.startAll().catch((e) => console.error('[ChannelManager] Startup error:', e.message));
6247
6245
  return app;
6248
6246
  }