0agent 1.0.96 → 1.0.97

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/bin/0agent.js CHANGED
@@ -330,7 +330,21 @@ async function runInit() {
330
330
  tgToken = await arrowPassword('Telegram bot token');
331
331
  tgToken = tgToken.trim();
332
332
  if (tgToken) {
333
- console.log(' \x1b[32m✓\x1b[0m Telegram connected. Message your bot to chat with 0agent.');
333
+ // Validate token immediately
334
+ process.stdout.write(' Verifying token...');
335
+ try {
336
+ const tgRes = await fetch(`https://api.telegram.org/bot${tgToken}/getMe`, { signal: AbortSignal.timeout(10000) });
337
+ const tgData = await tgRes.json();
338
+ if (tgData.ok) {
339
+ console.log(` \x1b[32m✓\x1b[0m @${tgData.result?.username ?? 'bot'}`);
340
+ console.log(` \x1b[32m✓\x1b[0m Message @${tgData.result?.username} on Telegram to chat with 0agent.`);
341
+ } else {
342
+ console.log(` \x1b[31m✗\x1b[0m Invalid token — check with @BotFather`);
343
+ tgToken = '';
344
+ }
345
+ } catch {
346
+ console.log(` \x1b[33m⚠\x1b[0m Could not verify (network issue) — will retry on daemon start`);
347
+ }
334
348
  }
335
349
  } else if (channelIdx === 1) {
336
350
  // Slack
package/dist/daemon.mjs CHANGED
@@ -11219,7 +11219,7 @@ import { join as join4 } from "node:path";
11219
11219
  var TelegramAdapter = class {
11220
11220
  constructor(config) {
11221
11221
  this.config = config;
11222
- this.token = config.token;
11222
+ this.token = config.token || process.env.TELEGRAM_BOT_TOKEN || "";
11223
11223
  this.allowedUsers = new Set(config.allowed_users ?? []);
11224
11224
  this.daemonUrl = config.daemon_url ?? "http://localhost:4200";
11225
11225
  this.transcribeVoice = config.transcribe_voice ?? true;
@@ -11244,8 +11244,23 @@ var TelegramAdapter = class {
11244
11244
  }
11245
11245
  async start() {
11246
11246
  if (this.running) return;
11247
+ if (!this.token) {
11248
+ console.error("[0agent] Telegram: no token configured. Set surfaces.telegram.token in config.yaml or TELEGRAM_BOT_TOKEN env var.");
11249
+ return;
11250
+ }
11251
+ try {
11252
+ const res = await fetch(`https://api.telegram.org/bot${this.token}/getMe`, { signal: AbortSignal.timeout(1e4) });
11253
+ const data = await res.json();
11254
+ if (!data.ok) {
11255
+ console.error("[0agent] Telegram: invalid bot token \u2014 getMe failed. Check your token.");
11256
+ return;
11257
+ }
11258
+ console.log(`[0agent] Telegram: connected as @${data.result?.username ?? data.result?.first_name ?? "bot"}`);
11259
+ } catch (err) {
11260
+ console.error(`[0agent] Telegram: could not reach Telegram API \u2014 ${err instanceof Error ? err.message : err}`);
11261
+ return;
11262
+ }
11247
11263
  this.running = true;
11248
- console.log("[0agent] Telegram: adapter started");
11249
11264
  this._poll();
11250
11265
  }
11251
11266
  async stop() {
@@ -11544,7 +11559,8 @@ Sessions: ${h.active_sessions} active`
11544
11559
  }
11545
11560
  static isConfigured(config) {
11546
11561
  const c = config;
11547
- return !!(c?.token && typeof c.token === "string" && c.token.length > 10);
11562
+ const token = c?.token ?? process.env.TELEGRAM_BOT_TOKEN;
11563
+ return !!(token && typeof token === "string" && token.length > 10);
11548
11564
  }
11549
11565
  };
11550
11566
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "0agent",
3
- "version": "1.0.96",
3
+ "version": "1.0.97",
4
4
  "description": "A persistent, learning AI agent that runs on your machine. An agent that learns.",
5
5
  "private": false,
6
6
  "license": "Apache-2.0",