@sulala/agent-os 0.1.27 → 0.1.29

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.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/png" href="/logo_dark.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Sulala Agent Dashboard</title>
8
- <script type="module" crossorigin src="/assets/index-BZYG7rCd.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-BBmAFz5e.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-CAOgf_FY.css">
10
10
  </head>
11
11
  <body>
package/dist/cli.js CHANGED
@@ -26834,22 +26834,45 @@ async function handleTelegramWebhook(req, memoryStore) {
26834
26834
  }
26835
26835
  function startTelegramPolling(memoryStore) {
26836
26836
  let offset = 0;
26837
+ let webhookDeletedForToken = null;
26838
+ let loggedPollingStarted = false;
26837
26839
  async function poll() {
26838
26840
  const config2 = await readConfig();
26839
26841
  const botToken = config2.telegram_bot_token?.trim();
26840
26842
  if (!botToken) {
26843
+ webhookDeletedForToken = null;
26844
+ loggedPollingStarted = false;
26841
26845
  setTimeout(poll, POLLING_INTERVAL_MS);
26842
26846
  return;
26843
26847
  }
26844
26848
  try {
26845
- const url = `https://api.telegram.org/bot${botToken}/getUpdates?offset=${offset}&timeout=${GET_UPDATES_TIMEOUT}`;
26846
- const res = await fetch(url);
26849
+ const res = await fetch(`https://api.telegram.org/bot${botToken}/getWebhookInfo`);
26847
26850
  if (!res.ok) {
26848
26851
  setTimeout(poll, POLLING_INTERVAL_MS);
26849
26852
  return;
26850
26853
  }
26851
26854
  const data = await res.json();
26852
- const updates = Array.isArray(data?.result) ? data.result : [];
26855
+ const webhookUrl = data?.result?.url?.trim();
26856
+ if (webhookUrl) {
26857
+ setTimeout(poll, POLLING_INTERVAL_MS);
26858
+ return;
26859
+ }
26860
+ if (webhookDeletedForToken !== botToken) {
26861
+ await fetch(`https://api.telegram.org/bot${botToken}/deleteWebhook`).catch(() => {});
26862
+ webhookDeletedForToken = botToken;
26863
+ }
26864
+ if (!loggedPollingStarted) {
26865
+ console.log("[telegram] polling started (no webhook set; no HTTPS required).");
26866
+ loggedPollingStarted = true;
26867
+ }
26868
+ const url = `https://api.telegram.org/bot${botToken}/getUpdates?offset=${offset}&timeout=${GET_UPDATES_TIMEOUT}`;
26869
+ const getRes = await fetch(url);
26870
+ if (!getRes.ok) {
26871
+ setTimeout(poll, POLLING_INTERVAL_MS);
26872
+ return;
26873
+ }
26874
+ const updateData = await getRes.json();
26875
+ const updates = Array.isArray(updateData?.result) ? updateData.result : [];
26853
26876
  for (const update of updates) {
26854
26877
  if (update.update_id != null && update.update_id >= offset) {
26855
26878
  offset = update.update_id + 1;
@@ -26863,22 +26886,7 @@ function startTelegramPolling(memoryStore) {
26863
26886
  }
26864
26887
  setTimeout(poll, 0);
26865
26888
  }
26866
- readConfig().then(async (config2) => {
26867
- const botToken = config2.telegram_bot_token?.trim();
26868
- if (!botToken)
26869
- return;
26870
- const res = await fetch(`https://api.telegram.org/bot${botToken}/getWebhookInfo`);
26871
- if (!res.ok)
26872
- return;
26873
- const data = await res.json();
26874
- const webhookUrl = data?.result?.url?.trim();
26875
- if (webhookUrl) {
26876
- return;
26877
- }
26878
- await fetch(`https://api.telegram.org/bot${botToken}/deleteWebhook`).catch(() => {});
26879
- console.log("[telegram] polling started (no webhook set; no HTTPS required).");
26880
- poll();
26881
- }).catch(() => {});
26889
+ poll();
26882
26890
  }
26883
26891
  var POLLING_INTERVAL_MS = 1000, GET_UPDATES_TIMEOUT = 30;
26884
26892
  var init_telegram = __esm(() => {
package/dist/index.js CHANGED
@@ -28647,22 +28647,45 @@ var POLLING_INTERVAL_MS = 1000;
28647
28647
  var GET_UPDATES_TIMEOUT = 30;
28648
28648
  function startTelegramPolling(memoryStore) {
28649
28649
  let offset = 0;
28650
+ let webhookDeletedForToken = null;
28651
+ let loggedPollingStarted = false;
28650
28652
  async function poll() {
28651
28653
  const config2 = await readConfig();
28652
28654
  const botToken = config2.telegram_bot_token?.trim();
28653
28655
  if (!botToken) {
28656
+ webhookDeletedForToken = null;
28657
+ loggedPollingStarted = false;
28654
28658
  setTimeout(poll, POLLING_INTERVAL_MS);
28655
28659
  return;
28656
28660
  }
28657
28661
  try {
28658
- const url = `https://api.telegram.org/bot${botToken}/getUpdates?offset=${offset}&timeout=${GET_UPDATES_TIMEOUT}`;
28659
- const res = await fetch(url);
28662
+ const res = await fetch(`https://api.telegram.org/bot${botToken}/getWebhookInfo`);
28660
28663
  if (!res.ok) {
28661
28664
  setTimeout(poll, POLLING_INTERVAL_MS);
28662
28665
  return;
28663
28666
  }
28664
28667
  const data = await res.json();
28665
- const updates = Array.isArray(data?.result) ? data.result : [];
28668
+ const webhookUrl = data?.result?.url?.trim();
28669
+ if (webhookUrl) {
28670
+ setTimeout(poll, POLLING_INTERVAL_MS);
28671
+ return;
28672
+ }
28673
+ if (webhookDeletedForToken !== botToken) {
28674
+ await fetch(`https://api.telegram.org/bot${botToken}/deleteWebhook`).catch(() => {});
28675
+ webhookDeletedForToken = botToken;
28676
+ }
28677
+ if (!loggedPollingStarted) {
28678
+ console.log("[telegram] polling started (no webhook set; no HTTPS required).");
28679
+ loggedPollingStarted = true;
28680
+ }
28681
+ const url = `https://api.telegram.org/bot${botToken}/getUpdates?offset=${offset}&timeout=${GET_UPDATES_TIMEOUT}`;
28682
+ const getRes = await fetch(url);
28683
+ if (!getRes.ok) {
28684
+ setTimeout(poll, POLLING_INTERVAL_MS);
28685
+ return;
28686
+ }
28687
+ const updateData = await getRes.json();
28688
+ const updates = Array.isArray(updateData?.result) ? updateData.result : [];
28666
28689
  for (const update of updates) {
28667
28690
  if (update.update_id != null && update.update_id >= offset) {
28668
28691
  offset = update.update_id + 1;
@@ -28676,22 +28699,7 @@ function startTelegramPolling(memoryStore) {
28676
28699
  }
28677
28700
  setTimeout(poll, 0);
28678
28701
  }
28679
- readConfig().then(async (config2) => {
28680
- const botToken = config2.telegram_bot_token?.trim();
28681
- if (!botToken)
28682
- return;
28683
- const res = await fetch(`https://api.telegram.org/bot${botToken}/getWebhookInfo`);
28684
- if (!res.ok)
28685
- return;
28686
- const data = await res.json();
28687
- const webhookUrl = data?.result?.url?.trim();
28688
- if (webhookUrl) {
28689
- return;
28690
- }
28691
- await fetch(`https://api.telegram.org/bot${botToken}/deleteWebhook`).catch(() => {});
28692
- console.log("[telegram] polling started (no webhook set; no HTTPS required).");
28693
- poll();
28694
- }).catch(() => {});
28702
+ poll();
28695
28703
  }
28696
28704
 
28697
28705
  // src/http/slack.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sulala/agent-os",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },