0agent 1.0.87 → 1.0.89

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/daemon.mjs +36 -20
  2. package/package.json +1 -1
package/dist/daemon.mjs CHANGED
@@ -6344,24 +6344,35 @@ content = element.text if element else page.get_all_text()` : `content = page.ge
6344
6344
  const isCodingTask = !hasGUI && !!(task && /\b(implement|build|write|fix|refactor|debug|test|add.*feature|create.*function|edit.*file|modify|update.*code|class|function|interface|component|module|api|endpoint|schema|migration|type|hook|util|script|cli|service|handler|middleware)\b/i.test(task));
6345
6345
  const isJustdoTask = !!(task && /book|file.*itr|tax.*file|irctc|train.*ticket|flight|passport|appointment|login.*portal|pan.*card|aadhaar|monitor.*watch|price.*drop|slot.*available|justdo/i.test(task));
6346
6346
  const dateStr = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6347
+ const agentRoot = this.agentRoot || resolve7(homedir2(), ".0agent");
6348
+ const configPath = resolve7(homedir2(), ".0agent", "config.yaml");
6347
6349
  const lines = [
6348
- `You are 0agent, a persistent AI agent that lives on the user's machine.`,
6349
- `You learn from every interaction, remember across sessions, and can code, automate, browse, and more.`,
6350
+ `You are 0agent, a persistent AI agent installed at: ${agentRoot}`,
6351
+ `Config: ${configPath}`,
6350
6352
  `Working directory: ${this.cwd}`,
6351
6353
  `Date: ${dateStr}`,
6352
6354
  ``,
6353
- `PERSONALITY: Be warm, helpful, and genuinely curious about the user. You are their personal agent.`,
6354
- `If this is the first interaction, introduce yourself and learn about them \u2014 their name, role, goals.`,
6355
- `Save anything they share about themselves to memory_write immediately.`,
6355
+ `YOUR ARCHITECTURE (know thyself):`,
6356
+ ` Source code: ${agentRoot}/packages/daemon/src/`,
6357
+ ` Config file: ${configPath}`,
6358
+ ` Tools/capabilities: ${agentRoot}/packages/daemon/src/tools/`,
6359
+ ` Skills: ${agentRoot}/skills/`,
6360
+ ` Surfaces (Telegram/Slack/WhatsApp): ${agentRoot}/packages/daemon/src/surfaces/`,
6361
+ ` Memory DB: ~/.0agent/graph.db`,
6362
+ ` Memory file: ~/.0agent/MEMORY.md`,
6363
+ ` Bundle: ${agentRoot}/dist/daemon.mjs`,
6364
+ ` Rebuild: cd ${agentRoot} && node scripts/bundle.mjs && pkill -f "daemon.mjs"`,
6356
6365
  ``,
6357
- `SELF-IMPROVEMENT: When the user asks you to do something you can't do yet, or asks you to`,
6358
- `improve yourself, add a new capability, or adapt \u2014 you SHOULD modify your own source code.`,
6359
- `Your source is at: ${this.agentRoot || resolve7(homedir2(), ".0agent")}`,
6360
- `Read the relevant files, make the change, rebuild with: node scripts/bundle.mjs`,
6361
- `Then tell the user what you changed and how to reload (pkill -f daemon.mjs).`,
6366
+ `When the user mentions "the bot", "telegram", "my agent", "yourself", "this agent",`,
6367
+ `"the integration", etc. \u2014 they mean YOU. Look at YOUR config and YOUR source code first.`,
6368
+ `Do NOT search the filesystem for other projects. Start with: file_op(op:"read", path:"${configPath}")`,
6369
+ ``,
6370
+ `SELF-IMPROVEMENT: When asked to add a capability, fix something about yourself, or adapt \u2014`,
6371
+ `modify YOUR OWN source at ${agentRoot}/packages/daemon/src/. Read, edit, rebuild.`,
6372
+ ``,
6373
+ `PERSONALITY: Be warm, helpful, genuinely curious. Save user info to memory_write.`,
6362
6374
  ``,
6363
6375
  `Use tools to accomplish tasks \u2014 don't describe what to do, do it.`,
6364
- `For background processes, always redirect output: cmd > /tmp/log 2>&1 &`,
6365
6376
  `Prefer file_op edit (find-and-replace) over rewriting entire files.`,
6366
6377
  `Be concise. State what was done and where to find it.`,
6367
6378
  ``,
@@ -7905,9 +7916,7 @@ var COMPLEX_PATTERNS = [
7905
7916
  var SIMPLE_PATTERNS = [
7906
7917
  /^(hey|hi|hello|sup|yo|hola|namaste|what'?s?\s*up|how\s+are\s+you)[!?.\s,]*$/i,
7907
7918
  /^(thanks|thank\s+you|thx|ok|okay|cool|great|nice|perfect|got\s+it|sure|yep|yeah|yes|no|nah)[!?.\s,]*$/i,
7908
- /^(bye|goodbye|see\s+ya|later|good\s*(morning|evening|afternoon|night))[!?.\s,]*$/i,
7909
- /^(what\s+is|who\s+is|when\s+was|where\s+is|how\s+do\s+you|what\s+does|can\s+you)\b.{0,80}$/i,
7910
- /^(tell\s+me\s+about|summarize|summarise|tldr|tl;dr)\b.{0,80}$/i
7919
+ /^(bye|goodbye|see\s+ya|later|good\s*(morning|evening|afternoon|night))[!?.\s,]*$/i
7911
7920
  ];
7912
7921
  function routeMessage(task) {
7913
7922
  const trimmed = task.trim();
@@ -7931,7 +7940,7 @@ function routeMessage(task) {
7931
7940
  if (sentences.length > 2) {
7932
7941
  return { decision: "primary", reason: "multi-sentence request" };
7933
7942
  }
7934
- return { decision: "fast", reason: "short message, no complex indicators" };
7943
+ return { decision: "primary", reason: "unrecognized message \u2014 using full agent" };
7935
7944
  }
7936
7945
  function getFastModelId(provider, _currentModel) {
7937
7946
  switch (provider) {
@@ -11143,10 +11152,12 @@ var TelegramAdapter = class {
11143
11152
  try {
11144
11153
  const updates = await this._getUpdates();
11145
11154
  for (const u of updates) {
11146
- await this._handleUpdate(u).catch(() => {
11155
+ await this._handleUpdate(u).catch((err) => {
11156
+ console.error("[telegram] Error handling update:", err instanceof Error ? err.message : err);
11147
11157
  });
11148
11158
  }
11149
- } catch {
11159
+ } catch (err) {
11160
+ console.error("[telegram] Poll error:", err instanceof Error ? err.message : err);
11150
11161
  }
11151
11162
  if (this.running) {
11152
11163
  this.pollTimer = setTimeout(() => this._poll(), 1e3);
@@ -11213,8 +11224,8 @@ Sessions: ${h.active_sessions} active`
11213
11224
  const sessionId = this.activeSessions.get(chatId);
11214
11225
  if (sessionId) {
11215
11226
  try {
11216
- await fetch(`${this.daemonUrl}/api/sessions/${sessionId}/cancel`, {
11217
- method: "POST",
11227
+ await fetch(`${this.daemonUrl}/api/sessions/${sessionId}`, {
11228
+ method: "DELETE",
11218
11229
  signal: AbortSignal.timeout(3e3)
11219
11230
  });
11220
11231
  await this._sendMessage(chatId, "\u{1F6D1} Task cancelled.");
@@ -11254,7 +11265,12 @@ Sessions: ${h.active_sessions} active`
11254
11265
  await this._dispatchTask(chatId, userId, userName, text, msg);
11255
11266
  }
11256
11267
  async _dispatchTask(chatId, userId, userName, text, msg) {
11257
- if (!this.messageHandler) return;
11268
+ if (!this.messageHandler) {
11269
+ console.error("[telegram] No messageHandler set \u2014 SurfaceRouter may not have registered this adapter");
11270
+ await this._sendMessage(chatId, "\u26A0\uFE0F Agent not ready. Try again in a few seconds.");
11271
+ return;
11272
+ }
11273
+ console.log(`[telegram] Dispatching: "${text.slice(0, 60)}" from ${userName} (chat ${chatId})`);
11258
11274
  const inbound = {
11259
11275
  surface: "telegram",
11260
11276
  surface_user_id: String(userId),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "0agent",
3
- "version": "1.0.87",
3
+ "version": "1.0.89",
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",