@inceptionstack/roundhouse 0.5.19 → 0.5.20
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.
- package/package.json +1 -1
- package/src/gateway/gateway.ts +19 -2
package/package.json
CHANGED
package/src/gateway/gateway.ts
CHANGED
|
@@ -817,10 +817,27 @@ export class Gateway {
|
|
|
817
817
|
const threadId = `telegram:${primaryChatId}`;
|
|
818
818
|
const agentThreadId = "main";
|
|
819
819
|
|
|
820
|
-
// Create a synthetic thread
|
|
820
|
+
// Create a synthetic Telegram-compatible thread so streaming, HTML conversion,
|
|
821
|
+
// message splitting, and progressive edits all work identically to real chat threads.
|
|
822
|
+
const token = process.env.TELEGRAM_BOT_TOKEN;
|
|
821
823
|
const syntheticThread = {
|
|
822
824
|
id: threadId,
|
|
823
|
-
|
|
825
|
+
adapter: {
|
|
826
|
+
telegramFetch: async (method: string, payload: Record<string, unknown>) => {
|
|
827
|
+
if (!token) return null;
|
|
828
|
+
const res = await fetch(`https://api.telegram.org/bot${token}/${method}`, {
|
|
829
|
+
method: "POST",
|
|
830
|
+
headers: { "Content-Type": "application/json" },
|
|
831
|
+
body: JSON.stringify({ chat_id: primaryChatId, ...payload }),
|
|
832
|
+
signal: AbortSignal.timeout(30_000),
|
|
833
|
+
});
|
|
834
|
+
if (!res.ok) return null;
|
|
835
|
+
const json = await res.json() as { result?: unknown };
|
|
836
|
+
return json.result ?? null;
|
|
837
|
+
},
|
|
838
|
+
},
|
|
839
|
+
post: async (content: string | { markdown: string }) => {
|
|
840
|
+
const text = typeof content === "string" ? content : content.markdown;
|
|
824
841
|
await this.transport.notify([primaryChatId], text);
|
|
825
842
|
},
|
|
826
843
|
startTyping: async () => {},
|