Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

feat: add toggle functionality to /stream command and refactor response handling

Salman Qureshi31d9046f677c
diff --git a/src/core/agent.ts b/src/core/agent.ts
index 25ed1461..52925f73 100644
--- a/src/core/agent.ts
+++ b/src/core/agent.ts
@@ -140,13 +140,18 @@ export class Agent {
const sub = trimmed.slice('/stream'.length).trim().toLowerCase();
if (sub === 'off') {
this.telegramStreaming = false;
- const ch = this.channels.get(msg.channelType as any);
- if (ch) await ch.send('Telegram streaming disabled. Responses will arrive as a single message.', msg.channelId);
- } else {
+ } else if (sub === 'on') {
this.telegramStreaming = true;
- const ch = this.channels.get(msg.channelType as any);
- if (ch) await ch.send('Telegram streaming enabled. Responses will appear progressively.', msg.channelId);
+ } else {
+ this.telegramStreaming = !this.telegramStreaming;
}
+ const ch = this.channels.get(msg.channelType as any);
+ if (ch) await ch.send(
+ this.telegramStreaming
+ ? 'Telegram streaming enabled. Responses will appear progressively.'
+ : 'Telegram streaming disabled. Responses will arrive as a single message.',
+ msg.channelId,
+ );
this.lifecycle.transition('idle');
return;
}
@@ -601,7 +606,7 @@ export class Agent {
return true;
}
- if (cmd === '/stream' || cmd === '/stream on') {
+ if (cmd === '/stream on') {
this.telegramStreaming = true;
await channel.send('Telegram streaming enabled. Responses will appear progressively.', channelId);
return true;
@@ -613,6 +618,22 @@ export class Agent {
return true;
}
+ if (cmd === '/stream') {
+ this.telegramStreaming = !this.telegramStreaming;
+ await channel.send(
+ this.telegramStreaming
+ ? 'Telegram streaming enabled. Responses will appear progressively.'
+ : 'Telegram streaming disabled. Responses will arrive as a single message.',
+ channelId,
+ );
+ return true;
+ }
+ if (cmd === '/stream off') {
+ this.telegramStreaming = false;
+ await channel.send('Telegram streaming disabled. Responses will arrive as a single message.', channelId);
+ return true;
+ }
+
return false;
}
}
\ No newline at end of file