open-agents-ai 0.49.0 → 0.51.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 (2) hide show
  1. package/dist/index.js +64 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -20941,27 +20941,36 @@ async function handleSlashCommand(input, ctx) {
20941
20941
  ctx.telegramStatus?.();
20942
20942
  return "handled";
20943
20943
  }
20944
+ const isLocal = parts.includes("--local");
20944
20945
  const keyIdx = parts.indexOf("--key");
20945
- if (keyIdx !== -1) {
20946
- const token = parts[keyIdx + 1];
20947
- if (!token) {
20948
- renderWarning("Usage: /telegram --key <bot-token>");
20949
- renderInfo("Get a bot token from @BotFather on Telegram.");
20950
- return "handled";
20951
- }
20952
- ctx.saveTelegramSettings?.({ key: token });
20953
- renderInfo(`Telegram bot token saved (${token.slice(0, 6)}...). Use /telegram to start.`);
20954
- return "handled";
20955
- }
20956
20946
  const adminIdx = parts.indexOf("--admin");
20957
- if (adminIdx !== -1) {
20958
- const userId = parts[adminIdx + 1];
20959
- if (!userId) {
20960
- renderWarning("Usage: /telegram --admin <user-id-or-username>");
20961
- return "handled";
20962
- }
20963
- ctx.saveTelegramSettings?.({ admin: userId });
20964
- renderInfo(`Telegram admin set to ${c2.bold(userId)}. Only this user's messages will be processed.`);
20947
+ if (keyIdx !== -1 || adminIdx !== -1) {
20948
+ const settings = { local: isLocal };
20949
+ const scope = isLocal ? "project" : "global";
20950
+ if (keyIdx !== -1) {
20951
+ const token = parts[keyIdx + 1];
20952
+ if (!token || token.startsWith("--")) {
20953
+ renderWarning("Usage: /telegram --key <bot-token> [--admin <id>] [--local]");
20954
+ renderInfo("Get a bot token from @BotFather on Telegram.");
20955
+ return "handled";
20956
+ }
20957
+ settings.key = token;
20958
+ }
20959
+ if (adminIdx !== -1) {
20960
+ const userId = parts[adminIdx + 1];
20961
+ if (!userId || userId.startsWith("--")) {
20962
+ renderWarning("Usage: /telegram --admin <user-id-or-username> [--key <token>] [--local]");
20963
+ return "handled";
20964
+ }
20965
+ settings.admin = userId;
20966
+ }
20967
+ ctx.saveTelegramSettings?.(settings);
20968
+ if (settings.key)
20969
+ renderInfo(`Telegram bot token saved to ${scope} settings (${settings.key.slice(0, 6)}...).`);
20970
+ if (settings.admin)
20971
+ renderInfo(`Telegram admin set to ${c2.bold(settings.admin)} (${scope}).`);
20972
+ if (!ctx.isTelegramActive?.() && settings.key)
20973
+ renderInfo("Use /telegram to start.");
20965
20974
  return "handled";
20966
20975
  }
20967
20976
  if (!arg) {
@@ -20985,11 +20994,12 @@ async function handleSlashCommand(input, ctx) {
20985
20994
  }
20986
20995
  renderWarning(`Unknown argument: "${arg}"`);
20987
20996
  renderInfo("Usage:");
20988
- renderInfo(" /telegram --key <token> Save bot token");
20989
- renderInfo(" /telegram --admin <id> Set admin user filter");
20997
+ renderInfo(" /telegram --key <token> Save bot token (global)");
20998
+ renderInfo(" /telegram --admin <id> Set admin filter (global)");
20990
20999
  renderInfo(" /telegram Toggle on/off");
20991
21000
  renderInfo(" /telegram stop Stop bridge");
20992
21001
  renderInfo(" /telegram status Show status");
21002
+ renderInfo(" Add --local to scope settings to this project only");
20993
21003
  return "handled";
20994
21004
  }
20995
21005
  default: {
@@ -27456,9 +27466,19 @@ with summary "no_reply" to silently skip without responding.
27456
27466
  async start() {
27457
27467
  if (this.polling)
27458
27468
  throw new Error("Telegram bridge already active.");
27459
- const me = await this.apiCall("getMe");
27460
- if (!me.ok) {
27461
- throw new Error(`Invalid Telegram bot token: ${me.description || "unknown error"}`);
27469
+ let me;
27470
+ for (let attempt = 0; attempt < 3; attempt++) {
27471
+ try {
27472
+ me = await this.apiCall("getMe");
27473
+ break;
27474
+ } catch (err) {
27475
+ if (attempt === 2)
27476
+ throw err;
27477
+ await new Promise((r) => setTimeout(r, 2e3 * (attempt + 1)));
27478
+ }
27479
+ }
27480
+ if (!me?.ok) {
27481
+ throw new Error(`Invalid Telegram bot token: ${me?.description || "unknown error"}`);
27462
27482
  }
27463
27483
  this.state = {
27464
27484
  active: true,
@@ -28223,8 +28243,11 @@ ${caption}\r
28223
28243
  if (body) {
28224
28244
  options.body = JSON.stringify(body);
28225
28245
  }
28246
+ const isLongPoll = method === "getUpdates";
28226
28247
  if (this.abortController) {
28227
28248
  options.signal = this.abortController.signal;
28249
+ } else if (!isLongPoll) {
28250
+ options.signal = AbortSignal.timeout(3e4);
28228
28251
  }
28229
28252
  const res = await fetch(url, options);
28230
28253
  const data = await res.json();
@@ -30740,10 +30763,15 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
30740
30763
  if (settings.admin !== void 0) {
30741
30764
  savedSettings.telegramAdmin = settings.admin;
30742
30765
  }
30743
- saveProjectSettings(repoRoot, {
30766
+ const payload = {
30744
30767
  ...settings.key !== void 0 ? { telegramKey: settings.key } : {},
30745
30768
  ...settings.admin !== void 0 ? { telegramAdmin: settings.admin } : {}
30746
- });
30769
+ };
30770
+ if (settings.local) {
30771
+ saveProjectSettings(repoRoot, payload);
30772
+ } else {
30773
+ saveGlobalSettings(payload);
30774
+ }
30747
30775
  },
30748
30776
  telegramStatus() {
30749
30777
  const active = telegramBridge?.isActive ?? false;
@@ -31019,6 +31047,16 @@ ${sessionCtx}` : "",
31019
31047
  }, 100);
31020
31048
  }
31021
31049
  }
31050
+ if (!isResumed && savedSettings.telegramKey) {
31051
+ setTimeout(async () => {
31052
+ try {
31053
+ await commandCtx.telegramStart(savedSettings.telegramKey, savedSettings.telegramAdmin);
31054
+ } catch (err) {
31055
+ writeContent(() => renderWarning(`Telegram auto-start failed: ${err instanceof Error ? err.message : String(err)}`));
31056
+ showPrompt();
31057
+ }
31058
+ }, 200);
31059
+ }
31022
31060
  let pasteBuffer = [];
31023
31061
  let pasteTimer = null;
31024
31062
  let pasteIndicatorShown = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.49.0",
3
+ "version": "0.51.0",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",