@agenticmail/enterprise 0.5.389 → 0.5.391

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.
@@ -466,7 +466,7 @@ var AgentHeartbeatManager = class {
466
466
  return;
467
467
  }
468
468
  try {
469
- const { guardrails } = await import("./routes-K2GAVUXI.js");
469
+ const { guardrails } = await import("./routes-3UJKWSYJ.js");
470
470
  const status = await guardrails.getStatus(ctx.agentId);
471
471
  if (status.paused || status.offDuty) {
472
472
  console.log(`[heartbeat] Skipping action dispatch \u2014 agent is ${status.offDuty ? "off duty" : "paused"}`);
@@ -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-K2GAVUXI.js");
359
+ var { knowledgeBase } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
392
+ var { memoryManager } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
413
+ var { policyEngine } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
438
+ var { lifecycle } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
531
+ var { lifecycle } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
542
+ var { activity } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
590
+ var { permissionEngine } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
599
+ var { guardrails } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
611
+ var { dlp } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
631
+ var { approvals } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
661
+ var { activity } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
678
+ var { lifecycle } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
690
+ var { journal } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
705
+ var { commBus } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
719
+ var { activity } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
732
+ var { activity } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
746
+ var { memoryManager } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
2521
+ const { activity } = await import("./routes-3UJKWSYJ.js");
2522
2522
  activity.recordToolCallCompact({
2523
2523
  agentId: config.agentId,
2524
2524
  orgId: config.orgId,
@@ -12,7 +12,7 @@ import {
12
12
  DeploymentEngine,
13
13
  init_agent_config,
14
14
  init_deployer
15
- } from "./chunk-FT5MAYTU.js";
15
+ } from "./chunk-E6B4W3WG.js";
16
16
  import {
17
17
  init_messaging_history,
18
18
  storeMessage
@@ -6847,7 +6847,7 @@ function createAgentRoutes(opts) {
6847
6847
  });
6848
6848
  router.post("/system/install-pm2", async (c) => {
6849
6849
  try {
6850
- const { ensurePm2 } = await import("./deployer-HN7HPTZU.js");
6850
+ const { ensurePm2 } = await import("./deployer-MCISTNBP.js");
6851
6851
  const result = await ensurePm2();
6852
6852
  if (result.installed) {
6853
6853
  return c.json({ success: true, message: `PM2 ${result.version} installed successfully` });
@@ -7103,7 +7103,7 @@ function createAgentRoutes(opts) {
7103
7103
  }
7104
7104
  const managedAgent = await lifecycle2.createAgent(orgId, config, actor);
7105
7105
  try {
7106
- const { knowledgeBase: kbEngine } = await import("./routes-K2GAVUXI.js");
7106
+ const { knowledgeBase: kbEngine } = await import("./routes-3UJKWSYJ.js");
7107
7107
  const allKbs = kbEngine.getAllKnowledgeBases();
7108
7108
  const clientOrgId = managedAgent?.clientOrgId || config?.clientOrgId || null;
7109
7109
  let kbAssigned = 0;
@@ -449,7 +449,7 @@ async function runCloudSetup(inquirer, chalk, existingSubdomain) {
449
449
  try {
450
450
  const archStr = arch() === "arm64" ? "arm64" : "amd64";
451
451
  const dlUrl = `https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-${archStr}.exe`;
452
- execSync(`powershell -Command "New-Item -ItemType Directory -Force -Path '${cfDir}' | Out-Null; Invoke-WebRequest -Uri '${dlUrl}' -OutFile '${cfExe}'"`, { stdio: "inherit", timeout: 12e4 });
452
+ execSync(`powershell -Command "New-Item -ItemType Directory -Force -Path '${cfDir.replace(/'/g, "''")}' | Out-Null; Invoke-WebRequest -Uri '${dlUrl}' -OutFile '${cfExe.replace(/'/g, "''")}'"`, { stdio: "inherit", timeout: 12e4 });
453
453
  found = true;
454
454
  } catch (dlErr) {
455
455
  console.log(chalk.dim(` Download failed: ${dlErr.message?.substring(0, 100)}`));
@@ -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-WX52FFA4.js");
1237
+ const { createServer: createServer2 } = await import("./server-VGZXHRIM.js");
1238
1238
  const server2 = createServer2({ port: tunnel.port, db, jwtSecret });
1239
1239
  const handle2 = await server2.start();
1240
1240
  spinner.succeed("Server running");
@@ -1264,11 +1264,11 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
1264
1264
  execSync2("winget install --id Cloudflare.cloudflared --accept-source-agreements --accept-package-agreements", { stdio: "pipe", timeout: 12e4 });
1265
1265
  } catch {
1266
1266
  const archStr = process.arch === "arm64" ? "arm64" : "amd64";
1267
- const localAppData = process.env.LOCALAPPDATA || `${process.env.USERPROFILE}\\AppData\\Local`;
1268
- const cfDir = `${localAppData}\\cloudflared`;
1269
- const cfExe = `${cfDir}\\cloudflared.exe`;
1267
+ const localAppData = process.env.LOCALAPPDATA || join2(process.env.USERPROFILE || homedir2(), "AppData", "Local");
1268
+ const cfDir = join2(localAppData, "cloudflared");
1269
+ const cfExe = join2(cfDir, "cloudflared.exe");
1270
1270
  const dlUrl = `https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-${archStr}.exe`;
1271
- execSync2(`powershell -Command "New-Item -ItemType Directory -Force -Path '${cfDir}' | Out-Null; Invoke-WebRequest -Uri '${dlUrl}' -OutFile '${cfExe}'"`, { stdio: "pipe", timeout: 12e4 });
1271
+ execSync2(`powershell -Command "New-Item -ItemType Directory -Force -Path '${cfDir.replace(/'/g, "''")}' | Out-Null; Invoke-WebRequest -Uri '${dlUrl}' -OutFile '${cfExe.replace(/'/g, "''")}'"`, { stdio: "pipe", timeout: 12e4 });
1272
1272
  process.env.PATH = `${cfDir};${process.env.PATH}`;
1273
1273
  }
1274
1274
  } else if (process.platform === "darwin") {
@@ -1350,7 +1350,8 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
1350
1350
  `});`,
1351
1351
  `process.exit(r.status || 0);`
1352
1352
  ].join("\n"));
1353
- execSync2(`pm2 start "${cfScript}" --name cloudflared -- tunnel --no-autoupdate run --token ${cloud.tunnelToken}`, { stdio: "pipe", timeout: 15e3 });
1353
+ const safeToken = String(cloud.tunnelToken || "").replace(/[^a-zA-Z0-9_.-]/g, "");
1354
+ execSync2(`pm2 start "${cfScript}" --name cloudflared -- tunnel --no-autoupdate run --token ${safeToken}`, { stdio: "pipe", timeout: 15e3 });
1354
1355
  const envLines = [
1355
1356
  `PORT=${cloud.port || 8080}`,
1356
1357
  `DATABASE_URL=${database.connectionString || ""}`,
@@ -1535,7 +1536,7 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
1535
1536
  return {};
1536
1537
  }
1537
1538
  spinner.start("Starting local server...");
1538
- const { createServer } = await import("./server-WX52FFA4.js");
1539
+ const { createServer } = await import("./server-VGZXHRIM.js");
1539
1540
  const server = createServer({ port: 3e3, db, jwtSecret });
1540
1541
  const handle = await server.start();
1541
1542
  spinner.succeed("Server running");
@@ -11,7 +11,7 @@ import {
11
11
  init_config_bus,
12
12
  init_routes,
13
13
  routes_exports
14
- } from "./chunk-ACP7QSXU.js";
14
+ } from "./chunk-I5MQXMPP.js";
15
15
  import {
16
16
  SecureVault,
17
17
  init_vault
@@ -3269,7 +3269,7 @@ function createAdminRoutes(db) {
3269
3269
  });
3270
3270
  api.get("/system/update-check", async (c) => {
3271
3271
  try {
3272
- const { checkForUpdate, getCachedUpdateCheck } = await import("./cli-update-UM7XCICB.js");
3272
+ const { checkForUpdate, getCachedUpdateCheck } = await import("./cli-update-P3TAXEW7.js");
3273
3273
  const cached = getCachedUpdateCheck();
3274
3274
  if (cached && Date.now() - new Date(cached.checkedAt).getTime() < 5 * 6e4) {
3275
3275
  return c.json(cached);
@@ -3282,7 +3282,7 @@ function createAdminRoutes(db) {
3282
3282
  });
3283
3283
  api.post("/system/update", async (c) => {
3284
3284
  try {
3285
- const { performUpdate } = await import("./cli-update-UM7XCICB.js");
3285
+ const { performUpdate } = await import("./cli-update-P3TAXEW7.js");
3286
3286
  const result = await performUpdate({ restart: true });
3287
3287
  return c.json(result);
3288
3288
  } catch (e) {
@@ -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-K2GAVUXI.js");
4686
+ const { engineRoutes, setEngineDb } = await import("./routes-3UJKWSYJ.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-5OKJ5DT6.js");
4717
- const { mountRuntimeApp, setRuntime } = await import("./routes-K2GAVUXI.js");
4716
+ const { createAgentRuntime } = await import("./runtime-G6SEDQA6.js");
4717
+ const { mountRuntimeApp, setRuntime } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
4722
+ const { lifecycle: lc, memoryManager: mm } = await import("./routes-3UJKWSYJ.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-K2GAVUXI.js");
4761
+ const { vault: vaultRef, permissionEngine: permRef, databaseManager: dbMgr } = await import("./routes-3UJKWSYJ.js");
4762
4762
  const runtime = createAgentRuntime({
4763
4763
  engineDb,
4764
4764
  adminDb: config.db,
@@ -4965,7 +4965,7 @@ function createServer(config) {
4965
4965
  });
4966
4966
  (async () => {
4967
4967
  try {
4968
- const { engineRoutes, setEngineDb } = await import("./routes-K2GAVUXI.js");
4968
+ const { engineRoutes, setEngineDb } = await import("./routes-3UJKWSYJ.js");
4969
4969
  const { EngineDatabase } = await import("./db-adapter-2T56ORSD.js");
4970
4970
  if (!engineInitialized) {
4971
4971
  engineInitialized = true;
@@ -4989,13 +4989,13 @@ function createServer(config) {
4989
4989
  await setEngineDb(engineDb, config.db);
4990
4990
  if (config.runtime?.enabled) {
4991
4991
  try {
4992
- const { createAgentRuntime } = await import("./runtime-5OKJ5DT6.js");
4993
- const { mountRuntimeApp, setRuntime } = await import("./routes-K2GAVUXI.js");
4992
+ const { createAgentRuntime } = await import("./runtime-G6SEDQA6.js");
4993
+ const { mountRuntimeApp, setRuntime } = await import("./routes-3UJKWSYJ.js");
4994
4994
  let getEmailConfig;
4995
4995
  let onTokenRefresh;
4996
4996
  let agentMemoryMgr;
4997
4997
  try {
4998
- const { lifecycle: lc, memoryManager: mm } = await import("./routes-K2GAVUXI.js");
4998
+ const { lifecycle: lc, memoryManager: mm } = await import("./routes-3UJKWSYJ.js");
4999
4999
  agentMemoryMgr = mm;
5000
5000
  if (lc) {
5001
5001
  getEmailConfig = (agentId) => {
@@ -5034,7 +5034,7 @@ function createServer(config) {
5034
5034
  }
5035
5035
  } catch {
5036
5036
  }
5037
- const { vault: vaultRef2, permissionEngine: permRef2, databaseManager: dbMgr2 } = await import("./routes-K2GAVUXI.js");
5037
+ const { vault: vaultRef2, permissionEngine: permRef2, databaseManager: dbMgr2 } = await import("./routes-3UJKWSYJ.js");
5038
5038
  const runtime = createAgentRuntime({
5039
5039
  engineDb,
5040
5040
  adminDb: config.db,
@@ -5046,7 +5046,7 @@ function createServer(config) {
5046
5046
  agentMemoryManager: agentMemoryMgr,
5047
5047
  vault: vaultRef2,
5048
5048
  permissionEngine: permRef2,
5049
- hierarchyManager: (await import("./routes-K2GAVUXI.js")).hierarchyManager ?? void 0,
5049
+ hierarchyManager: (await import("./routes-3UJKWSYJ.js")).hierarchyManager ?? void 0,
5050
5050
  databaseManager: dbMgr2
5051
5051
  });
5052
5052
  await runtime.start();
@@ -5060,7 +5060,7 @@ function createServer(config) {
5060
5060
  }
5061
5061
  console.log("[engine] Eagerly initialized");
5062
5062
  try {
5063
- const { lifecycle: lcRef } = await import("./routes-K2GAVUXI.js");
5063
+ const { lifecycle: lcRef } = await import("./routes-3UJKWSYJ.js");
5064
5064
  if (lcRef) {
5065
5065
  const agents = Array.from(lcRef.agents?.values?.() || []);
5066
5066
  const hasLocalPm2 = agents.some((a) => {
@@ -5069,7 +5069,7 @@ function createServer(config) {
5069
5069
  return target === "local" && (!pm || pm === "pm2");
5070
5070
  });
5071
5071
  if (hasLocalPm2) {
5072
- const { ensurePm2 } = await import("./deployer-HN7HPTZU.js");
5072
+ const { ensurePm2 } = await import("./deployer-MCISTNBP.js");
5073
5073
  const pm2 = await ensurePm2();
5074
5074
  if (pm2.installed) {
5075
5075
  console.log(`[startup] PM2 v${pm2.version} available for local deployments`);
@@ -776,7 +776,7 @@ async function runAgent(_args) {
776
776
  const agent = agentRow[0];
777
777
  console.log(` Agent: ${agent.display_name || agent.name}`);
778
778
  console.log(` State: ${agent.state}`);
779
- const routes = await import("./routes-K2GAVUXI.js");
779
+ const routes = await import("./routes-3UJKWSYJ.js");
780
780
  await routes.lifecycle.setDb(engineDb);
781
781
  await routes.lifecycle.loadFromDb();
782
782
  routes.lifecycle.standaloneMode = true;
@@ -834,10 +834,10 @@ async function runAgent(_args) {
834
834
  }
835
835
  } catch {
836
836
  }
837
- const { createAgentRuntime } = await import("./runtime-5OKJ5DT6.js");
837
+ const { createAgentRuntime } = await import("./runtime-G6SEDQA6.js");
838
838
  let orgIntMgr = null;
839
839
  try {
840
- const { orgIntegrations: oi } = await import("./routes-K2GAVUXI.js");
840
+ const { orgIntegrations: oi } = await import("./routes-3UJKWSYJ.js");
841
841
  orgIntMgr = oi;
842
842
  } catch {
843
843
  }
@@ -1236,7 +1236,7 @@ Please complete this task now.`,
1236
1236
  }
1237
1237
  if (scope === "all" || scope === "permissions") {
1238
1238
  try {
1239
- const { permissionEngine } = await import("./routes-K2GAVUXI.js");
1239
+ const { permissionEngine } = await import("./routes-3UJKWSYJ.js");
1240
1240
  await permissionEngine.setDb(engineDb);
1241
1241
  reloaded.push("permissions");
1242
1242
  } catch {
@@ -1276,7 +1276,7 @@ Please complete this task now.`,
1276
1276
  }
1277
1277
  if (scope === "all" || scope === "guardrails") {
1278
1278
  try {
1279
- const { guardrails } = await import("./routes-K2GAVUXI.js");
1279
+ const { guardrails } = await import("./routes-3UJKWSYJ.js");
1280
1280
  await guardrails.loadFromDb?.();
1281
1281
  reloaded.push("guardrails");
1282
1282
  } catch {
@@ -2216,7 +2216,7 @@ Available tools: ${providerType === "imap" ? "email_send (to, subject, body)" :
2216
2216
  console.log("[guardrails] Disabled via autonomy settings");
2217
2217
  }
2218
2218
  try {
2219
- const { AgentHeartbeatManager } = await import("./agent-heartbeat-VKF257FY.js");
2219
+ const { AgentHeartbeatManager } = await import("./agent-heartbeat-YS4UEQES.js");
2220
2220
  const hbOrgRows = await engineDb.query(`SELECT org_id FROM managed_agents WHERE id = $1`, [AGENT_ID]);
2221
2221
  const hbOrgId = hbOrgRows?.[0]?.org_id || "";
2222
2222
  const hbManagerEmail = config.managerEmail || (config.manager?.type === "external" ? config.manager.email : null);
@@ -448,7 +448,8 @@ async function runCloudRecover(args, inquirer, chalk, ora) {
448
448
  ex("pm2 delete cloudflared 2>/dev/null", { timeout: 5e3 });
449
449
  } catch {
450
450
  }
451
- const safeToken = String(data.tunnelToken).replace(/[^a-zA-Z0-9_-]/g, "");
451
+ const safeToken = String(data.tunnelToken).replace(/[^a-zA-Z0-9_.\-]/g, "");
452
+ if (!safeToken || safeToken.length < 10) throw new Error("Invalid tunnel token");
452
453
  ex(`pm2 start cloudflared --name cloudflared -- tunnel --no-autoupdate run --token ${safeToken}`, { timeout: 15e3 });
453
454
  try {
454
455
  ex("pm2 save 2>/dev/null", { timeout: 5e3 });
@@ -94,7 +94,7 @@ async function runServe(_args) {
94
94
  process.exit(1);
95
95
  }
96
96
  const { createAdapter, smartDbConfig } = await import("./factory-XRYYBBCW.js");
97
- const { createServer } = await import("./server-WX52FFA4.js");
97
+ const { createServer } = await import("./server-VGZXHRIM.js");
98
98
  const db = await createAdapter(smartDbConfig(DATABASE_URL));
99
99
  await db.migrate();
100
100
  const server = createServer({
@@ -106,7 +106,7 @@ async function runServe(_args) {
106
106
  await server.start();
107
107
  console.log(`AgenticMail Enterprise server running on :${PORT}`);
108
108
  try {
109
- const { startBackgroundUpdateCheck } = await import("./cli-update-UM7XCICB.js");
109
+ const { startBackgroundUpdateCheck } = await import("./cli-update-P3TAXEW7.js");
110
110
  startBackgroundUpdateCheck();
111
111
  } catch {
112
112
  }
@@ -70,7 +70,8 @@ async function checkForUpdate() {
70
70
  try {
71
71
  const cacheDir = join(homedir(), ".agenticmail");
72
72
  const cachePath = join(cacheDir, "update-check.json");
73
- writeFileSync(cachePath, JSON.stringify(info, null, 2));
73
+ const safeInfo = { current: String(info.current), latest: String(info.latest), updateAvailable: Boolean(info.updateAvailable), checkedAt: String(info.checkedAt), releaseNotes: info.releaseNotes ? String(info.releaseNotes).slice(0, 1e4) : void 0, releaseUrl: info.releaseUrl ? String(info.releaseUrl).slice(0, 500) : void 0 };
74
+ writeFileSync(cachePath, JSON.stringify(safeInfo, null, 2));
74
75
  } catch {
75
76
  }
76
77
  return info;
@@ -105,6 +106,9 @@ async function performUpdate(options) {
105
106
  `);
106
107
  return { success: false, from: current, to: "unknown", message: "Could not determine latest version" };
107
108
  }
109
+ if (!/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(latest)) {
110
+ return { success: false, from: current, to: latest, message: `Invalid version format: ${latest}` };
111
+ }
108
112
  console.log(`
109
113
  \u{1F4E6} Installing ${PKG_NAME}@${latest}...`);
110
114
  try {
@@ -137,9 +141,11 @@ async function performUpdate(options) {
137
141
  return aIsServer ? 1 : bIsServer ? -1 : 0;
138
142
  });
139
143
  for (const proc of sorted) {
140
- console.log(` Restarting: ${proc.name}`);
144
+ const safeName = String(proc.name).replace(/[^a-zA-Z0-9_-]/g, "");
145
+ if (!safeName) continue;
146
+ console.log(` Restarting: ${safeName}`);
141
147
  try {
142
- execSync(`pm2 restart ${proc.name}`, { stdio: "inherit", timeout: 15e3 });
148
+ execSync(`pm2 restart ${safeName}`, { stdio: "inherit", timeout: 15e3 });
143
149
  } catch {
144
150
  }
145
151
  }
package/dist/cli.js CHANGED
@@ -14,7 +14,7 @@ switch (command) {
14
14
  import("./cli-submit-skill-SNGAHVB7.js").then((m) => m.runSubmitSkill(args.slice(1))).catch(fatal);
15
15
  break;
16
16
  case "recover":
17
- import("./cli-recover-4ENZIKE2.js").then((m) => m.runRecover(args.slice(1))).catch(fatal);
17
+ import("./cli-recover-HGWHKH6N.js").then((m) => m.runRecover(args.slice(1))).catch(fatal);
18
18
  break;
19
19
  case "verify-domain":
20
20
  import("./cli-verify-Q3NO5XBI.js").then((m) => m.runVerifyDomain(args.slice(1))).catch(fatal);
@@ -61,18 +61,18 @@ Skill Development:
61
61
  break;
62
62
  case "update":
63
63
  case "upgrade":
64
- import("./cli-update-UM7XCICB.js").then((m) => m.runUpdate(args.slice(1))).catch(fatal);
64
+ import("./cli-update-P3TAXEW7.js").then((m) => m.runUpdate(args.slice(1))).catch(fatal);
65
65
  break;
66
66
  case "serve":
67
67
  case "start":
68
- import("./cli-serve-GA5EXFOE.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
68
+ import("./cli-serve-WA6BNLZ3.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
69
69
  break;
70
70
  case "agent":
71
- import("./cli-agent-3MGMIL4H.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
71
+ import("./cli-agent-FKBRZT3B.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
72
72
  break;
73
73
  case "setup":
74
74
  default:
75
- import("./setup-KK3N57HP.js").then((m) => m.runSetupWizard()).catch(fatal);
75
+ import("./setup-YVTDNY7K.js").then((m) => m.runSetupWizard()).catch(fatal);
76
76
  break;
77
77
  }
78
78
  function fatal(err) {
@@ -2,7 +2,7 @@ import {
2
2
  DeploymentEngine,
3
3
  ensurePm2,
4
4
  init_deployer
5
- } from "./chunk-FT5MAYTU.js";
5
+ } from "./chunk-E6B4W3WG.js";
6
6
  import "./chunk-KFQGP6VL.js";
7
7
  init_deployer();
8
8
  export {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  provision,
3
3
  runSetupWizard
4
- } from "./chunk-FP4QC3T5.js";
4
+ } from "./chunk-MPDSMMSJ.js";
5
5
  import {
6
6
  AgenticMailManager,
7
7
  GoogleEmailProvider,
@@ -28,7 +28,7 @@ import {
28
28
  executeTool,
29
29
  runAgentLoop,
30
30
  toolsToDefinitions
31
- } from "./chunk-CCYSUKRG.js";
31
+ } from "./chunk-5TFB3EIE.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-QIDDLWRL.js";
45
+ } from "./chunk-N3CFP4AQ.js";
46
46
  import "./chunk-DJBCRQTD.js";
47
47
  import {
48
48
  PROVIDER_REGISTRY,
@@ -82,7 +82,7 @@ import {
82
82
  init_storage_manager,
83
83
  init_tenant,
84
84
  init_workforce
85
- } from "./chunk-ACP7QSXU.js";
85
+ } from "./chunk-I5MQXMPP.js";
86
86
  import "./chunk-WYDVMFGJ.js";
87
87
  import "./chunk-3UAFHUEC.js";
88
88
  import {
@@ -100,7 +100,7 @@ import {
100
100
  DeploymentEngine,
101
101
  init_agent_config,
102
102
  init_deployer
103
- } from "./chunk-FT5MAYTU.js";
103
+ } from "./chunk-E6B4W3WG.js";
104
104
  import "./chunk-Z7NVD3OQ.js";
105
105
  import {
106
106
  AgentMemoryManager,
@@ -35,10 +35,10 @@ import {
35
35
  tenants,
36
36
  vault,
37
37
  workforce
38
- } from "./chunk-ACP7QSXU.js";
38
+ } from "./chunk-I5MQXMPP.js";
39
39
  import "./chunk-WYDVMFGJ.js";
40
40
  import "./chunk-3UAFHUEC.js";
41
- import "./chunk-FT5MAYTU.js";
41
+ import "./chunk-E6B4W3WG.js";
42
42
  import "./chunk-Z7NVD3OQ.js";
43
43
  import "./chunk-VSBC4SWO.js";
44
44
  import "./chunk-AF3WSNVX.js";
@@ -14,7 +14,7 @@ import {
14
14
  executeTool,
15
15
  runAgentLoop,
16
16
  toolsToDefinitions
17
- } from "./chunk-CCYSUKRG.js";
17
+ } from "./chunk-5TFB3EIE.js";
18
18
  import {
19
19
  PROVIDER_REGISTRY,
20
20
  listAllProviders,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-QIDDLWRL.js";
3
+ } from "./chunk-N3CFP4AQ.js";
4
4
  import "./chunk-DJBCRQTD.js";
5
5
  import "./chunk-UF3ZJMJO.js";
6
- import "./chunk-ACP7QSXU.js";
6
+ import "./chunk-I5MQXMPP.js";
7
7
  import "./chunk-WYDVMFGJ.js";
8
8
  import "./chunk-3UAFHUEC.js";
9
- import "./chunk-FT5MAYTU.js";
9
+ import "./chunk-E6B4W3WG.js";
10
10
  import "./chunk-Z7NVD3OQ.js";
11
11
  import "./chunk-VSBC4SWO.js";
12
12
  import "./chunk-AF3WSNVX.js";
@@ -6,7 +6,7 @@ import {
6
6
  promptRegistration,
7
7
  provision,
8
8
  runSetupWizard
9
- } from "./chunk-FP4QC3T5.js";
9
+ } from "./chunk-MPDSMMSJ.js";
10
10
  import "./chunk-P6W565WH.js";
11
11
  import "./chunk-KFQGP6VL.js";
12
12
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/enterprise",
3
- "version": "0.5.389",
3
+ "version": "0.5.391",
4
4
  "description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
5
5
  "type": "module",
6
6
  "bin": {
File without changes