@agenticmail/enterprise 0.5.442 → 0.5.443

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 (244) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +3 -2
  3. package/dist/agent-tools-3MD7EPO6.js +14629 -0
  4. package/dist/agent-tools-62HGQYDL.js +14629 -0
  5. package/dist/agent-tools-BTUVVOWT.js +14629 -0
  6. package/dist/agent-tools-BV3JMJPN.js +14629 -0
  7. package/dist/agent-tools-JVNQ4RPM.js +14629 -0
  8. package/dist/agent-tools-LD7LELVT.js +14629 -0
  9. package/dist/agent-tools-NRKQ5NMW.js +14629 -0
  10. package/dist/agent-tools-OXZJOD4D.js +14629 -0
  11. package/dist/agent-tools-PT2ES6G5.js +14629 -0
  12. package/dist/agent-tools-SS335E2E.js +14629 -0
  13. package/dist/chunk-2ACTQSPC.js +1728 -0
  14. package/dist/chunk-2XZE5NT3.js +5387 -0
  15. package/dist/chunk-325NTNE6.js +2180 -0
  16. package/dist/chunk-3AHKVWCO.js +5387 -0
  17. package/dist/chunk-3L2N6LR2.js +7517 -0
  18. package/dist/chunk-3ZD3XOV6.js +1728 -0
  19. package/dist/chunk-44VXWYPE.js +2570 -0
  20. package/dist/chunk-4UOSUXFR.js +7529 -0
  21. package/dist/chunk-54SHHX2S.js +2180 -0
  22. package/dist/chunk-5DVY3CNK.js +1728 -0
  23. package/dist/chunk-5F5DGV63.js +5596 -0
  24. package/dist/chunk-6IUUOWZY.js +7526 -0
  25. package/dist/chunk-77LFFLQX.js +7526 -0
  26. package/dist/chunk-7BKNDBSA.js +2191 -0
  27. package/dist/chunk-7BS2XPLW.js +5359 -0
  28. package/dist/chunk-7GCSGDXQ.js +1636 -0
  29. package/dist/chunk-7IAI45PR.js +4735 -0
  30. package/dist/chunk-7QPZGO27.js +4976 -0
  31. package/dist/chunk-7S5XAXRD.js +4747 -0
  32. package/dist/chunk-AD6ZR3QD.js +5357 -0
  33. package/dist/chunk-AO556OXZ.js +2570 -0
  34. package/dist/chunk-APUWQHXC.js +7437 -0
  35. package/dist/chunk-BKSSHV6C.js +1728 -0
  36. package/dist/chunk-BMUNQHLU.js +1208 -0
  37. package/dist/chunk-BPF5DKUM.js +392 -0
  38. package/dist/chunk-CFR5OSMI.js +1220 -0
  39. package/dist/chunk-CM4GUHXP.js +1728 -0
  40. package/dist/chunk-CVFIM72Q.js +501 -0
  41. package/dist/chunk-DFXVJNKW.js +4734 -0
  42. package/dist/chunk-DJ7LHRL7.js +2214 -0
  43. package/dist/chunk-DJFI6NR6.js +1624 -0
  44. package/dist/chunk-DJHYV5VY.js +1624 -0
  45. package/dist/chunk-DYM4PQO3.js +4727 -0
  46. package/dist/chunk-DZ75RF35.js +1728 -0
  47. package/dist/chunk-E5H64U5H.js +472 -0
  48. package/dist/chunk-EOD4EGFI.js +1728 -0
  49. package/dist/chunk-EP74QR5B.js +4980 -0
  50. package/dist/chunk-FE2M4FV5.js +5273 -0
  51. package/dist/chunk-FUH6NWIX.js +7540 -0
  52. package/dist/chunk-G5ADHHAD.js +1728 -0
  53. package/dist/chunk-GAYLPSM7.js +7529 -0
  54. package/dist/chunk-GDAFZJTJ.js +7540 -0
  55. package/dist/chunk-GLAN2JBA.js +1636 -0
  56. package/dist/chunk-GNAEBGU7.js +4812 -0
  57. package/dist/chunk-HDDA2Q3Q.js +1728 -0
  58. package/dist/chunk-HG62FWWQ.js +7437 -0
  59. package/dist/chunk-HV5VIS5K.js +1624 -0
  60. package/dist/chunk-IEVA23WK.js +4976 -0
  61. package/dist/chunk-IFMZ2IYC.js +7540 -0
  62. package/dist/chunk-IN7VIORK.js +2641 -0
  63. package/dist/chunk-KAX3ZDP2.js +7529 -0
  64. package/dist/chunk-KECO53GP.js +1728 -0
  65. package/dist/chunk-KGZ74UMA.js +1728 -0
  66. package/dist/chunk-M2ZLRUMX.js +7540 -0
  67. package/dist/chunk-MKQWC6KF.js +5374 -0
  68. package/dist/chunk-MQ3JBGLU.js +1636 -0
  69. package/dist/chunk-MVB6JARX.js +7529 -0
  70. package/dist/chunk-N37MOOFE.js +2210 -0
  71. package/dist/chunk-NELCAZUQ.js +5357 -0
  72. package/dist/chunk-OPAO5QQS.js +1728 -0
  73. package/dist/chunk-OUHU3VW6.js +1728 -0
  74. package/dist/chunk-OWEXZVZ6.js +1728 -0
  75. package/dist/chunk-P4DHSJJY.js +7437 -0
  76. package/dist/chunk-Q7QA6MNJ.js +1728 -0
  77. package/dist/chunk-QKKTNPGV.js +7592 -0
  78. package/dist/chunk-REMMXZVU.js +7529 -0
  79. package/dist/chunk-RK3KATD4.js +4756 -0
  80. package/dist/chunk-RQ33L5T3.js +5374 -0
  81. package/dist/chunk-RU77F65Q.js +1728 -0
  82. package/dist/chunk-SAM3CVIU.js +5374 -0
  83. package/dist/chunk-SFMXIKWZ.js +1728 -0
  84. package/dist/chunk-SPZ5JBGW.js +1624 -0
  85. package/dist/chunk-TDOC6WSK.js +7529 -0
  86. package/dist/chunk-TPMT5WTW.js +5357 -0
  87. package/dist/chunk-TVXUR3PB.js +2180 -0
  88. package/dist/chunk-TZEEVEKG.js +5343 -0
  89. package/dist/chunk-U327O3ZR.js +7540 -0
  90. package/dist/chunk-ULD6C5DB.js +2180 -0
  91. package/dist/chunk-ULVRCJZV.js +5374 -0
  92. package/dist/chunk-UOCDOM2S.js +1624 -0
  93. package/dist/chunk-VINDZLLX.js +1636 -0
  94. package/dist/chunk-VODW5GJL.js +2180 -0
  95. package/dist/chunk-WEWL7Z3C.js +2180 -0
  96. package/dist/chunk-WG2MEMS6.js +5343 -0
  97. package/dist/chunk-WYV6QWOJ.js +1188 -0
  98. package/dist/chunk-X5AIAD77.js +1636 -0
  99. package/dist/chunk-XUETIRDV.js +2214 -0
  100. package/dist/chunk-XWSMX7RK.js +7529 -0
  101. package/dist/chunk-YUSYXHKB.js +1728 -0
  102. package/dist/chunk-ZC2RMHQD.js +5374 -0
  103. package/dist/chunk-ZDZQQGFG.js +5374 -0
  104. package/dist/chunk-ZJ2HCWKF.js +1728 -0
  105. package/dist/chunk-ZMKVEJKR.js +392 -0
  106. package/dist/cli-agent-2UFGFO24.js +2761 -0
  107. package/dist/cli-agent-5FPUCFPG.js +2761 -0
  108. package/dist/cli-agent-7AB6NIYQ.js +2761 -0
  109. package/dist/cli-agent-7CAFSYOM.js +2761 -0
  110. package/dist/cli-agent-7OVOINHR.js +2757 -0
  111. package/dist/cli-agent-AWKBFIRS.js +2761 -0
  112. package/dist/cli-agent-ES3XOPHJ.js +2757 -0
  113. package/dist/cli-agent-KPXZN5JK.js +2761 -0
  114. package/dist/cli-agent-LGTCFHGS.js +2757 -0
  115. package/dist/cli-agent-LLUYUHHF.js +2757 -0
  116. package/dist/cli-agent-NHZWYX5Q.js +2761 -0
  117. package/dist/cli-agent-TYUOTYCO.js +2757 -0
  118. package/dist/cli-agent-VQO6HI65.js +2757 -0
  119. package/dist/cli-agent-VV5JWRU7.js +2757 -0
  120. package/dist/cli-agent-Z5B23XED.js +2757 -0
  121. package/dist/cli-serve-2FLQXJW7.js +322 -0
  122. package/dist/cli-serve-34YFCCUX.js +322 -0
  123. package/dist/cli-serve-3NS6MNUS.js +322 -0
  124. package/dist/cli-serve-4PWFEPNA.js +322 -0
  125. package/dist/cli-serve-4VIBMXMT.js +322 -0
  126. package/dist/cli-serve-5ZUF5MGH.js +322 -0
  127. package/dist/cli-serve-6HGL56GB.js +322 -0
  128. package/dist/cli-serve-BBBWEKKW.js +322 -0
  129. package/dist/cli-serve-D2HQC4SB.js +322 -0
  130. package/dist/cli-serve-IKCMNUNM.js +322 -0
  131. package/dist/cli-serve-LTUKYMEF.js +322 -0
  132. package/dist/cli-serve-MIWI5PBE.js +322 -0
  133. package/dist/cli-serve-R6K4SZ3L.js +322 -0
  134. package/dist/cli-serve-RQIOBQGF.js +322 -0
  135. package/dist/cli-serve-S57ROYQ6.js +322 -0
  136. package/dist/cli-serve-WVSLOISY.js +322 -0
  137. package/dist/cli-serve-YKZSNR3P.js +322 -0
  138. package/dist/cli-serve-ZGKXWDMZ.js +322 -0
  139. package/dist/cli-serve-ZZOJWREY.js +322 -0
  140. package/dist/cli.js +3 -3
  141. package/dist/dashboard/components/utils.js +1 -1
  142. package/dist/dashboard/docs/polymarket.html +1 -1
  143. package/dist/dashboard/pages/polymarket.js +222 -80
  144. package/dist/index.js +10 -10
  145. package/dist/pipeline-C4C3ZF4X.js +15 -0
  146. package/dist/pipeline-DAF3EV7Q.js +15 -0
  147. package/dist/pipeline-MMESLRQG.js +15 -0
  148. package/dist/polymarket-3LGJSQZK.js +17 -0
  149. package/dist/polymarket-4OIWQFBO.js +17 -0
  150. package/dist/polymarket-AZEV7C6E.js +17 -0
  151. package/dist/polymarket-DBQYJC57.js +7 -0
  152. package/dist/polymarket-EVTKWLUO.js +7 -0
  153. package/dist/polymarket-GMKDVVQH.js +17 -0
  154. package/dist/polymarket-HZOAD4W4.js +17 -0
  155. package/dist/polymarket-PKGRF7ID.js +17 -0
  156. package/dist/polymarket-QUNR2H7U.js +17 -0
  157. package/dist/polymarket-TM624BN5.js +17 -0
  158. package/dist/polymarket-VT2EDGD7.js +17 -0
  159. package/dist/polymarket-W7B4TLP3.js +17 -0
  160. package/dist/polymarket-WS4VE6U7.js +7 -0
  161. package/dist/polymarket-runtime-772ADZJW.js +108 -0
  162. package/dist/polymarket-runtime-AIYHQKYQ.js +108 -0
  163. package/dist/polymarket-runtime-APJ5HW4Y.js +108 -0
  164. package/dist/polymarket-runtime-BX3ODZZD.js +108 -0
  165. package/dist/polymarket-runtime-ISD4CKKL.js +108 -0
  166. package/dist/polymarket-runtime-JU4PQZGJ.js +108 -0
  167. package/dist/polymarket-runtime-OFLBSPCK.js +108 -0
  168. package/dist/polymarket-runtime-POJRRWFS.js +108 -0
  169. package/dist/polymarket-runtime-XN5TVHU5.js +108 -0
  170. package/dist/polymarket-runtime-ZYFTKEJ4.js +108 -0
  171. package/dist/polymarket-watcher-2CKLTIXI.js +23 -0
  172. package/dist/polymarket-watcher-3C72X36B.js +23 -0
  173. package/dist/polymarket-watcher-IHRZ2URM.js +23 -0
  174. package/dist/polymarket-watcher-J7UWIN7I.js +23 -0
  175. package/dist/polymarket-watcher-M6CDW63Y.js +23 -0
  176. package/dist/polymarket-watcher-OSI73EDX.js +23 -0
  177. package/dist/polymarket-watcher-PN4JJV3V.js +23 -0
  178. package/dist/polymarket-watcher-PXK4NS5F.js +23 -0
  179. package/dist/polymarket-watcher-VDJ4SVHP.js +23 -0
  180. package/dist/polymarket-watcher-W4BV6JTG.js +23 -0
  181. package/dist/runtime-22E2WCL6.js +46 -0
  182. package/dist/runtime-7GYS4FQU.js +46 -0
  183. package/dist/runtime-BR6K3Q3N.js +46 -0
  184. package/dist/runtime-CTTRDVJ6.js +46 -0
  185. package/dist/runtime-GIIPTHK5.js +46 -0
  186. package/dist/runtime-HYAKLZWI.js +46 -0
  187. package/dist/runtime-IQ2KIV2L.js +50 -0
  188. package/dist/runtime-ISXECIAB.js +46 -0
  189. package/dist/runtime-IV4BY7S4.js +46 -0
  190. package/dist/runtime-O65GGHL2.js +46 -0
  191. package/dist/runtime-PKHEGQYK.js +50 -0
  192. package/dist/runtime-RFKPIFK4.js +46 -0
  193. package/dist/runtime-S35B6PIY.js +46 -0
  194. package/dist/runtime-WEZJ4YRK.js +46 -0
  195. package/dist/runtime-WLWB62ZI.js +46 -0
  196. package/dist/screener-FB47G4YX.js +26 -0
  197. package/dist/screener-WQVQO4WF.js +26 -0
  198. package/dist/server-6GWGIGBH.js +36 -0
  199. package/dist/server-7VZ6XXBC.js +36 -0
  200. package/dist/server-7XBTD3FW.js +36 -0
  201. package/dist/server-BN56IMC4.js +36 -0
  202. package/dist/server-GD6SPDER.js +36 -0
  203. package/dist/server-IJHU2FIK.js +36 -0
  204. package/dist/server-J5WZGZX3.js +36 -0
  205. package/dist/server-JVUH2E3H.js +36 -0
  206. package/dist/server-MYXWTXSE.js +36 -0
  207. package/dist/server-ORGV7O7L.js +36 -0
  208. package/dist/server-QPE3WVUQ.js +36 -0
  209. package/dist/server-SUBGS5BJ.js +36 -0
  210. package/dist/server-SWAYJTFF.js +36 -0
  211. package/dist/server-TFIWDU2H.js +36 -0
  212. package/dist/server-VH4W6LWW.js +36 -0
  213. package/dist/server-X5UMJJ3J.js +36 -0
  214. package/dist/server-XOK5LHNU.js +36 -0
  215. package/dist/server-ZLK24KFY.js +36 -0
  216. package/dist/server-ZNSQGCRM.js +36 -0
  217. package/dist/setup-32ZRMW7R.js +20 -0
  218. package/dist/setup-3WF7PBIS.js +20 -0
  219. package/dist/setup-4TM64QG4.js +20 -0
  220. package/dist/setup-5SGUMKN7.js +20 -0
  221. package/dist/setup-AGYKOCIU.js +20 -0
  222. package/dist/setup-EIP4IHZN.js +20 -0
  223. package/dist/setup-F5SAGQJJ.js +20 -0
  224. package/dist/setup-LMF76UUM.js +20 -0
  225. package/dist/setup-MA5QR3J4.js +20 -0
  226. package/dist/setup-MLIPR2U3.js +20 -0
  227. package/dist/setup-MLIZYTT6.js +20 -0
  228. package/dist/setup-OPVZ3GM7.js +20 -0
  229. package/dist/setup-PWFHUXOK.js +20 -0
  230. package/dist/setup-QF5GCTPE.js +20 -0
  231. package/dist/setup-SGF4OX3A.js +20 -0
  232. package/dist/setup-TLWKGWC6.js +20 -0
  233. package/dist/setup-TYCRH63P.js +20 -0
  234. package/dist/setup-USUBKTVX.js +20 -0
  235. package/dist/setup-VMNTNEB4.js +20 -0
  236. package/dist/shared-S5ROHYCX.js +69 -0
  237. package/dist/shared-TLWZZZSK.js +69 -0
  238. package/dist/system-prompts-7ZRL27FN.js +69 -0
  239. package/dist/system-prompts-CNXUF2AV.js +69 -0
  240. package/dist/system-prompts-SYGQRBRG.js +69 -0
  241. package/logs/cloudflared-error.log +4 -89
  242. package/logs/cloudflared-error__2026-03-11_00-00-00.log +289 -0
  243. package/package.json +1 -1
  244. package/logs/cloudflared-error__2026-03-06_00-00-00.log +0 -245
