@agenticmail/enterprise 0.5.612 → 0.5.614

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 (27) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/{agent-heartbeat-PHLWJ3HO.js → agent-heartbeat-HFDBZWMO.js} +1 -1
  3. package/dist/{agent-tools-KRMDJOCK.js → agent-tools-5LLIXV6A.js} +17 -6
  4. package/dist/{chunk-NMMTMHTA.js → chunk-GC77MDKW.js} +37 -31
  5. package/dist/{chunk-BUKTZ35L.js → chunk-H3JXMBTG.js} +3 -6
  6. package/dist/{chunk-I2T4HESC.js → chunk-IXAWHXMY.js} +16 -16
  7. package/dist/{chunk-5EMB2S53.js → chunk-MVD2DMAY.js} +2 -2
  8. package/dist/{chunk-TBBVEXBH.js → chunk-QVZIW5HI.js} +14 -0
  9. package/dist/{chunk-REAJCMQE.js → chunk-T26AVIAQ.js} +3 -6
  10. package/dist/chunk-UETRFOSR.js +80 -0
  11. package/dist/{chunk-KQ5EU4IA.js → chunk-VWIDJRD4.js} +49 -32
  12. package/dist/{cli-agent-V7K6HZAG.js → cli-agent-DOLO7OCU.js} +67 -23
  13. package/dist/{cli-serve-T3W5RDO4.js → cli-serve-4NLB4RK2.js} +2 -2
  14. package/dist/cli.js +3 -3
  15. package/dist/{deployer-BKBISKKF.js → deployer-M4YHMATN.js} +2 -1
  16. package/dist/index.js +12 -11
  17. package/dist/meetings-SPK24WE7.js +1 -1
  18. package/dist/{routes-VX5CXX4J.js → routes-5PUCWC4N.js} +4 -3
  19. package/dist/{runtime-RMLNHLAT.js → runtime-GML2LXIN.js} +2 -1
  20. package/dist/{server-64K32C5T.js → server-R5SICPBI.js} +5 -4
  21. package/dist/{setup-7AQLYQBS.js → setup-SLLV37YT.js} +1 -1
  22. package/dist/{telegram-NG7PNNIN.js → telegram-W765VRI5.js} +1 -1
  23. package/dist/{whatsapp-RAQUV6ZL.js → whatsapp-TBOB7TDL.js} +1 -1
  24. package/dist/workspace-P5FCSG2D.js +19 -0
  25. package/package.json +1 -1
  26. /package/dist/{chunk-CC4BHZHO.js → chunk-GAOEALTJ.js} +0 -0
  27. /package/dist/{integrations-4JDIOHQU.js → integrations-UWDEQ7Z4.js} +0 -0
