@agenticmail/enterprise 0.5.377 → 0.5.379

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.
@@ -356,7 +356,7 @@ function createRuntimeHooks(deps) {
356
356
  var injectedMessages = [...messages];
357
357
  if (deps.knowledgeBaseEnabled !== false) {
358
358
  try {
359
- var { knowledgeBase } = await import("./routes-NIQHEAV2.js");
359
+ var { knowledgeBase } = await import("./routes-K2GAVUXI.js");
360
360
  var kbs = await knowledgeBase.listForAgent(agentId);
361
361
  if (kbs.length > 0) {
362
362
  var contextParts = [];
@@ -389,7 +389,7 @@ ${contextParts.join("\n\n")}`;
389
389
  }
390
390
  if (deps.memoryEnabled !== false) {
391
391
  try {
392
- var { memoryManager } = await import("./routes-NIQHEAV2.js");
392
+ var { memoryManager } = await import("./routes-K2GAVUXI.js");
393
393
  var memories = await memoryManager.queryMemories({
394
394
  agentId,
395
395
  limit: 10,
@@ -410,7 +410,7 @@ ${memories.map(function(m) {
410
410
  }
411
411
  if (deps.policyEnabled !== false) {
412
412
  try {
413
- var { policyEngine } = await import("./routes-NIQHEAV2.js");
413
+ var { policyEngine } = await import("./routes-K2GAVUXI.js");
414
414
  var policies = await policyEngine.getAgentPolicies(agentId, deps.orgId);
415
415
  if (policies.length > 0) {
416
416
  var policyText = policies.map(function(p) {
@@ -435,7 +435,7 @@ ${policyText}`;
435
435
  // ─── Budget Check ──────────────────────────────
436
436
  async checkBudget(agentId, _orgId, _estimatedTokens) {
437
437
  try {
438
- var { lifecycle } = await import("./routes-NIQHEAV2.js");
438
+ var { lifecycle } = await import("./routes-K2GAVUXI.js");
439
439
  var now = Date.now();
440
440
  var cacheKey = `budget_sync_${agentId}`;
441
441
  var lastSync = globalThis[cacheKey] || 0;
@@ -528,7 +528,7 @@ ${policyText}`;
528
528
  // ─── Record LLM Usage ──────────────────────────
529
529
  async recordLLMUsage(agentId, orgId, usage) {
530
530
  try {
531
- var { lifecycle } = await import("./routes-NIQHEAV2.js");
531
+ var { lifecycle } = await import("./routes-K2GAVUXI.js");
532
532
  console.log(`[hooks] recordLLMUsage: agent=${agentId}, input=${usage.inputTokens}, output=${usage.outputTokens}`);
533
533
  await lifecycle.recordLLMUsage(agentId, {
534
534
  inputTokens: usage.inputTokens,
@@ -539,7 +539,7 @@ ${policyText}`;
539
539
  console.log(`[hooks] recordLLMUsage error: ${recordErr.message}`);
540
540
  }
541
541
  try {
542
- var { activity } = await import("./routes-NIQHEAV2.js");
542
+ var { activity } = await import("./routes-K2GAVUXI.js");
543
543
  await activity.record({
544
544
  agentId,
545
545
  orgId,
@@ -587,7 +587,7 @@ ${policyText}`;
587
587
  var cacheKey = `${ctx.agentId}:${ctx.toolName}`;
588
588
  var cached = getCachedPermission(cacheKey);
589
589
  if (cached) return cached;
590
- var { permissionEngine } = await import("./routes-NIQHEAV2.js");
590
+ var { permissionEngine } = await import("./routes-K2GAVUXI.js");
591
591
  var permResult = await permissionEngine.checkPermission(ctx.agentId, ctx.toolName);
592
592
  var result = {
593
593
  allowed: permResult.allowed,
@@ -596,7 +596,7 @@ ${policyText}`;
596
596
  };
597
597
  if (result.allowed && deps.guardrailsEnabled !== false) {
598
598
  try {
599
- var { guardrails } = await import("./routes-NIQHEAV2.js");
599
+ var { guardrails } = await import("./routes-K2GAVUXI.js");
600
600
  var status = await guardrails.getStatus(ctx.agentId);
601
601
  if (status.paused || status.offDuty) {
602
602
  result.allowed = false;
@@ -608,7 +608,7 @@ ${policyText}`;
608
608
  }
609
609
  if (result.allowed && deps.dlpEnabled !== false && ctx.parameters) {
610
610
  try {
611
- var { dlp } = await import("./routes-NIQHEAV2.js");
611
+ var { dlp } = await import("./routes-K2GAVUXI.js");
612
612
  var dlpResult = await dlp.scanParameters({
613
613
  orgId: ctx.orgId,
614
614
  agentId: ctx.agentId,
@@ -628,7 +628,7 @@ ${policyText}`;
628
628
  }
629
629
  if (result.requiresApproval && result.allowed) {
630
630
  try {
631
- var { approvals } = await import("./routes-NIQHEAV2.js");
631
+ var { approvals } = await import("./routes-K2GAVUXI.js");
632
632
  var approval = await approvals.createAndWait({
633
633
  agentId: ctx.agentId,
634
634
  orgId: ctx.orgId,
@@ -658,7 +658,7 @@ ${policyText}`;
658
658
  // ─── After Tool Call ────────────────────────────
659
659
  async afterToolCall(ctx, result) {
660
660
  try {
661
- var { activity } = await import("./routes-NIQHEAV2.js");
661
+ var { activity } = await import("./routes-K2GAVUXI.js");
662
662
  await activity.record({
663
663
  agentId: ctx.agentId,
664
664
  orgId: ctx.orgId,
@@ -675,7 +675,7 @@ ${policyText}`;
675
675
  } catch {
676
676
  }
677
677
  try {
678
- var { lifecycle } = await import("./routes-NIQHEAV2.js");
678
+ var { lifecycle } = await import("./routes-K2GAVUXI.js");
679
679
  await lifecycle.recordToolCall(ctx.agentId, {
680
680
  toolId: ctx.toolName,
681
681
  tokensUsed: 0,
@@ -687,7 +687,7 @@ ${policyText}`;
687
687
  }
688
688
  if (result.success && EXTERNAL_TOOLS.has(ctx.toolName)) {
689
689
  try {
690
- var { journal } = await import("./routes-NIQHEAV2.js");
690
+ var { journal } = await import("./routes-K2GAVUXI.js");
691
691
  await journal.record({
692
692
  orgId: ctx.orgId,
693
693
  agentId: ctx.agentId,
@@ -702,7 +702,7 @@ ${policyText}`;
702
702
  }
703
703
  if (result.success && COMMUNICATION_TOOLS.has(ctx.toolName)) {
704
704
  try {
705
- var { commBus } = await import("./routes-NIQHEAV2.js");
705
+ var { commBus } = await import("./routes-K2GAVUXI.js");
706
706
  await commBus.observeMessage({
707
707
  orgId: ctx.orgId,
708
708
  agentId: ctx.agentId,
@@ -716,7 +716,7 @@ ${policyText}`;
716
716
  // ─── Session Lifecycle ──────────────────────────
717
717
  async onSessionStart(sessionId, agentId, orgId) {
718
718
  try {
719
- var { activity } = await import("./routes-NIQHEAV2.js");
719
+ var { activity } = await import("./routes-K2GAVUXI.js");
720
720
  await activity.record({
721
721
  agentId,
722
722
  orgId,
@@ -729,7 +729,7 @@ ${policyText}`;
729
729
  },
730
730
  async onSessionEnd(sessionId, agentId, orgId) {
731
731
  try {
732
- var { activity } = await import("./routes-NIQHEAV2.js");
732
+ var { activity } = await import("./routes-K2GAVUXI.js");
733
733
  await activity.record({
734
734
  agentId,
735
735
  orgId,
@@ -743,7 +743,7 @@ ${policyText}`;
743
743
  // ─── Context Compaction ─────────────────────────
744
744
  async onContextCompaction(sessionId, agentId, summary) {
745
745
  try {
746
- var { memoryManager } = await import("./routes-NIQHEAV2.js");
746
+ var { memoryManager } = await import("./routes-K2GAVUXI.js");
747
747
  await memoryManager.createMemory({
748
748
  agentId,
749
749
  orgId: deps.orgId,
@@ -2518,7 +2518,7 @@ async function runAgentLoop(config, initialMessages, hooks, options) {
2518
2518
  console.log(`[agent-loop] \u2705 Tool ${toolCall.name} succeeded (${content.length} chars): ${content.slice(0, 300)}`);
2519
2519
  }
2520
2520
  try {
2521
- const { activity } = await import("./routes-NIQHEAV2.js");
2521
+ const { activity } = await import("./routes-K2GAVUXI.js");
2522
2522
  activity.recordToolCallCompact({
2523
2523
  agentId: config.agentId,
2524
2524
  orgId: config.orgId,
@@ -3403,7 +3403,7 @@ function createRequestToolsTool(allTools, activeSets, _context) {
3403
3403
  };
3404
3404
  }
3405
3405
  async function createToolsForContext(options, context, opts) {
3406
- const { createAllTools } = await import("./agent-tools-GJUIPPHV.js");
3406
+ const { createAllTools } = await import("./agent-tools-2XUSIG4S.js");
3407
3407
  if (context === "full") {
3408
3408
  return createAllTools(options);
3409
3409
  }
@@ -1234,7 +1234,7 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
1234
1234
  const { deployTarget, company, database, domain, tunnel, cloud } = config;
1235
1235
  if (deployTarget === "cloudflare-tunnel" && tunnel) {
1236
1236
  spinner.start(`Starting local server on port ${tunnel.port}...`);
1237
- const { createServer: createServer2 } = await import("./server-Q52YXWZD.js");
1237
+ const { createServer: createServer2 } = await import("./server-OYPIKSG2.js");
1238
1238
  const server2 = createServer2({ port: tunnel.port, db, jwtSecret });
1239
1239
  const handle2 = await server2.start();
1240
1240
  spinner.succeed("Server running");
@@ -1535,7 +1535,7 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
1535
1535
  return {};
1536
1536
  }
1537
1537
  spinner.start("Starting local server...");
1538
- const { createServer } = await import("./server-Q52YXWZD.js");
1538
+ const { createServer } = await import("./server-OYPIKSG2.js");
1539
1539
  const server = createServer({ port: 3e3, db, jwtSecret });
1540
1540
  const handle = await server.start();
1541
1541
  spinner.succeed("Server running");
@@ -3,6 +3,13 @@ import {
3
3
  } from "./chunk-KFQGP6VL.js";
4
4
 
5
5
  // src/agent-tools/tools/messaging/telegram.ts
6
+ function stripMarkdown(text) {
7
+ if (!text) return text;
8
+ return text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/~~(.+?)~~/g, "$1").replace(/^#{1,6}\s+/gm, "").replace(/^[-*+]\s+/gm, "- ").replace(/```[\s\S]*?```/g, (m) => (
9
+ // ```code blocks``` → content only
10
+ m.replace(/```\w*\n?/g, "").trim()
11
+ )).replace(/`([^`]+)`/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").trim();
12
+ }
6
13
  async function tgApi(token, method, body) {
7
14
  var timeoutMs = method === "getUpdates" && body?.timeout ? (body.timeout + 15) * 1e3 : 3e4;
8
15
  var opts = { method: "POST", headers: { "Content-Type": "application/json" }, signal: AbortSignal.timeout(timeoutMs) };
@@ -41,10 +48,10 @@ function createTelegramTools(config) {
41
48
  required: ["chatId", "text"]
42
49
  },
43
50
  execute: async (_id, input) => {
51
+ var cleanText = stripMarkdown(input.text);
44
52
  var r = await tgApi(botToken, "sendMessage", {
45
53
  chat_id: input.chatId,
46
- text: input.text,
47
- parse_mode: "HTML",
54
+ text: cleanText,
48
55
  ...input.replyTo ? { reply_parameters: { message_id: input.replyTo } } : {}
49
56
  });
50
57
  if (onOutbound) try {
@@ -11,7 +11,7 @@ import {
11
11
  init_config_bus,
12
12
  init_routes,
13
13
  routes_exports
14
- } from "./chunk-VPWGFA5K.js";
14
+ } from "./chunk-ACP7QSXU.js";
15
15
  import {
16
16
  SecureVault,
17
17
  init_vault
@@ -1372,7 +1372,7 @@ function createAdminRoutes(db) {
1372
1372
  });
1373
1373
  api.get("/whatsapp/qr/:agentId", requireRole("admin"), async (c) => {
1374
1374
  try {
1375
- var { getWhatsAppQR, isWhatsAppConnected } = await import("./whatsapp-32CNVRFX.js");
1375
+ var { getWhatsAppQR, isWhatsAppConnected } = await import("./whatsapp-RAQUV6ZL.js");
1376
1376
  var agentId = c.req.param("agentId");
1377
1377
  if (isWhatsAppConnected(agentId)) {
1378
1378
  return c.json({ status: "connected" });
@@ -4683,7 +4683,7 @@ function createServer(config) {
4683
4683
  let engineInitialized = false;
4684
4684
  api.all("/engine/*", async (c, _next) => {
4685
4685
  try {
4686
- const { engineRoutes, setEngineDb } = await import("./routes-NIQHEAV2.js");
4686
+ const { engineRoutes, setEngineDb } = await import("./routes-K2GAVUXI.js");
4687
4687
  const { EngineDatabase } = await import("./db-adapter-2T56ORSD.js");
4688
4688
  if (!engineInitialized) {
4689
4689
  engineInitialized = true;
@@ -4713,13 +4713,13 @@ function createServer(config) {
4713
4713
  engineInitialized = true;
4714
4714
  if (config.runtime?.enabled) {
4715
4715
  try {
4716
- const { createAgentRuntime } = await import("./runtime-SUDXHYMB.js");
4717
- const { mountRuntimeApp, setRuntime } = await import("./routes-NIQHEAV2.js");
4716
+ const { createAgentRuntime } = await import("./runtime-5OKJ5DT6.js");
4717
+ const { mountRuntimeApp, setRuntime } = await import("./routes-K2GAVUXI.js");
4718
4718
  let getEmailConfig;
4719
4719
  let onTokenRefresh;
4720
4720
  let agentMemoryMgr;
4721
4721
  try {
4722
- const { lifecycle: lc, memoryManager: mm } = await import("./routes-NIQHEAV2.js");
4722
+ const { lifecycle: lc, memoryManager: mm } = await import("./routes-K2GAVUXI.js");
4723
4723
  agentMemoryMgr = mm;
4724
4724
  if (lc) {
4725
4725
  getEmailConfig = (agentId) => {
@@ -4758,7 +4758,7 @@ function createServer(config) {
4758
4758
  }
4759
4759
  } catch {
4760
4760
  }
4761
- const { vault: vaultRef, permissionEngine: permRef, databaseManager: dbMgr } = await import("./routes-NIQHEAV2.js");
4761
+ const { vault: vaultRef, permissionEngine: permRef, databaseManager: dbMgr } = await import("./routes-K2GAVUXI.js");
4762
4762
  const runtime = createAgentRuntime({
4763
4763
  engineDb,
4764
4764
  adminDb: config.db,
@@ -4958,7 +4958,7 @@ function createServer(config) {
4958
4958
  });
4959
4959
  (async () => {
4960
4960
  try {
4961
- const { engineRoutes, setEngineDb } = await import("./routes-NIQHEAV2.js");
4961
+ const { engineRoutes, setEngineDb } = await import("./routes-K2GAVUXI.js");
4962
4962
  const { EngineDatabase } = await import("./db-adapter-2T56ORSD.js");
4963
4963
  if (!engineInitialized) {
4964
4964
  engineInitialized = true;
@@ -4982,13 +4982,13 @@ function createServer(config) {
4982
4982
  await setEngineDb(engineDb, config.db);
4983
4983
  if (config.runtime?.enabled) {
4984
4984
  try {
4985
- const { createAgentRuntime } = await import("./runtime-SUDXHYMB.js");
4986
- const { mountRuntimeApp, setRuntime } = await import("./routes-NIQHEAV2.js");
4985
+ const { createAgentRuntime } = await import("./runtime-5OKJ5DT6.js");
4986
+ const { mountRuntimeApp, setRuntime } = await import("./routes-K2GAVUXI.js");
4987
4987
  let getEmailConfig;
4988
4988
  let onTokenRefresh;
4989
4989
  let agentMemoryMgr;
4990
4990
  try {
4991
- const { lifecycle: lc, memoryManager: mm } = await import("./routes-NIQHEAV2.js");
4991
+ const { lifecycle: lc, memoryManager: mm } = await import("./routes-K2GAVUXI.js");
4992
4992
  agentMemoryMgr = mm;
4993
4993
  if (lc) {
4994
4994
  getEmailConfig = (agentId) => {
@@ -5027,7 +5027,7 @@ function createServer(config) {
5027
5027
  }
5028
5028
  } catch {
5029
5029
  }
5030
- const { vault: vaultRef2, permissionEngine: permRef2, databaseManager: dbMgr2 } = await import("./routes-NIQHEAV2.js");
5030
+ const { vault: vaultRef2, permissionEngine: permRef2, databaseManager: dbMgr2 } = await import("./routes-K2GAVUXI.js");
5031
5031
  const runtime = createAgentRuntime({
5032
5032
  engineDb,
5033
5033
  adminDb: config.db,
@@ -5039,7 +5039,7 @@ function createServer(config) {
5039
5039
  agentMemoryManager: agentMemoryMgr,
5040
5040
  vault: vaultRef2,
5041
5041
  permissionEngine: permRef2,
5042
- hierarchyManager: (await import("./routes-NIQHEAV2.js")).hierarchyManager ?? void 0,
5042
+ hierarchyManager: (await import("./routes-K2GAVUXI.js")).hierarchyManager ?? void 0,
5043
5043
  databaseManager: dbMgr2
5044
5044
  });
5045
5045
  await runtime.start();
@@ -5053,7 +5053,7 @@ function createServer(config) {
5053
5053
  }
5054
5054
  console.log("[engine] Eagerly initialized");
5055
5055
  try {
5056
- const { lifecycle: lcRef } = await import("./routes-NIQHEAV2.js");
5056
+ const { lifecycle: lcRef } = await import("./routes-K2GAVUXI.js");
5057
5057
  if (lcRef) {
5058
5058
  const agents = Array.from(lcRef.agents?.values?.() || []);
5059
5059
  const hasLocalPm2 = agents.some((a) => {