@@ -0,0 +1,322 @@
1
+ import "./chunk-KFQGP6VL.js";
2
+
3
+ // src/cli-serve.ts
4
+ import { existsSync, readFileSync } from "fs";
5
+ import { join } from "path";
6
+ import { homedir } from "os";
7
+ function loadEnvFile() {
8
+ const candidates = [
9
+ join(process.cwd(), ".env"),
10
+ join(homedir(), ".agenticmail", ".env")
11
+ ];
12
+ for (const envPath of candidates) {
13
+ if (!existsSync(envPath)) continue;
14
+ try {
15
+ const content = readFileSync(envPath, "utf8");
16
+ for (const line of content.split("\n")) {
17
+ const trimmed = line.trim();
18
+ if (!trimmed || trimmed.startsWith("#")) continue;
19
+ const eq = trimmed.indexOf("=");
20
+ if (eq < 0) continue;
21
+ const key = trimmed.slice(0, eq).trim();
22
+ let val = trimmed.slice(eq + 1).trim();
23
+ if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
24
+ val = val.slice(1, -1);
25
+ }
26
+ if (!process.env[key]) process.env[key] = val;
27
+ }
28
+ console.log(`Loaded config from ${envPath}`);
29
+ return;
30
+ } catch {
31
+ }
32
+ }
33
+ }
34
+ async function ensureSecrets() {
35
+ const { randomUUID } = await import("crypto");
36
+ const envDir = join(homedir(), ".agenticmail");
37
+ const envPath = join(envDir, ".env");
38
+ let dirty = false;
39
+ if (!process.env.JWT_SECRET) {
40
+ process.env.JWT_SECRET = randomUUID() + randomUUID();
41
+ dirty = true;
42
+ console.log("[startup] Generated new JWT_SECRET (existing sessions will need to re-login)");
43
+ }
44
+ if (!process.env.AGENTICMAIL_VAULT_KEY) {
45
+ process.env.AGENTICMAIL_VAULT_KEY = randomUUID() + randomUUID();
46
+ dirty = true;
47
+ console.log("[startup] Generated new AGENTICMAIL_VAULT_KEY");
48
+ console.log("[startup] \u26A0\uFE0F Previously encrypted credentials will need to be re-entered in the dashboard");
49
+ }
50
+ if (dirty) {
51
+ try {
52
+ if (!existsSync(envDir)) {
53
+ const { mkdirSync } = await import("fs");
54
+ mkdirSync(envDir, { recursive: true });
55
+ }
56
+ const { appendFileSync } = await import("fs");
57
+ const lines = [];
58
+ let existing = "";
59
+ if (existsSync(envPath)) {
60
+ existing = readFileSync(envPath, "utf8");
61
+ }
62
+ if (!existing.includes("JWT_SECRET=")) {
63
+ lines.push(`JWT_SECRET=${process.env.JWT_SECRET}`);
64
+ }
65
+ if (!existing.includes("AGENTICMAIL_VAULT_KEY=")) {
66
+ lines.push(`AGENTICMAIL_VAULT_KEY=${process.env.AGENTICMAIL_VAULT_KEY}`);
67
+ }
68
+ if (lines.length) {
69
+ appendFileSync(envPath, "\n" + lines.join("\n") + "\n", { mode: 384 });
70
+ console.log(`[startup] Saved secrets to ${envPath}`);
71
+ }
72
+ } catch (e) {
73
+ console.warn(`[startup] Could not save secrets to ${envPath}: ${e.message}`);
74
+ }
75
+ }
76
+ }
77
+ async function runServe(_args) {
78
+ loadEnvFile();
79
+ const DATABASE_URL = process.env.DATABASE_URL;
80
+ const PORT = parseInt(process.env.PORT || "8080", 10);
81
+ await ensureSecrets();
82
+ const JWT_SECRET = process.env.JWT_SECRET;
83
+ const _VAULT_KEY = process.env.AGENTICMAIL_VAULT_KEY;
84
+ if (!DATABASE_URL) {
85
+ console.error("ERROR: DATABASE_URL is required.");
86
+ console.error("");
87
+ console.error("Set it via environment variable or .env file:");
88
+ console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db npx @agenticmail/enterprise start");
89
+ console.error("");
90
+ console.error("Or create a .env file (in cwd or ~/.agenticmail/.env):");
91
+ console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db");
92
+ console.error(" JWT_SECRET=your-secret-here");
93
+ console.error(" PORT=3200");
94
+ process.exit(1);
95
+ }
96
+ const { createAdapter, smartDbConfig } = await import("./factory-R6MMSC2X.js");
97
+ const { createServer } = await import("./server-MYXWTXSE.js");
98
+ const db = await createAdapter(smartDbConfig(DATABASE_URL));
99
+ await db.migrate();
100
+ const server = createServer({
101
+ port: PORT,
102
+ db,
103
+ jwtSecret: JWT_SECRET,
104
+ corsOrigins: ["*"]
105
+ });
106
+ await server.start();
107
+ console.log(`AgenticMail Enterprise server running on :${PORT}`);
108
+ try {
109
+ const { startWatcherEngine, initWatcherTables, setWatcherRuntime } = await import("./polymarket-watcher-M6CDW63Y.js");
110
+ const edb = db.getEngineDB?.();
111
+ if (edb) {
112
+ await initWatcherTables(edb);
113
+ startWatcherEngine(db, {
114
+ log: (...args) => console.log(...args),
115
+ onEvent: (agentId, event) => {
116
+ if (event.severity === "critical") {
117
+ console.log(`[poly-watcher] CRITICAL signal for agent ${agentId}: ${event.title}`);
118
+ }
119
+ }
120
+ });
121
+ setTimeout(async () => {
122
+ try {
123
+ const routes = await import("./routes-PRBWZ4MQ.js");
124
+ setWatcherRuntime(
125
+ () => routes.getRuntime?.() || null
126
+ );
127
+ } catch (e) {
128
+ console.warn("[poly-watcher] Could not inject runtime:", e.message);
129
+ }
130
+ }, 5e3);
131
+ console.log("[startup] Polymarket watcher engine started");
132
+ }
133
+ setTimeout(async () => {
134
+ try {
135
+ const { autoConnectProxy } = await import("./polymarket-runtime-XN5TVHU5.js");
136
+ const pdb = db.getEngineDB?.();
137
+ if (pdb) await autoConnectProxy(pdb);
138
+ } catch {
139
+ }
140
+ }, 8e3);
141
+ } catch (e) {
142
+ console.warn("[startup] Polymarket watcher engine skipped:", e.message);
143
+ }
144
+ try {
145
+ const { startBackgroundUpdateCheck } = await import("./cli-update-SX7GACL3.js");
146
+ startBackgroundUpdateCheck();
147
+ } catch {
148
+ }
149
+ try {
150
+ const { startPreventSleep } = await import("./screen-unlock-4RPZBHOI.js");
151
+ const adminDb = server.getAdminDb?.() || server.adminDb;
152
+ if (adminDb) {
153
+ const settings = await adminDb.getSettings?.().catch(() => null);
154
+ const screenAccess = settings?.securityConfig?.screenAccess;
155
+ if (screenAccess?.enabled && screenAccess?.preventSleep) {
156
+ startPreventSleep();
157
+ console.log("[startup] Prevent-sleep enabled \u2014 system will stay awake while agents are active");
158
+ }
159
+ }
160
+ } catch {
161
+ }
162
+ try {
163
+ await setupSystemPersistence();
164
+ } catch (e) {
165
+ console.warn("[startup] System persistence setup skipped: " + e.message);
166
+ }
167
+ const tunnelToken = process.env.CLOUDFLARED_TOKEN;
168
+ if (tunnelToken) {
169
+ try {
170
+ const { execSync, spawn } = await import("child_process");
171
+ try {
172
+ execSync(process.platform === "win32" ? "where cloudflared" : "which cloudflared", { timeout: 3e3 });
173
+ } catch {
174
+ console.log("[startup] cloudflared not found \u2014 skipping tunnel auto-start");
175
+ console.log("[startup] Install cloudflared to enable tunnel: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/");
176
+ return;
177
+ }
178
+ try {
179
+ if (process.platform === "win32") {
180
+ const tasklist = execSync('tasklist /FI "IMAGENAME eq cloudflared.exe" /NH', { encoding: "utf8", timeout: 5e3 });
181
+ if (tasklist.includes("cloudflared.exe")) {
182
+ console.log("[startup] cloudflared tunnel already running");
183
+ return;
184
+ }
185
+ } else {
186
+ execSync('pgrep -f "cloudflared.*tunnel.*run"', { timeout: 3e3 });
187
+ console.log("[startup] cloudflared tunnel already running");
188
+ return;
189
+ }
190
+ } catch {
191
+ }
192
+ const subdomain = process.env.AGENTICMAIL_SUBDOMAIN || process.env.AGENTICMAIL_DOMAIN || "";
193
+ console.log(`[startup] Starting cloudflared tunnel${subdomain ? ` for ${subdomain}.agenticmail.io` : ""}...`);
194
+ let cfBin = "cloudflared";
195
+ if (process.platform === "win32") {
196
+ try {
197
+ cfBin = execSync("where cloudflared", { encoding: "utf8", timeout: 3e3 }).trim().split("\n")[0].trim();
198
+ } catch {
199
+ const candidate = `${process.env.LOCALAPPDATA || ""}\\cloudflared\\cloudflared.exe`;
200
+ try {
201
+ (await import("fs")).statSync(candidate);
202
+ cfBin = candidate;
203
+ } catch {
204
+ }
205
+ }
206
+ }
207
+ const child = spawn(cfBin, ["tunnel", "--no-autoupdate", "run", "--token", tunnelToken], {
208
+ detached: true,
209
+ stdio: "ignore"
210
+ });
211
+ child.unref();
212
+ console.log("[startup] cloudflared tunnel started (pid " + child.pid + ")");
213
+ } catch (e) {
214
+ console.warn("[startup] Could not auto-start cloudflared: " + e.message);
215
+ }
216
+ }
217
+ }
218
+ async function setupSystemPersistence() {
219
+ const { execSync, spawnSync } = await import("child_process");
220
+ const { existsSync: exists, writeFileSync, mkdirSync } = await import("fs");
221
+ const { join: pathJoin } = await import("path");
222
+ const platform = process.platform;
223
+ if (!process.env.PM2_HOME && !process.env.pm_id) {
224
+ return;
225
+ }
226
+ const markerDir = pathJoin(homedir(), ".agenticmail");
227
+ const markerFile = pathJoin(markerDir, ".persistence-configured");
228
+ if (exists(markerFile)) {
229
+ try {
230
+ execSync("pm2 save --silent", { timeout: 1e4, stdio: "ignore" });
231
+ } catch {
232
+ }
233
+ return;
234
+ }
235
+ console.log("[startup] Configuring system persistence (one-time setup)...");
236
+ try {
237
+ if (platform === "darwin") {
238
+ const result = spawnSync("pm2", ["startup", "launchd", "--silent"], {
239
+ timeout: 15e3,
240
+ stdio: "pipe",
241
+ encoding: "utf-8"
242
+ });
243
+ const output = (result.stdout || "") + (result.stderr || "");
244
+ const sudoMatch = output.match(/sudo\s+env\s+.*pm2\s+startup.*/);
245
+ if (sudoMatch) {
246
+ console.log("[startup] PM2 startup requires sudo. Run this once:");
247
+ console.log(" " + sudoMatch[0]);
248
+ } else {
249
+ console.log("[startup] PM2 startup configured (launchd)");
250
+ }
251
+ const plistPath = pathJoin(homedir(), "Library", "LaunchAgents", `pm2.${process.env.USER || "user"}.plist`);
252
+ if (exists(plistPath)) {
253
+ try {
254
+ execSync(`launchctl load -w "${plistPath}"`, { timeout: 5e3, stdio: "ignore" });
255
+ } catch {
256
+ }
257
+ }
258
+ } else if (platform === "linux") {
259
+ const result = spawnSync("pm2", ["startup", "systemd", "--silent"], {
260
+ timeout: 15e3,
261
+ stdio: "pipe",
262
+ encoding: "utf-8"
263
+ });
264
+ const output = (result.stdout || "") + (result.stderr || "");
265
+ const sudoMatch = output.match(/sudo\s+env\s+.*pm2\s+startup.*/);
266
+ if (sudoMatch) {
267
+ try {
268
+ execSync(sudoMatch[0], { timeout: 15e3, stdio: "ignore" });
269
+ console.log("[startup] PM2 startup configured (systemd)");
270
+ } catch {
271
+ console.log("[startup] PM2 startup requires root. Run this once:");
272
+ console.log(" " + sudoMatch[0]);
273
+ }
274
+ } else {
275
+ console.log("[startup] PM2 startup configured (systemd)");
276
+ }
277
+ } else if (platform === "win32") {
278
+ try {
279
+ execSync("npm list -g pm2-windows-startup", { timeout: 1e4, stdio: "ignore" });
280
+ } catch {
281
+ console.log("[startup] Installing pm2-windows-startup...");
282
+ try {
283
+ execSync("npm install -g pm2-windows-startup", { timeout: 6e4, stdio: "ignore" });
284
+ execSync("pm2-startup install", { timeout: 15e3, stdio: "ignore" });
285
+ console.log("[startup] PM2 startup configured (Windows Service)");
286
+ } catch (e) {
287
+ console.warn("[startup] Could not install pm2-windows-startup: " + e.message);
288
+ }
289
+ }
290
+ }
291
+ } catch (e) {
292
+ console.warn("[startup] PM2 startup setup: " + e.message);
293
+ }
294
+ try {
295
+ const moduleList = execSync("pm2 ls --silent 2>/dev/null || true", { timeout: 1e4, encoding: "utf-8" });
296
+ if (!moduleList.includes("pm2-logrotate")) {
297
+ console.log("[startup] Installing pm2-logrotate...");
298
+ execSync("pm2 install pm2-logrotate --silent", { timeout: 6e4, stdio: "ignore" });
299
+ execSync("pm2 set pm2-logrotate:max_size 10M --silent", { timeout: 5e3, stdio: "ignore" });
300
+ execSync("pm2 set pm2-logrotate:retain 5 --silent", { timeout: 5e3, stdio: "ignore" });
301
+ execSync("pm2 set pm2-logrotate:compress true --silent", { timeout: 5e3, stdio: "ignore" });
302
+ console.log("[startup] Log rotation configured (10MB, 5 files)");
303
+ }
304
+ } catch {
305
+ }
306
+ try {
307
+ execSync("pm2 save --silent", { timeout: 1e4, stdio: "ignore" });
308
+ console.log("[startup] Process list saved");
309
+ } catch {
310
+ }
311
+ try {
312
+ if (!exists(markerDir)) mkdirSync(markerDir, { recursive: true });
313
+ writeFileSync(markerFile, (/* @__PURE__ */ new Date()).toISOString() + `
314
+ platform=${platform}
315
+ `, { mode: 384 });
316
+ console.log("[startup] System persistence configured successfully");
317
+ } catch {
318
+ }
319
+ }
320
+ export {
321
+ runServe
322
+ };
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-XDFSJIQV.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
68
+ import("./cli-serve-4VIBMXMT.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
69
69
  break;
70
70
  case "agent":
71
- import("./cli-agent-FSO2N7I6.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
71
+ import("./cli-agent-7CAFSYOM.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
72
72
  break;
73
73
  case "setup":
74
74
  default:
75
- import("./setup-7ENTPINX.js").then((m) => m.runSetupWizard()).catch(fatal);
75
+ import("./setup-MLIPR2U3.js").then((m) => m.runSetupWizard()).catch(fatal);
76
76
  break;
77
77
  }
78
78
  function fatal(err) {
@@ -128,7 +128,7 @@ export function formatUptime(seconds) {
128
128
  export var DEPLOY_PHASES = ['validate', 'provision', 'configure', 'upload', 'install', 'start', 'healthcheck', 'complete'];
129
129
  export var DEPLOY_PHASE_LABELS = { validate: 'Validate Config', provision: 'Provision Infrastructure', configure: 'Configure Environment', upload: 'Upload Agent Files', install: 'Install Dependencies', start: 'Start Agent Process', healthcheck: 'Health Check', complete: 'Complete' };
130
130
 
131
- export async function showConfirm(opts) { return window.__showConfirm ? window.__showConfirm(opts) : confirm(opts.message); }
131
+ export async function showConfirm(opts) { var o = typeof opts === 'string' ? { message: opts } : opts; return window.__showConfirm ? window.__showConfirm(o) : confirm(o.message || o); }
132
132
 
133
133
  var _uuidRe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
134
134
 
@@ -5,7 +5,7 @@
5
5
  </head><body>
6
6
  <a href="javascript:history.back()" class="back">← Back to Dashboard</a>
7
7
  <h1>Polymarket Trading</h1>
8
- <p style="color:var(--text-muted);margin-bottom:24px">Institutional-grade prediction market trading with 108 tools across 9 skills — on-chain intelligence, social analysis, quantitative modeling, smart execution, counter-intelligence, and self-improving AI agents that learn from every trade.</p>
8
+ <p style="color:var(--text-muted);margin-bottom:24px">Institutional-grade prediction market trading with 114+ tools across 10 skills — on-chain intelligence, social analysis, quantitative modeling, smart execution, counter-intelligence, trading optimization, and self-improving AI agents that learn from every trade.</p>
9
9
 
10
10
  <div class="toc">
11
11
  <h3>Table of Contents</h3>