@@ -0,0 +1,80 @@
1
+ import {
2
+ __esm
3
+ } from "./chunk-KFQGP6VL.js";
4
+
5
+ // src/agent-tools/workspace.ts
6
+ import { homedir } from "os";
7
+ import { join } from "path";
8
+ import { mkdirSync, writeFileSync, existsSync } from "fs";
9
+ function getWorkspaceBase() {
10
+ return process.env.AGENTICMAIL_WORKSPACE_DIR || join(homedir(), ".agenticmail", "workspaces");
11
+ }
12
+ function getAgentWorkspaceDir(agentId) {
13
+ return join(getWorkspaceBase(), agentId || "default");
14
+ }
15
+ function getAgentSubdir(agentId, name) {
16
+ const dir = join(getAgentWorkspaceDir(agentId), name);
17
+ try {
18
+ mkdirSync(dir, { recursive: true });
19
+ } catch {
20
+ }
21
+ return dir;
22
+ }
23
+ function ensureAgentWorkspace(agentId, displayName) {
24
+ const root = getAgentWorkspaceDir(agentId);
25
+ try {
26
+ mkdirSync(root, { recursive: true });
27
+ for (const sub of Object.keys(WORKSPACE_SUBDIRS)) {
28
+ mkdirSync(join(root, sub), { recursive: true });
29
+ }
30
+ const md = join(root, "WORKSPACE.md");
31
+ if (!existsSync(md)) writeFileSync(md, renderWorkspaceMarkdown(root, displayName));
32
+ } catch {
33
+ }
34
+ return root;
35
+ }
36
+ function renderWorkspaceMarkdown(root, displayName) {
37
+ const lines = [];
38
+ lines.push(`# WORKSPACE.md \u2014 ${displayName ? displayName + "'s" : "Your"} permanent workspace`);
39
+ lines.push("");
40
+ lines.push(`Your permanent working directory is:
41
+
42
+ ${root}
43
+ `);
44
+ lines.push("ALWAYS work from here. NEVER write to /tmp \u2014 OS temp files are wiped and lost.");
45
+ lines.push("This folder persists across sessions, restarts, and reboots. Keep it tidy.");
46
+ lines.push("");
47
+ lines.push("## Folder layout");
48
+ lines.push("");
49
+ for (const [name, desc] of Object.entries(WORKSPACE_SUBDIRS)) {
50
+ lines.push(`- \`${name}/\` \u2014 ${desc}`);
51
+ }
52
+ lines.push("");
53
+ lines.push("Save email/HTML templates to `templates/`, attachments and images to `media/`,");
54
+ lines.push("finished deliverables to `exports/`, and use `tmp/` (inside the workspace) for scratch.");
55
+ return lines.join("\n") + "\n";
56
+ }
57
+ var WORKSPACE_SUBDIRS;
58
+ var init_workspace = __esm({
59
+ "src/agent-tools/workspace.ts"() {
60
+ WORKSPACE_SUBDIRS = {
61
+ media: "Images, audio, video, and inbound/outbound message attachments",
62
+ files: "Documents and generated deliverables (reports, sheets, etc.)",
63
+ templates: "Reusable email / HTML / document templates",
64
+ exports: "Rendered final outputs (PDF, MP4, ZIP, etc.) ready to send",
65
+ projects: "Multi-file working projects (code, video projects, sites)",
66
+ data: "Local scratch databases and JSON/CSV working data",
67
+ tmp: "Scratch space \u2014 local & ephemeral, but NOT the OS /tmp (still under your workspace)"
68
+ };
69
+ }
70
+ });
71
+
72
+ export {
73
+ WORKSPACE_SUBDIRS,
74
+ getWorkspaceBase,
75
+ getAgentWorkspaceDir,
76
+ getAgentSubdir,
77
+ ensureAgentWorkspace,
78
+ renderWorkspaceMarkdown,
79
+ init_workspace
80
+ };
@@ -1,3 +1,7 @@
1
+ import {
2
+ AgentStatusTracker,
3
+ init_agent_status
4
+ } from "./chunk-FQWJMPKW.js";
1
5
  import {
2
6
  DatabaseConnectionManager,
3
7
  init_connection_manager,
@@ -7,6 +11,12 @@ import {
7
11
  init_agent_tools,
8
12
  init_types
9
13
  } from "./chunk-TK55CSBH.js";
14
+ import {
15
+ AgentConfigGenerator,
16
+ DeploymentEngine,
17
+ init_agent_config,
18
+ init_deployer
19
+ } from "./chunk-QVZIW5HI.js";
10
20
  import {
11
21
  init_messaging_history,
12
22
  storeMessage
@@ -28,10 +38,6 @@ import {
28
38
  TaskQueueManager,
29
39
  init_task_queue
30
40
  } from "./chunk-ET6WZFPS.js";
31
- import {
32
- AgentStatusTracker,
33
- init_agent_status
34
- } from "./chunk-FQWJMPKW.js";
35
41
  import {
36
42
  BUILTIN_SKILLS,
37
43
  PRESET_PROFILES,
@@ -39,12 +45,6 @@ import {
39
45
  SKILL_SUITES,
40
46
  init_skills as init_skills2
41
47
  } from "./chunk-HGBLI5HF.js";
42
- import {
43
- AgentConfigGenerator,
44
- DeploymentEngine,
45
- init_agent_config,
46
- init_deployer
47
- } from "./chunk-TBBVEXBH.js";
48
48
  import {
49
49
  getConfig,
50
50
  init_transport_encryption,
@@ -760,6 +760,25 @@ var init_lifecycle = __esm({
760
760
  this.agents.set(agent.id, agent);
761
761
  await this.persistAgent(agent);
762
762
  this.emitEvent(agent, "created", { createdBy });
763
+ try {
764
+ const { ensureAgentWorkspace, renderWorkspaceMarkdown } = await import("./workspace-P5FCSG2D.js");
765
+ const displayName = config.identity?.displayName || config.displayName || config.name;
766
+ const wsRoot = ensureAgentWorkspace(agent.id, displayName);
767
+ try {
768
+ const { memoryManager: memoryManager2 } = await import("./routes-5PUCWC4N.js");
769
+ await memoryManager2.createMemory({
770
+ agentId: agent.id,
771
+ orgId,
772
+ category: "system_notice",
773
+ title: "My permanent workspace location",
774
+ content: renderWorkspaceMarkdown(wsRoot, displayName),
775
+ source: "system",
776
+ importance: "high"
777
+ });
778
+ } catch {
779
+ }
780
+ } catch {
781
+ }
763
782
  return agent;
764
783
  }
765
784
  /**
@@ -7055,7 +7074,7 @@ function createAgentRoutes(opts) {
7055
7074
  });
7056
7075
  router.post("/system/install-pm2", async (c) => {
7057
7076
  try {
7058
- const { ensurePm2 } = await import("./deployer-BKBISKKF.js");
7077
+ const { ensurePm2 } = await import("./deployer-M4YHMATN.js");
7059
7078
  const result = await ensurePm2();
7060
7079
  if (result.installed) {
7061
7080
  return c.json({ success: true, message: `PM2 ${result.version} installed successfully` });
@@ -7311,7 +7330,7 @@ function createAgentRoutes(opts) {
7311
7330
  }
7312
7331
  const managedAgent = await lifecycle2.createAgent(orgId, config, actor);
7313
7332
  try {
7314
- const { knowledgeBase: kbEngine } = await import("./routes-VX5CXX4J.js");
7333
+ const { knowledgeBase: kbEngine } = await import("./routes-5PUCWC4N.js");
7315
7334
  const allKbs = kbEngine.getAllKnowledgeBases();
7316
7335
  const clientOrgId = managedAgent?.clientOrgId || config?.clientOrgId || null;
7317
7336
  let kbAssigned = 0;
@@ -9256,7 +9275,7 @@ function createAgentRoutes(opts) {
9256
9275
  try {
9257
9276
  const body = await c.req.json().catch(() => ({}));
9258
9277
  const mode = body.mode || "";
9259
- const { createWhatsAppTools } = await import("./whatsapp-RAQUV6ZL.js");
9278
+ const { createWhatsAppTools } = await import("./whatsapp-TBOB7TDL.js");
9260
9279
  const dataDir = process.env.DATA_DIR || "/tmp/agenticmail-data";
9261
9280
  const connId = mode === "business" ? `biz-${agentId}` : agentId;
9262
9281
  const connDir = mode === "business" ? `${dataDir}/agents/${agentId}/whatsapp-business` : `${dataDir}/agents/${agentId}/whatsapp`;
@@ -9273,7 +9292,7 @@ function createAgentRoutes(opts) {
9273
9292
  const agentId = c.req.param("id");
9274
9293
  const mode = c.req.query("mode") || "";
9275
9294
  try {
9276
- const { getConnectionStatus } = await import("./whatsapp-RAQUV6ZL.js");
9295
+ const { getConnectionStatus } = await import("./whatsapp-TBOB7TDL.js");
9277
9296
  const connId = mode === "business" ? `biz-${agentId}` : agentId;
9278
9297
  return c.json(getConnectionStatus(connId));
9279
9298
  } catch {
@@ -9286,7 +9305,7 @@ function createAgentRoutes(opts) {
9286
9305
  const body = await c.req.json().catch(() => ({}));
9287
9306
  const mode = body.mode || "";
9288
9307
  const connId = mode === "business" ? `biz-${agentId}` : agentId;
9289
- const { sendTestMessage } = await import("./whatsapp-RAQUV6ZL.js");
9308
+ const { sendTestMessage } = await import("./whatsapp-TBOB7TDL.js");
9290
9309
  const result = await sendTestMessage(connId, body.to);
9291
9310
  return c.json(result);
9292
9311
  } catch (err) {
@@ -9297,7 +9316,7 @@ function createAgentRoutes(opts) {
9297
9316
  const agentId = c.req.param("id");
9298
9317
  try {
9299
9318
  const body = await c.req.json();
9300
- const { getConnection } = await import("./whatsapp-RAQUV6ZL.js");
9319
+ const { getConnection } = await import("./whatsapp-TBOB7TDL.js");
9301
9320
  const conn = getConnection(agentId);
9302
9321
  if (!conn?.connected) return c.json({ error: "Not connected" }, 503);
9303
9322
  const toJid = (to) => to?.includes("@") ? to : (to || "").replace(/[^0-9]/g, "") + "@s.whatsapp.net";
@@ -9341,7 +9360,7 @@ function createAgentRoutes(opts) {
9341
9360
  try {
9342
9361
  const body = await c.req.json().catch(() => ({}));
9343
9362
  const mode = body.mode || "";
9344
- const { createWhatsAppTools } = await import("./whatsapp-RAQUV6ZL.js");
9363
+ const { createWhatsAppTools } = await import("./whatsapp-TBOB7TDL.js");
9345
9364
  const dataDir = process.env.DATA_DIR || "/tmp/agenticmail-data";
9346
9365
  const connId = mode === "business" ? `biz-${agentId}` : agentId;
9347
9366
  const connDir = mode === "business" ? `${dataDir}/agents/${agentId}/whatsapp-business` : `${dataDir}/agents/${agentId}/whatsapp`;
@@ -24422,15 +24441,16 @@ var init_messaging_poller = __esm({
24422
24441
  port: agents[0].port || 3100
24423
24442
  };
24424
24443
  if (this.config.getCapability("whatsapp")) {
24425
- var dataDir = process.env.DATA_DIR || "/tmp/agenticmail-data";
24444
+ var { getAgentWorkspaceDir } = await import("./workspace-P5FCSG2D.js");
24445
+ var { join: _join } = await import("path");
24426
24446
  var agentEndpoints = [];
24427
24447
  for (var ag of agents) {
24428
24448
  var ep = { id: ag.id, displayName: ag.displayName || ag.name || "Agent", host: ag.host || "localhost", port: ag.port || 3100 };
24429
- agentEndpoints.push({ id: ag.id, dataDir: `${dataDir}/agents/${ag.id}/whatsapp`, endpoint: ep });
24449
+ agentEndpoints.push({ id: ag.id, dataDir: _join(getAgentWorkspaceDir(ag.id), "whatsapp"), endpoint: ep });
24430
24450
  await this.startWhatsApp(ep);
24431
24451
  }
24432
24452
  try {
24433
- var { autoStartConnections } = await import("./whatsapp-RAQUV6ZL.js");
24453
+ var { autoStartConnections } = await import("./whatsapp-TBOB7TDL.js");
24434
24454
  await autoStartConnections(agentEndpoints.map((a) => ({ id: a.id, dataDir: a.dataDir })));
24435
24455
  } catch (err) {
24436
24456
  console.error("[messaging] WhatsApp auto-start failed:", err.message);
@@ -24544,7 +24564,7 @@ var init_messaging_poller = __esm({
24544
24564
  // ─── WhatsApp (event-driven — Baileys WebSocket) ──
24545
24565
  async startWhatsApp(agent) {
24546
24566
  try {
24547
- var { onWhatsAppMessage } = await import("./whatsapp-RAQUV6ZL.js");
24567
+ var { onWhatsAppMessage } = await import("./whatsapp-TBOB7TDL.js");
24548
24568
  var unsub = onWhatsAppMessage(agent.id, (msg) => {
24549
24569
  var waMediaFiles;
24550
24570
  if (msg.mediaPath && msg.mediaType) {
@@ -24570,7 +24590,7 @@ var init_messaging_poller = __esm({
24570
24590
  }
24571
24591
  // ─── Telegram (webhook preferred, polling fallback) ─
24572
24592
  async startTelegram(botToken, agent) {
24573
- var { setTelegramWebhook, deleteTelegramWebhook, getTelegramWebhookInfo } = await import("./telegram-NG7PNNIN.js");
24593
+ var { setTelegramWebhook, deleteTelegramWebhook, getTelegramWebhookInfo } = await import("./telegram-W765VRI5.js");
24574
24594
  var { randomBytes: randomBytes2 } = await import("crypto");
24575
24595
  var webhookSecret = randomBytes2(32).toString("hex");
24576
24596
  if (this.config.publicUrl && this.config.app) {
@@ -24649,7 +24669,7 @@ var init_messaging_poller = __esm({
24649
24669
  offset = await loadOffset();
24650
24670
  while (running && this.running) {
24651
24671
  try {
24652
- var { pollTelegramUpdates } = await import("./telegram-NG7PNNIN.js");
24672
+ var { pollTelegramUpdates } = await import("./telegram-W765VRI5.js");
24653
24673
  var { updates, nextOffset } = await pollTelegramUpdates(botToken, offset, 25);
24654
24674
  if (nextOffset > offset) {
24655
24675
  offset = nextOffset;
@@ -24766,13 +24786,10 @@ ${desc}` : desc;
24766
24786
  var downloadUrl = `https://api.telegram.org/file/bot${botToken}/${filePath}`;
24767
24787
  var response = await fetch(downloadUrl);
24768
24788
  if (!response.ok) return null;
24769
- var { join: join3, dirname: dirname3 } = await import("path");
24770
- var { mkdirSync, writeFileSync } = await import("fs");
24771
- var mediaDir = join3(agent.dataDir || `/tmp/agents/${agent.id}`, "media");
24772
- try {
24773
- mkdirSync(mediaDir, { recursive: true });
24774
- } catch {
24775
- }
24789
+ var { join: join3 } = await import("path");
24790
+ var { writeFileSync } = await import("fs");
24791
+ var { getAgentSubdir } = await import("./workspace-P5FCSG2D.js");
24792
+ var mediaDir = getAgentSubdir(agent.id, "media");
24776
24793
  var ext = filePath.split(".").pop() || (mediaType === "photo" ? "jpg" : "bin");
24777
24794
  var localName = fileName || `${mediaType}-${Date.now()}.${ext}`;
24778
24795
  var localPath = join3(mediaDir, localName);
@@ -25042,7 +25059,7 @@ ${desc}` : desc;
25042
25059
  var typingJson = await typingResp.json();
25043
25060
  console.log(`[messaging] Telegram typing sent to ${chatId}: ${JSON.stringify(typingJson)}`);
25044
25061
  } else if (ctx.source === "whatsapp") {
25045
- var { getConnection } = await import("./whatsapp-RAQUV6ZL.js");
25062
+ var { getConnection } = await import("./whatsapp-TBOB7TDL.js");
25046
25063
  var conn = getConnection(agent.id);
25047
25064
  if (!conn?.connected) return;
25048
25065
  var jid = ctx.senderId.includes("@") ? ctx.senderId : ctx.senderId.replace(/[^0-9]/g, "") + "@s.whatsapp.net";
@@ -25057,7 +25074,7 @@ ${desc}` : desc;
25057
25074
  async sendDirectReply(agent, ctx, text) {
25058
25075
  try {
25059
25076
  if (ctx.source === "whatsapp") {
25060
- var { getConnection } = await import("./whatsapp-RAQUV6ZL.js");
25077
+ var { getConnection } = await import("./whatsapp-TBOB7TDL.js");
25061
25078
  var conn = getConnection(agent.id);
25062
25079
  if (!conn?.connected) return;
25063
25080
  var jid = ctx.senderId.includes("@") ? ctx.senderId : ctx.senderId.replace(/[^0-9]/g, "") + "@s.whatsapp.net";
@@ -2,13 +2,19 @@ import {
2
2
  TaskQueueManager,
3
3
  init_task_queue
4
4
  } from "./chunk-ET6WZFPS.js";
5
+ import {
6
+ getAgentSubdir,
7
+ init_workspace
8
+ } from "./chunk-UETRFOSR.js";
5
9
  import "./chunk-KFQGP6VL.js";
6
10
 
7
11
  // src/cli-agent.ts
12
+ init_workspace();
8
13
  init_task_queue();
9
14
  import { Hono } from "hono";
10
15
  import { serve } from "@hono/node-server";
11
16
  import { existsSync, readFileSync, writeFileSync } from "fs";
17
+ import { join as _joinPath } from "path";
12
18
 
13
19
  // src/engine/task-queue-before-spawn.ts
14
20
  function extractTaskMetadata(task) {
@@ -415,6 +421,33 @@ if (_LOG_THRESHOLD > 2) {
415
421
  console.warn = function() {
416
422
  };
417
423
  }
424
+ var _typingTimers = /* @__PURE__ */ new Map();
425
+ var _TYPING_REFRESH_MS = 4e3;
426
+ var _TYPING_MAX_MS = 15 * 6e4;
427
+ function startTypingIndicator(key, tick) {
428
+ if (!key || _typingTimers.has(key)) return;
429
+ try {
430
+ tick();
431
+ } catch {
432
+ }
433
+ const interval = setInterval(() => {
434
+ try {
435
+ tick();
436
+ } catch {
437
+ }
438
+ }, _TYPING_REFRESH_MS);
439
+ const safety = setTimeout(() => stopTypingIndicator(key), _TYPING_MAX_MS);
440
+ interval.unref?.();
441
+ safety.unref?.();
442
+ _typingTimers.set(key, { interval, safety });
443
+ }
444
+ function stopTypingIndicator(key) {
445
+ const t = _typingTimers.get(key);
446
+ if (!t) return;
447
+ clearInterval(t.interval);
448
+ clearTimeout(t.safety);
449
+ _typingTimers.delete(key);
450
+ }
418
451
  function _stripMd(text) {
419
452
  if (!text) return text;
420
453
  return text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/~~(.+?)~~/g, "$1").replace(/^#{1,6}\s+/gm, "").replace(/```[\s\S]*?```/g, (m) => m.replace(/```\w*\n?/g, "").trim()).replace(/`([^`]+)`/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").trim();
@@ -889,7 +922,7 @@ async function runAgent(_args) {
889
922
  const agent = agentRow[0];
890
923
  console.log(` Agent: ${agent.display_name || agent.name}`);
891
924
  console.log(` State: ${agent.state}`);
892
- const routes = await import("./routes-VX5CXX4J.js");
925
+ const routes = await import("./routes-5PUCWC4N.js");
893
926
  await routes.lifecycle.setDb(engineDb);
894
927
  await routes.lifecycle.loadFromDb();
895
928
  routes.lifecycle.standaloneMode = true;
@@ -957,7 +990,7 @@ async function runAgent(_args) {
957
990
  }
958
991
  Object.assign(dbApiKeys, fresh);
959
992
  try {
960
- const routesMod = await import("./routes-VX5CXX4J.js");
993
+ const routesMod = await import("./routes-5PUCWC4N.js");
961
994
  routesMod.knowledgeBase?.setApiKeys?.(dbApiKeys);
962
995
  } catch {
963
996
  }
@@ -998,10 +1031,10 @@ async function runAgent(_args) {
998
1031
  setInterval(() => {
999
1032
  void _loadProviderKeys();
1000
1033
  }, 3e4).unref();
1001
- const { createAgentRuntime } = await import("./runtime-RMLNHLAT.js");
1034
+ const { createAgentRuntime } = await import("./runtime-GML2LXIN.js");
1002
1035
  let orgIntMgr = null;
1003
1036
  try {
1004
- const { orgIntegrations: oi } = await import("./routes-VX5CXX4J.js");
1037
+ const { orgIntegrations: oi } = await import("./routes-5PUCWC4N.js");
1005
1038
  orgIntMgr = oi;
1006
1039
  } catch {
1007
1040
  }
@@ -1388,7 +1421,7 @@ Please complete this task now.`,
1388
1421
  console.log(`[TaskPoller] Delivered recovery response to Telegram chat ${dc.chatId}`);
1389
1422
  }
1390
1423
  } else if (dc.channel === "whatsapp") {
1391
- const { getOrCreateConnection, toJid } = await import("./whatsapp-RAQUV6ZL.js");
1424
+ const { getOrCreateConnection, toJid } = await import("./whatsapp-TBOB7TDL.js");
1392
1425
  const conn = await getOrCreateConnection(agentId);
1393
1426
  if (conn.connected && conn.sock) {
1394
1427
  await conn.sock.sendMessage(toJid(dc.chatId), { text: lastText.trim() });
@@ -1590,7 +1623,7 @@ Please complete this task now.`,
1590
1623
  }
1591
1624
  if (scope === "all" || scope === "permissions") {
1592
1625
  try {
1593
- const { permissionEngine } = await import("./routes-VX5CXX4J.js");
1626
+ const { permissionEngine } = await import("./routes-5PUCWC4N.js");
1594
1627
  await permissionEngine.setDb(engineDb);
1595
1628
  reloaded.push("permissions");
1596
1629
  } catch {
@@ -1630,7 +1663,7 @@ Please complete this task now.`,
1630
1663
  }
1631
1664
  if (scope === "all" || scope === "guardrails") {
1632
1665
  try {
1633
- const { guardrails } = await import("./routes-VX5CXX4J.js");
1666
+ const { guardrails } = await import("./routes-5PUCWC4N.js");
1634
1667
  await guardrails.loadFromDb?.();
1635
1668
  reloaded.push("guardrails");
1636
1669
  } catch {
@@ -1702,30 +1735,36 @@ Please complete this task now.`,
1702
1735
  }
1703
1736
  });
1704
1737
  app.post("/api/runtime/chat", async (c) => {
1738
+ let typingKey = "";
1705
1739
  try {
1706
1740
  const ctx = await c.req.json();
1707
1741
  if (typeof ctx.messageText !== "string") ctx.messageText = "";
1708
1742
  const isMessagingSource = ["whatsapp", "telegram"].includes(ctx.source);
1709
1743
  console.log(`[chat] Message from ${ctx.senderName} (${ctx.senderEmail}) in ${ctx.source || ctx.spaceName}: "${ctx.messageText.slice(0, 80)}"`);
1744
+ typingKey = ctx.source === "telegram" ? `tg:${ctx.spaceId || ctx.senderEmail}` : ctx.source === "whatsapp" ? `wa:${ctx.senderEmail}` : "";
1710
1745
  if (ctx.source === "telegram") {
1711
- const tgToken = agent.config?.channels?.telegram?.botToken;
1746
+ const tgToken = agent.config?.channels?.telegram?.botToken || agent.config?.messagingChannels?.telegram?.botToken;
1712
1747
  const chatId = ctx.spaceId || ctx.senderEmail;
1713
1748
  if (tgToken && chatId) {
1714
- fetch(`https://api.telegram.org/bot${tgToken}/sendChatAction`, {
1715
- method: "POST",
1716
- headers: { "Content-Type": "application/json" },
1717
- body: JSON.stringify({ chat_id: chatId, action: "typing" })
1718
- }).catch(() => {
1749
+ startTypingIndicator(typingKey, () => {
1750
+ fetch(`https://api.telegram.org/bot${tgToken}/sendChatAction`, {
1751
+ method: "POST",
1752
+ headers: { "Content-Type": "application/json" },
1753
+ body: JSON.stringify({ chat_id: chatId, action: "typing" })
1754
+ }).catch(() => {
1755
+ });
1719
1756
  });
1720
1757
  }
1721
1758
  } else if (ctx.source === "whatsapp") {
1722
- import("./whatsapp-RAQUV6ZL.js").then(({ getConnection }) => {
1723
- const conn = getConnection(AGENT_ID);
1724
- if (!conn?.connected) return;
1725
- const jid = ctx.senderEmail.includes("@") ? ctx.senderEmail : ctx.senderEmail.replace(/[^0-9]/g, "") + "@s.whatsapp.net";
1726
- conn.sock.presenceSubscribe(jid).then(() => conn.sock.sendPresenceUpdate("composing", jid)).catch(() => {
1759
+ const jid = ctx.senderEmail.includes("@") ? ctx.senderEmail : ctx.senderEmail.replace(/[^0-9]/g, "") + "@s.whatsapp.net";
1760
+ startTypingIndicator(typingKey, () => {
1761
+ import("./whatsapp-TBOB7TDL.js").then(({ getConnection }) => {
1762
+ const conn = getConnection(AGENT_ID);
1763
+ if (!conn?.connected) return;
1764
+ conn.sock.presenceSubscribe(jid).then(() => conn.sock.sendPresenceUpdate("composing", jid)).catch(() => {
1765
+ });
1766
+ }).catch(() => {
1727
1767
  });
1728
- }).catch(() => {
1729
1768
  });
1730
1769
  }
1731
1770
  const agentDomain = agent.email?.split("@")[1] || "agenticmail.io";
@@ -2026,6 +2065,7 @@ ${ambientContext}` : ""
2026
2065
  }
2027
2066
  });
2028
2067
  runtime.onSessionComplete(session.id, async (result) => {
2068
+ stopTypingIndicator(typingKey);
2029
2069
  sessionRouter?.unregister(agentId, session.id);
2030
2070
  if (taskId) {
2031
2071
  const usage = result?.usage || {};
@@ -2089,7 +2129,7 @@ ${ambientContext}` : ""
2089
2129
  if (isMessagingSource) {
2090
2130
  if (ctx.source === "whatsapp") {
2091
2131
  try {
2092
- const { getOrCreateConnection, toJid } = await import("./whatsapp-RAQUV6ZL.js");
2132
+ const { getOrCreateConnection, toJid } = await import("./whatsapp-TBOB7TDL.js");
2093
2133
  const conn = await getOrCreateConnection(AGENT_ID);
2094
2134
  if (conn.connected && conn.sock) {
2095
2135
  await conn.sock.sendMessage(toJid(ctx.senderEmail), { text: _stripMd(lastText) });
@@ -2172,6 +2212,10 @@ ${ambientContext}` : ""
2172
2212
  }
2173
2213
  return c.json({ ok: true, sessionId: session.id });
2174
2214
  } catch (err) {
2215
+ try {
2216
+ stopTypingIndicator(typingKey);
2217
+ } catch {
2218
+ }
2175
2219
  console.error(`[chat] Error: ${err.message}`);
2176
2220
  return c.json({ error: err.message }, 500);
2177
2221
  }
@@ -2343,7 +2387,7 @@ ${identity.personality.slice(0, 800)}` : "";
2343
2387
  if (defaultWaChat) waChatIds.add(String(defaultWaChat));
2344
2388
  if (waChatIds.size > 0) {
2345
2389
  try {
2346
- const { getConnection, toJid } = await import("./whatsapp-RAQUV6ZL.js");
2390
+ const { getConnection, toJid } = await import("./whatsapp-TBOB7TDL.js");
2347
2391
  const conn = await getConnection(agentId);
2348
2392
  if (conn?.connected && conn?.sock) {
2349
2393
  for (const chatId of waChatIds) {
@@ -2832,7 +2876,7 @@ Available tools: ${providerType === "imap" ? "email_send (to, subject, body)" :
2832
2876
  console.log("[guardrails] Disabled via autonomy settings");
2833
2877
  }
2834
2878
  try {
2835
- const { AgentHeartbeatManager } = await import("./agent-heartbeat-PHLWJ3HO.js");
2879
+ const { AgentHeartbeatManager } = await import("./agent-heartbeat-HFDBZWMO.js");
2836
2880
  const hbOrgRows = await engineDb.query(`SELECT org_id FROM managed_agents WHERE id = $1`, [AGENT_ID]);
2837
2881
  const hbOrgId = hbOrgRows?.[0]?.org_id || "";
2838
2882
  const hbManagerEmail = config.managerEmail || (config.manager?.type === "external" ? config.manager.email : null);
@@ -2917,7 +2961,7 @@ async function startCalendarPolling(agentId, config, runtime, _engineDb, _memory
2917
2961
  };
2918
2962
  const CALENDAR_POLL_INTERVAL = 5 * 6e4;
2919
2963
  const joinedMeetings = /* @__PURE__ */ new Set();
2920
- const joinedMeetingsFile = `/tmp/agenticmail-joined-meetings-${agentId}.json`;
2964
+ const joinedMeetingsFile = _joinPath(getAgentSubdir(agentId, "data"), "joined-meetings.json");
2921
2965
  try {
2922
2966
  if (existsSync(joinedMeetingsFile)) {
2923
2967
  const data = JSON.parse(readFileSync(joinedMeetingsFile, "utf-8"));
@@ -94,7 +94,7 @@ async function runServe(_args) {
94
94
  process.exit(1);
95
95
  }
96
96
  const { createAdapter, smartDbConfig } = await import("./factory-RUGZPU7W.js");
97
- const { createServer } = await import("./server-64K32C5T.js");
97
+ const { createServer } = await import("./server-R5SICPBI.js");
98
98
  const db = await createAdapter(smartDbConfig(DATABASE_URL));
99
99
  await db.migrate();
100
100
  const server = createServer({
@@ -120,7 +120,7 @@ async function runServe(_args) {
120
120
  });
121
121
  setTimeout(async () => {
122
122
  try {
123
- const routes = await import("./routes-VX5CXX4J.js");
123
+ const routes = await import("./routes-5PUCWC4N.js");
124
124
  setWatcherRuntime(
125
125
  () => routes.getRuntime?.() || null
126
126
  );
package/dist/cli.js CHANGED
@@ -65,14 +65,14 @@ Skill Development:
65
65
  break;
66
66
  case "serve":
67
67
  case "start":
68
- import("./cli-serve-T3W5RDO4.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
68
+ import("./cli-serve-4NLB4RK2.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
69
69
  break;
70
70
  case "agent":
71
- import("./cli-agent-V7K6HZAG.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
71
+ import("./cli-agent-DOLO7OCU.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
72
72
  break;
73
73
  case "setup":
74
74
  default:
75
- import("./setup-7AQLYQBS.js").then((m) => m.runSetupWizard()).catch(fatal);
75
+ import("./setup-SLLV37YT.js").then((m) => m.runSetupWizard()).catch(fatal);
76
76
  break;
77
77
  }
78
78
  function fatal(err) {
@@ -2,7 +2,8 @@ import {
2
2
  DeploymentEngine,
3
3
  ensurePm2,
4
4
  init_deployer
5
- } from "./chunk-TBBVEXBH.js";
5
+ } from "./chunk-QVZIW5HI.js";
6
+ import "./chunk-UETRFOSR.js";
6
7
  import "./chunk-KFQGP6VL.js";
7
8
  init_deployer();
8
9
  export {
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  provision,
15
15
  runSetupWizard
16
- } from "./chunk-5EMB2S53.js";
16
+ } from "./chunk-MVD2DMAY.js";
17
17
  import {
18
18
  AgentRuntime,
19
19
  EmailChannel,
@@ -28,7 +28,7 @@ import {
28
28
  executeTool,
29
29
  runAgentLoop,
30
30
  toolsToDefinitions
31
- } from "./chunk-NMMTMHTA.js";
31
+ } from "./chunk-GC77MDKW.js";
32
32
  import {
33
33
  ValidationError,
34
34
  auditLogger,
@@ -42,7 +42,7 @@ import {
42
42
  requireRole,
43
43
  securityHeaders,
44
44
  validate
45
- } from "./chunk-I2T4HESC.js";
45
+ } from "./chunk-IXAWHXMY.js";
46
46
  import "./chunk-DJBCRQTD.js";
47
47
  import {
48
48
  PROVIDER_REGISTRY,
@@ -83,7 +83,8 @@ import {
83
83
  init_storage_manager,
84
84
  init_tenant,
85
85
  init_workforce
86
- } from "./chunk-KQ5EU4IA.js";
86
+ } from "./chunk-VWIDJRD4.js";
87
+ import "./chunk-FQWJMPKW.js";
87
88
  import "./chunk-K2GKUQSB.js";
88
89
  import "./chunk-TK55CSBH.js";
89
90
  import {
@@ -96,6 +97,12 @@ import {
96
97
  sqliteToMySQL,
97
98
  sqliteToPostgres
98
99
  } from "./chunk-CZPHXLRP.js";
100
+ import {
101
+ AgentConfigGenerator,
102
+ DeploymentEngine,
103
+ init_agent_config,
104
+ init_deployer
105
+ } from "./chunk-QVZIW5HI.js";
99
106
  import "./chunk-Z7NVD3OQ.js";
100
107
  import {
101
108
  AgentMemoryManager,
@@ -105,19 +112,13 @@ import "./chunk-AF3WSNVX.js";
105
112
  import "./chunk-V6QTSKGO.js";
106
113
  import "./chunk-74ZCQKYU.js";
107
114
  import "./chunk-ET6WZFPS.js";
108
- import "./chunk-FQWJMPKW.js";
115
+ import "./chunk-UETRFOSR.js";
109
116
  import {
110
117
  BUILTIN_SKILLS,
111
118
  PRESET_PROFILES,
112
119
  PermissionEngine,
113
120
  init_skills
114
121
  } from "./chunk-HGBLI5HF.js";
115
- import {
116
- AgentConfigGenerator,
117
- DeploymentEngine,
118
- init_agent_config,
119
- init_deployer
120
- } from "./chunk-TBBVEXBH.js";
121
122
  import "./chunk-FLQ5FLHW.js";
122
123
  import "./chunk-GBW6SJPH.js";
123
124
  import "./chunk-X5IZUXDC.js";
@@ -2,7 +2,7 @@ import {
2
2
  createMeetingTools,
3
3
  ensureBrowser,
4
4
  sendChatMessage
5
- } from "./chunk-CC4BHZHO.js";
5
+ } from "./chunk-GAOEALTJ.js";
6
6
  import "./chunk-X5IZUXDC.js";
7
7
  import "./chunk-KFQGP6VL.js";
8
8
  export {
@@ -37,18 +37,19 @@ import {
37
37
  tenants,
38
38
  vault,
39
39
  workforce
40
- } from "./chunk-KQ5EU4IA.js";
40
+ } from "./chunk-VWIDJRD4.js";
41
+ import "./chunk-FQWJMPKW.js";
41
42
  import "./chunk-K2GKUQSB.js";
42
43
  import "./chunk-TK55CSBH.js";
44
+ import "./chunk-QVZIW5HI.js";
43
45
  import "./chunk-Z7NVD3OQ.js";
44
46
  import "./chunk-VSBC4SWO.js";
45
47
  import "./chunk-AF3WSNVX.js";
46
48
  import "./chunk-V6QTSKGO.js";
47
49
  import "./chunk-74ZCQKYU.js";
48
50
  import "./chunk-ET6WZFPS.js";
49
- import "./chunk-FQWJMPKW.js";
51
+ import "./chunk-UETRFOSR.js";
50
52
  import "./chunk-HGBLI5HF.js";
51
- import "./chunk-TBBVEXBH.js";
52
53
  import "./chunk-FLQ5FLHW.js";
53
54
  import "./chunk-WUAWWKTN.js";
54
55
  import "./chunk-YDD5TC5Q.js";