aiden-runtime 4.0.1 → 4.1.0

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 (112) hide show
  1. package/README.md +11 -7
  2. package/config/hardware.json +2 -2
  3. package/dist/api/server.js +50 -52
  4. package/dist/cli/v4/aidenCLI.js +513 -14
  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 +269 -52
  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 +19 -1
  18. package/dist/cli/v4/commands/mcp.js +358 -0
  19. package/dist/cli/v4/commands/setup.js +34 -0
  20. package/dist/cli/v4/commands/show.js +43 -0
  21. package/dist/cli/v4/commands/skills.js +169 -4
  22. package/dist/cli/v4/commands/status.js +84 -0
  23. package/dist/cli/v4/commands/subagent.js +78 -0
  24. package/dist/cli/v4/commands/verbose.js +1 -1
  25. package/dist/cli/v4/commands/voice.js +218 -0
  26. package/dist/cli/v4/cronCli.js +103 -0
  27. package/dist/cli/v4/display.js +300 -14
  28. package/dist/cli/v4/doctor.js +41 -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/setupWizard.js +466 -232
  37. package/dist/cli/v4/shellInterpolation.js +139 -0
  38. package/dist/cli/v4/skinEngine.js +21 -1
  39. package/dist/cli/v4/streamingPrefix.js +121 -0
  40. package/dist/cli/v4/syntaxHighlight.js +345 -0
  41. package/dist/cli/v4/table.js +216 -0
  42. package/dist/cli/v4/themeDetect.js +81 -0
  43. package/dist/cli/v4/uiBuild.js +74 -0
  44. package/dist/cli/v4/voiceCli.js +113 -0
  45. package/dist/cli/v4/voicePromptApi.js +196 -0
  46. package/dist/core/channels/discord.js +16 -10
  47. package/dist/core/channels/email.js +13 -9
  48. package/dist/core/channels/imessage.js +13 -9
  49. package/dist/core/channels/manager.js +25 -7
  50. package/dist/core/channels/pdf-extract.js +180 -0
  51. package/dist/core/channels/photo-vision.js +157 -0
  52. package/dist/core/channels/signal.js +11 -7
  53. package/dist/core/channels/slack.js +13 -10
  54. package/dist/core/channels/telegram-commands.js +154 -0
  55. package/dist/core/channels/telegram-groups.js +198 -0
  56. package/dist/core/channels/telegram-rate-limit.js +124 -0
  57. package/dist/core/channels/telegram.js +1980 -0
  58. package/dist/core/channels/twilio.js +11 -7
  59. package/dist/core/channels/webhook.js +9 -5
  60. package/dist/core/channels/whatsapp.js +15 -11
  61. package/dist/core/channels/whisper-transcribe.js +163 -0
  62. package/dist/core/cronManager.js +33 -294
  63. package/dist/core/gateway.js +29 -8
  64. package/dist/core/playwrightBridge.js +90 -0
  65. package/dist/core/v4/aidenAgent.js +35 -0
  66. package/dist/core/v4/auxiliaryClient.js +2 -2
  67. package/dist/core/v4/cron/atomicWrite.js +18 -4
  68. package/dist/core/v4/cron/cronExecute.js +300 -0
  69. package/dist/core/v4/cron/cronManager.js +502 -0
  70. package/dist/core/v4/cron/cronState.js +314 -0
  71. package/dist/core/v4/cron/cronTick.js +90 -0
  72. package/dist/core/v4/cron/diagnostics.js +104 -0
  73. package/dist/core/v4/cron/graceWindow.js +79 -0
  74. package/dist/core/v4/firstRun/providerDetection.js +287 -0
  75. package/dist/core/v4/logger/factory.js +110 -0
  76. package/dist/core/v4/logger/index.js +22 -0
  77. package/dist/core/v4/logger/logger.js +101 -0
  78. package/dist/core/v4/logger/sinks/fileSink.js +110 -0
  79. package/dist/core/v4/logger/sinks/multiSink.js +43 -0
  80. package/dist/core/v4/logger/sinks/nullSink.js +53 -0
  81. package/dist/core/v4/logger/sinks/stdSink.js +81 -0
  82. package/dist/core/v4/mcp/server/diagnostics.js +40 -0
  83. package/dist/core/v4/mcp/server/skillBridge.js +94 -0
  84. package/dist/core/v4/mcp/server/stdioServer.js +119 -0
  85. package/dist/core/v4/mcp/server/toolBridge.js +168 -0
  86. package/dist/core/v4/platformPaths.js +105 -0
  87. package/dist/core/v4/providerFallback.js +25 -0
  88. package/dist/core/v4/skillLoader.js +21 -5
  89. package/dist/core/v4/skillMining/candidateStore.js +164 -0
  90. package/dist/core/v4/skillMining/extractorPrompt.js +111 -0
  91. package/dist/core/v4/skillMining/proposalBuilder.js +139 -0
  92. package/dist/core/v4/skillMining/skillMiner.js +191 -0
  93. package/dist/core/v4/skillMining/traceFingerprint.js +51 -0
  94. package/dist/core/v4/subagent/budget.js +76 -0
  95. package/dist/core/v4/subagent/diagnostics.js +22 -0
  96. package/dist/core/v4/subagent/fanout.js +216 -0
  97. package/dist/core/v4/subagent/merger.js +148 -0
  98. package/dist/core/v4/subagent/providerRotation.js +54 -0
  99. package/dist/core/v4/voice/audioStream.js +373 -0
  100. package/dist/core/v4/voice/cliVoice.js +393 -0
  101. package/dist/core/v4/voice/diagnostics.js +66 -0
  102. package/dist/core/v4/voice/ttsStream.js +193 -0
  103. package/dist/core/version.js +1 -1
  104. package/dist/core/visionAnalyze.js +291 -90
  105. package/dist/core/voice/audio.js +61 -5
  106. package/dist/core/voice/audioBackend.js +134 -0
  107. package/dist/core/voice/stt.js +61 -6
  108. package/dist/core/voice/tts.js +19 -3
  109. package/dist/providers/v4/nullAdapter.js +58 -0
  110. package/dist/tools/v4/index.js +32 -1
  111. package/dist/tools/v4/subagent/subagentFanout.js +166 -0
  112. package/package.json +11 -2
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  Autonomous AI Engine
10
10
 
11
- 19 providers · 68 skills · 42 tools · 8 channels · AGPL-3.0
11
+ 19 providers · 68 skills · 42 tools · 9 channels · AGPL-3.0
12
12
 
13
13
  Windows · Linux · WSL · macOS (API Mode)
14
14
 
@@ -93,7 +93,7 @@ Local-first · Self-healing routing · Browser & terminal control · Persistent
93
93
  <img src="https://img.shields.io/badge/providers-19-f97316?style=for-the-badge" alt="19 providers" />
94
94
  <img src="https://img.shields.io/badge/skills-68-43853d?style=for-the-badge" alt="68 skills" />
95
95
  <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" />
96
+ <img src="https://img.shields.io/badge/channels-9-5865f2?style=for-the-badge" alt="9 channels" />
97
97
  <img src="https://img.shields.io/badge/offline-Ollama-22c55e?style=for-the-badge" alt="offline" />
98
98
  <img src="https://img.shields.io/badge/OAuth-Claude%20Pro%20%2B%20ChatGPT%20Plus-9333ea?style=for-the-badge" alt="OAuth subscriptions" />
99
99
  <img src="https://img.shields.io/badge/local--first-yes-00aaaa?style=for-the-badge" alt="local-first" />
@@ -103,13 +103,14 @@ Local-first · Self-healing routing · Browser & terminal control · Persistent
103
103
  <a href="https://aiden.taracod.com"><b>Website</b></a> &nbsp;·&nbsp;
104
104
  <a href="https://aiden.taracod.com/contact"><b>Contact</b></a> &nbsp;·&nbsp;
105
105
  <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>
106
+ <a href="https://github.com/taracodlabs/aiden-releases/releases/latest"><b>Download</b></a> &nbsp;·&nbsp;
107
+ <a href="https://www.amazon.in/Omega-Shiva-Deore-ebook/dp/B0GX33VWZC/"><b>Book</b></a>
107
108
  </p>
108
109
 
109
110
  ---
110
111
 
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.
112
+ > **v4.1.0 — multi-channel autonomous engine · Telegram + MCP server + subagent fanout · voice CLI · hardened cron · skill mining · structured markdown rendering · cross-platform CI**
113
+ > v4.1 turns Aiden into a multi-surface agent: a `ChannelAdapter`-shaped Telegram bot (text / voice / photo / PDF / groups / admin), an MCP server exposing 24 tools + the full skill catalog to Claude Desktop, parallel subagent fanout across `groq`/`together`, REPL voice mode (PTT + continuous), an auto-mining pipeline that proposes new skills from successful workflows, and a deep REPL polish layer (custom `@inquirer/core` prompt, autosuggest, sectioned boot card, sharp ASCII corners, theme detection). Linux/macOS/Windows × Node 20/22 CI matrix. See [changelog](#changelog) below.
113
114
 
114
115
  ---
115
116
 
@@ -328,9 +329,12 @@ We're shipping honest. Things that work, things that don't:
328
329
  - Subagent fanout / parallel agent swarm — single-loop only; deferred to v4.x
329
330
  - OCR — not bundled (vision-loop screen capture works, but no Tesseract)
330
331
  - Full agentskills.io ecosystem install — held pending license review
331
- - Telegram channel adapter — Discord/Slack/WhatsApp/Email/Webhook/Twilio/iMessage/Signal working
332
332
  - Docker sandbox backend — dropped in v4 rewrite
333
333
 
334
+ **Landed in v4.1:**
335
+
336
+ - Telegram channel adapter (DM polling + per-chat memory) — see [docs/channels/telegram.md](docs/channels/telegram.md)
337
+
334
338
  **Beta features:**
335
339
 
336
340
  - OAuth providers — provider-side gates may apply, use API keys as fallback
@@ -441,7 +445,7 @@ Multi-layer memory visualised — every conversation, task, and learned pattern
441
445
  | **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
446
  | **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
447
  | **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. |
448
+ | **Channel adapters** | Discord, Slack, Telegram, WhatsApp, Email (IMAP+SMTP), Webhook, Twilio SMS, iMessage (macOS), Signal — any channel triggers the same agent loop. |
445
449
  | **Computer use** | Screenshot capture, screen-state vision loop, browser automation. Mouse/keyboard automation partial. |
446
450
  | **Cron scheduler** | Persistent recurring tasks via the `croner` engine. Atomic state writes, output capture, 5/6-field cron + `@daily`/`@hourly` shortcodes. |
447
451
  | **Plugins** | Three bundled plugins: Chrome DevTools Protocol bridge, Claude Pro OAuth, ChatGPT Plus OAuth. Plugin system with permission-state machine (pending-grant / loaded / suspended). |
@@ -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
  }