@deepseekdev/coder 1.0.74

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 (711) hide show
  1. package/LICENSE +21 -0
  2. package/agents/agi-code.rules.json +159 -0
  3. package/agents/general.rules.json +181 -0
  4. package/dist/bin/cliMode.d.ts +8 -0
  5. package/dist/bin/cliMode.d.ts.map +1 -0
  6. package/dist/bin/cliMode.js +20 -0
  7. package/dist/bin/cliMode.js.map +1 -0
  8. package/dist/bin/deepseek.d.ts +3 -0
  9. package/dist/bin/deepseek.d.ts.map +1 -0
  10. package/dist/bin/deepseek.js +137 -0
  11. package/dist/bin/deepseek.js.map +1 -0
  12. package/dist/bin/erosolar.d.ts +7 -0
  13. package/dist/bin/erosolar.d.ts.map +1 -0
  14. package/dist/bin/erosolar.js +7 -0
  15. package/dist/bin/erosolar.js.map +1 -0
  16. package/dist/bin/lean.d.ts +9 -0
  17. package/dist/bin/lean.d.ts.map +1 -0
  18. package/dist/bin/lean.js +333 -0
  19. package/dist/bin/lean.js.map +1 -0
  20. package/dist/bin/selfTest.d.ts +14 -0
  21. package/dist/bin/selfTest.d.ts.map +1 -0
  22. package/dist/bin/selfTest.js +298 -0
  23. package/dist/bin/selfTest.js.map +1 -0
  24. package/dist/capabilities/baseCapability.d.ts +72 -0
  25. package/dist/capabilities/baseCapability.d.ts.map +1 -0
  26. package/dist/capabilities/baseCapability.js +183 -0
  27. package/dist/capabilities/baseCapability.js.map +1 -0
  28. package/dist/capabilities/bashCapability.d.ts +13 -0
  29. package/dist/capabilities/bashCapability.d.ts.map +1 -0
  30. package/dist/capabilities/bashCapability.js +24 -0
  31. package/dist/capabilities/bashCapability.js.map +1 -0
  32. package/dist/capabilities/editCapability.d.ts +17 -0
  33. package/dist/capabilities/editCapability.d.ts.map +1 -0
  34. package/dist/capabilities/editCapability.js +27 -0
  35. package/dist/capabilities/editCapability.js.map +1 -0
  36. package/dist/capabilities/enhancedGitCapability.d.ts +7 -0
  37. package/dist/capabilities/enhancedGitCapability.d.ts.map +1 -0
  38. package/dist/capabilities/enhancedGitCapability.js +220 -0
  39. package/dist/capabilities/enhancedGitCapability.js.map +1 -0
  40. package/dist/capabilities/filesystemCapability.d.ts +13 -0
  41. package/dist/capabilities/filesystemCapability.d.ts.map +1 -0
  42. package/dist/capabilities/filesystemCapability.js +24 -0
  43. package/dist/capabilities/filesystemCapability.js.map +1 -0
  44. package/dist/capabilities/gitHistoryCapability.d.ts +6 -0
  45. package/dist/capabilities/gitHistoryCapability.d.ts.map +1 -0
  46. package/dist/capabilities/gitHistoryCapability.js +160 -0
  47. package/dist/capabilities/gitHistoryCapability.js.map +1 -0
  48. package/dist/capabilities/hitlCapability.d.ts +18 -0
  49. package/dist/capabilities/hitlCapability.d.ts.map +1 -0
  50. package/dist/capabilities/hitlCapability.js +29 -0
  51. package/dist/capabilities/hitlCapability.js.map +1 -0
  52. package/dist/capabilities/index.d.ts +11 -0
  53. package/dist/capabilities/index.d.ts.map +1 -0
  54. package/dist/capabilities/index.js +13 -0
  55. package/dist/capabilities/index.js.map +1 -0
  56. package/dist/capabilities/searchCapability.d.ts +19 -0
  57. package/dist/capabilities/searchCapability.d.ts.map +1 -0
  58. package/dist/capabilities/searchCapability.js +29 -0
  59. package/dist/capabilities/searchCapability.js.map +1 -0
  60. package/dist/capabilities/toolManifest.d.ts +3 -0
  61. package/dist/capabilities/toolManifest.d.ts.map +1 -0
  62. package/dist/capabilities/toolManifest.js +163 -0
  63. package/dist/capabilities/toolManifest.js.map +1 -0
  64. package/dist/capabilities/toolRegistry.d.ts +25 -0
  65. package/dist/capabilities/toolRegistry.d.ts.map +1 -0
  66. package/dist/capabilities/toolRegistry.js +150 -0
  67. package/dist/capabilities/toolRegistry.js.map +1 -0
  68. package/dist/capabilities/unifiedCodingCapability.d.ts +48 -0
  69. package/dist/capabilities/unifiedCodingCapability.d.ts.map +1 -0
  70. package/dist/capabilities/unifiedCodingCapability.js +631 -0
  71. package/dist/capabilities/unifiedCodingCapability.js.map +1 -0
  72. package/dist/capabilities/webCapability.d.ts +23 -0
  73. package/dist/capabilities/webCapability.d.ts.map +1 -0
  74. package/dist/capabilities/webCapability.js +33 -0
  75. package/dist/capabilities/webCapability.js.map +1 -0
  76. package/dist/config.d.ts +25 -0
  77. package/dist/config.d.ts.map +1 -0
  78. package/dist/config.js +155 -0
  79. package/dist/config.js.map +1 -0
  80. package/dist/contracts/agent-profiles.schema.json +43 -0
  81. package/dist/contracts/agent-schemas.json +480 -0
  82. package/dist/contracts/models.schema.json +9 -0
  83. package/dist/contracts/module-schema.json +430 -0
  84. package/dist/contracts/schemas/agent-profile.schema.json +157 -0
  85. package/dist/contracts/schemas/agent-rules.schema.json +238 -0
  86. package/dist/contracts/schemas/agent-schemas.schema.json +528 -0
  87. package/dist/contracts/schemas/agent.schema.json +90 -0
  88. package/dist/contracts/schemas/tool-selection.schema.json +174 -0
  89. package/dist/contracts/tools.schema.json +82 -0
  90. package/dist/contracts/unified-schema.json +757 -0
  91. package/dist/contracts/v1/agent.d.ts +187 -0
  92. package/dist/contracts/v1/agent.d.ts.map +1 -0
  93. package/dist/contracts/v1/agent.js +8 -0
  94. package/dist/contracts/v1/agent.js.map +1 -0
  95. package/dist/contracts/v1/agentProfileManifest.d.ts +60 -0
  96. package/dist/contracts/v1/agentProfileManifest.d.ts.map +1 -0
  97. package/dist/contracts/v1/agentProfileManifest.js +9 -0
  98. package/dist/contracts/v1/agentProfileManifest.js.map +1 -0
  99. package/dist/contracts/v1/agentRules.d.ts +60 -0
  100. package/dist/contracts/v1/agentRules.d.ts.map +1 -0
  101. package/dist/contracts/v1/agentRules.js +10 -0
  102. package/dist/contracts/v1/agentRules.js.map +1 -0
  103. package/dist/contracts/v1/provider.d.ts +149 -0
  104. package/dist/contracts/v1/provider.d.ts.map +1 -0
  105. package/dist/contracts/v1/provider.js +7 -0
  106. package/dist/contracts/v1/provider.js.map +1 -0
  107. package/dist/contracts/v1/tool.d.ts +136 -0
  108. package/dist/contracts/v1/tool.d.ts.map +1 -0
  109. package/dist/contracts/v1/tool.js +7 -0
  110. package/dist/contracts/v1/tool.js.map +1 -0
  111. package/dist/contracts/v1/toolAccess.d.ts +43 -0
  112. package/dist/contracts/v1/toolAccess.d.ts.map +1 -0
  113. package/dist/contracts/v1/toolAccess.js +9 -0
  114. package/dist/contracts/v1/toolAccess.js.map +1 -0
  115. package/dist/core/agent.d.ts +320 -0
  116. package/dist/core/agent.d.ts.map +1 -0
  117. package/dist/core/agent.js +1627 -0
  118. package/dist/core/agent.js.map +1 -0
  119. package/dist/core/agentProfileManifest.d.ts +3 -0
  120. package/dist/core/agentProfileManifest.d.ts.map +1 -0
  121. package/dist/core/agentProfileManifest.js +188 -0
  122. package/dist/core/agentProfileManifest.js.map +1 -0
  123. package/dist/core/agentProfiles.d.ts +22 -0
  124. package/dist/core/agentProfiles.d.ts.map +1 -0
  125. package/dist/core/agentProfiles.js +35 -0
  126. package/dist/core/agentProfiles.js.map +1 -0
  127. package/dist/core/agentRulebook.d.ts +11 -0
  128. package/dist/core/agentRulebook.d.ts.map +1 -0
  129. package/dist/core/agentRulebook.js +136 -0
  130. package/dist/core/agentRulebook.js.map +1 -0
  131. package/dist/core/agentSchemaLoader.d.ts +131 -0
  132. package/dist/core/agentSchemaLoader.d.ts.map +1 -0
  133. package/dist/core/agentSchemaLoader.js +235 -0
  134. package/dist/core/agentSchemaLoader.js.map +1 -0
  135. package/dist/core/agiCore.d.ts +312 -0
  136. package/dist/core/agiCore.d.ts.map +1 -0
  137. package/dist/core/agiCore.js +1585 -0
  138. package/dist/core/agiCore.js.map +1 -0
  139. package/dist/core/aiErrorFixer.d.ts +57 -0
  140. package/dist/core/aiErrorFixer.d.ts.map +1 -0
  141. package/dist/core/aiErrorFixer.js +214 -0
  142. package/dist/core/aiErrorFixer.js.map +1 -0
  143. package/dist/core/bashCommandGuidance.d.ts +16 -0
  144. package/dist/core/bashCommandGuidance.d.ts.map +1 -0
  145. package/dist/core/bashCommandGuidance.js +40 -0
  146. package/dist/core/bashCommandGuidance.js.map +1 -0
  147. package/dist/core/constants.d.ts +31 -0
  148. package/dist/core/constants.d.ts.map +1 -0
  149. package/dist/core/constants.js +62 -0
  150. package/dist/core/constants.js.map +1 -0
  151. package/dist/core/contextManager.d.ts +271 -0
  152. package/dist/core/contextManager.d.ts.map +1 -0
  153. package/dist/core/contextManager.js +1073 -0
  154. package/dist/core/contextManager.js.map +1 -0
  155. package/dist/core/contextWindow.d.ts +42 -0
  156. package/dist/core/contextWindow.d.ts.map +1 -0
  157. package/dist/core/contextWindow.js +123 -0
  158. package/dist/core/contextWindow.js.map +1 -0
  159. package/dist/core/customCommands.d.ts +19 -0
  160. package/dist/core/customCommands.d.ts.map +1 -0
  161. package/dist/core/customCommands.js +85 -0
  162. package/dist/core/customCommands.js.map +1 -0
  163. package/dist/core/deepBugAnalyzer.d.ts +25 -0
  164. package/dist/core/deepBugAnalyzer.d.ts.map +1 -0
  165. package/dist/core/deepBugAnalyzer.js +44 -0
  166. package/dist/core/deepBugAnalyzer.js.map +1 -0
  167. package/dist/core/dynamicGuardrails.d.ts +207 -0
  168. package/dist/core/dynamicGuardrails.d.ts.map +1 -0
  169. package/dist/core/dynamicGuardrails.js +455 -0
  170. package/dist/core/dynamicGuardrails.js.map +1 -0
  171. package/dist/core/embeddingProviders.d.ts +80 -0
  172. package/dist/core/embeddingProviders.d.ts.map +1 -0
  173. package/dist/core/embeddingProviders.js +241 -0
  174. package/dist/core/embeddingProviders.js.map +1 -0
  175. package/dist/core/episodicMemory.d.ts +259 -0
  176. package/dist/core/episodicMemory.d.ts.map +1 -0
  177. package/dist/core/episodicMemory.js +834 -0
  178. package/dist/core/episodicMemory.js.map +1 -0
  179. package/dist/core/errors/apiKeyErrors.d.ts +11 -0
  180. package/dist/core/errors/apiKeyErrors.d.ts.map +1 -0
  181. package/dist/core/errors/apiKeyErrors.js +159 -0
  182. package/dist/core/errors/apiKeyErrors.js.map +1 -0
  183. package/dist/core/errors/errorTypes.d.ts +111 -0
  184. package/dist/core/errors/errorTypes.d.ts.map +1 -0
  185. package/dist/core/errors/errorTypes.js +345 -0
  186. package/dist/core/errors/errorTypes.js.map +1 -0
  187. package/dist/core/errors/index.d.ts +50 -0
  188. package/dist/core/errors/index.d.ts.map +1 -0
  189. package/dist/core/errors/index.js +156 -0
  190. package/dist/core/errors/index.js.map +1 -0
  191. package/dist/core/errors/networkErrors.d.ts +14 -0
  192. package/dist/core/errors/networkErrors.d.ts.map +1 -0
  193. package/dist/core/errors/networkErrors.js +53 -0
  194. package/dist/core/errors/networkErrors.js.map +1 -0
  195. package/dist/core/errors/safetyValidator.d.ts +109 -0
  196. package/dist/core/errors/safetyValidator.d.ts.map +1 -0
  197. package/dist/core/errors/safetyValidator.js +271 -0
  198. package/dist/core/errors/safetyValidator.js.map +1 -0
  199. package/dist/core/errors.d.ts +4 -0
  200. package/dist/core/errors.d.ts.map +1 -0
  201. package/dist/core/errors.js +33 -0
  202. package/dist/core/errors.js.map +1 -0
  203. package/dist/core/finalResponseFormatter.d.ts +10 -0
  204. package/dist/core/finalResponseFormatter.d.ts.map +1 -0
  205. package/dist/core/finalResponseFormatter.js +14 -0
  206. package/dist/core/finalResponseFormatter.js.map +1 -0
  207. package/dist/core/flowProtection.d.ts +154 -0
  208. package/dist/core/flowProtection.d.ts.map +1 -0
  209. package/dist/core/flowProtection.js +439 -0
  210. package/dist/core/flowProtection.js.map +1 -0
  211. package/dist/core/gitWorktreeManager.d.ts +126 -0
  212. package/dist/core/gitWorktreeManager.d.ts.map +1 -0
  213. package/dist/core/gitWorktreeManager.js +403 -0
  214. package/dist/core/gitWorktreeManager.js.map +1 -0
  215. package/dist/core/global-macbook-access.d.ts +59 -0
  216. package/dist/core/global-macbook-access.d.ts.map +1 -0
  217. package/dist/core/global-macbook-access.js +101 -0
  218. package/dist/core/global-macbook-access.js.map +1 -0
  219. package/dist/core/guardrails.d.ts +146 -0
  220. package/dist/core/guardrails.d.ts.map +1 -0
  221. package/dist/core/guardrails.js +361 -0
  222. package/dist/core/guardrails.js.map +1 -0
  223. package/dist/core/hallucinationGuard.d.ts +57 -0
  224. package/dist/core/hallucinationGuard.d.ts.map +1 -0
  225. package/dist/core/hallucinationGuard.js +237 -0
  226. package/dist/core/hallucinationGuard.js.map +1 -0
  227. package/dist/core/hitl.d.ts +109 -0
  228. package/dist/core/hitl.d.ts.map +1 -0
  229. package/dist/core/hitl.js +371 -0
  230. package/dist/core/hitl.js.map +1 -0
  231. package/dist/core/hooks.d.ts +113 -0
  232. package/dist/core/hooks.d.ts.map +1 -0
  233. package/dist/core/hooks.js +364 -0
  234. package/dist/core/hooks.js.map +1 -0
  235. package/dist/core/hotReload.d.ts +154 -0
  236. package/dist/core/hotReload.d.ts.map +1 -0
  237. package/dist/core/hotReload.js +451 -0
  238. package/dist/core/hotReload.js.map +1 -0
  239. package/dist/core/hypothesisEngine.d.ts +27 -0
  240. package/dist/core/hypothesisEngine.d.ts.map +1 -0
  241. package/dist/core/hypothesisEngine.js +58 -0
  242. package/dist/core/hypothesisEngine.js.map +1 -0
  243. package/dist/core/index.d.ts +18 -0
  244. package/dist/core/index.d.ts.map +1 -0
  245. package/dist/core/index.js +40 -0
  246. package/dist/core/index.js.map +1 -0
  247. package/dist/core/initialExplorer.d.ts +53 -0
  248. package/dist/core/initialExplorer.d.ts.map +1 -0
  249. package/dist/core/initialExplorer.js +423 -0
  250. package/dist/core/initialExplorer.js.map +1 -0
  251. package/dist/core/inputProtection.d.ts +122 -0
  252. package/dist/core/inputProtection.d.ts.map +1 -0
  253. package/dist/core/inputProtection.js +422 -0
  254. package/dist/core/inputProtection.js.map +1 -0
  255. package/dist/core/liveGCPVerification.d.ts +41 -0
  256. package/dist/core/liveGCPVerification.d.ts.map +1 -0
  257. package/dist/core/liveGCPVerification.js +745 -0
  258. package/dist/core/liveGCPVerification.js.map +1 -0
  259. package/dist/core/modelDiscovery.d.ts +105 -0
  260. package/dist/core/modelDiscovery.d.ts.map +1 -0
  261. package/dist/core/modelDiscovery.js +768 -0
  262. package/dist/core/modelDiscovery.js.map +1 -0
  263. package/dist/core/multilinePasteHandler.d.ts +35 -0
  264. package/dist/core/multilinePasteHandler.d.ts.map +1 -0
  265. package/dist/core/multilinePasteHandler.js +81 -0
  266. package/dist/core/multilinePasteHandler.js.map +1 -0
  267. package/dist/core/parallelExecutor.d.ts +215 -0
  268. package/dist/core/parallelExecutor.d.ts.map +1 -0
  269. package/dist/core/parallelExecutor.js +584 -0
  270. package/dist/core/parallelExecutor.js.map +1 -0
  271. package/dist/core/preferences.d.ts +71 -0
  272. package/dist/core/preferences.d.ts.map +1 -0
  273. package/dist/core/preferences.js +341 -0
  274. package/dist/core/preferences.js.map +1 -0
  275. package/dist/core/productTestHarness.d.ts +46 -0
  276. package/dist/core/productTestHarness.d.ts.map +1 -0
  277. package/dist/core/productTestHarness.js +128 -0
  278. package/dist/core/productTestHarness.js.map +1 -0
  279. package/dist/core/providerKeys.d.ts +20 -0
  280. package/dist/core/providerKeys.d.ts.map +1 -0
  281. package/dist/core/providerKeys.js +40 -0
  282. package/dist/core/providerKeys.js.map +1 -0
  283. package/dist/core/resultVerification.d.ts +47 -0
  284. package/dist/core/resultVerification.d.ts.map +1 -0
  285. package/dist/core/resultVerification.js +126 -0
  286. package/dist/core/resultVerification.js.map +1 -0
  287. package/dist/core/revenueEnvValidator.d.ts +30 -0
  288. package/dist/core/revenueEnvValidator.d.ts.map +1 -0
  289. package/dist/core/revenueEnvValidator.js +244 -0
  290. package/dist/core/revenueEnvValidator.js.map +1 -0
  291. package/dist/core/schemaValidator.d.ts +49 -0
  292. package/dist/core/schemaValidator.d.ts.map +1 -0
  293. package/dist/core/schemaValidator.js +234 -0
  294. package/dist/core/schemaValidator.js.map +1 -0
  295. package/dist/core/secretStore.d.ts +48 -0
  296. package/dist/core/secretStore.d.ts.map +1 -0
  297. package/dist/core/secretStore.js +295 -0
  298. package/dist/core/secretStore.js.map +1 -0
  299. package/dist/core/selfUpgrade.d.ts +79 -0
  300. package/dist/core/selfUpgrade.d.ts.map +1 -0
  301. package/dist/core/selfUpgrade.js +92 -0
  302. package/dist/core/selfUpgrade.js.map +1 -0
  303. package/dist/core/sessionStorage.d.ts +10 -0
  304. package/dist/core/sessionStorage.d.ts.map +1 -0
  305. package/dist/core/sessionStorage.js +46 -0
  306. package/dist/core/sessionStorage.js.map +1 -0
  307. package/dist/core/sessionStore.d.ts +35 -0
  308. package/dist/core/sessionStore.d.ts.map +1 -0
  309. package/dist/core/sessionStore.js +191 -0
  310. package/dist/core/sessionStore.js.map +1 -0
  311. package/dist/core/shutdown.d.ts +34 -0
  312. package/dist/core/shutdown.d.ts.map +1 -0
  313. package/dist/core/shutdown.js +173 -0
  314. package/dist/core/shutdown.js.map +1 -0
  315. package/dist/core/sudoPasswordManager.d.ts +52 -0
  316. package/dist/core/sudoPasswordManager.d.ts.map +1 -0
  317. package/dist/core/sudoPasswordManager.js +115 -0
  318. package/dist/core/sudoPasswordManager.js.map +1 -0
  319. package/dist/core/taskCompletionDetector.d.ts +112 -0
  320. package/dist/core/taskCompletionDetector.d.ts.map +1 -0
  321. package/dist/core/taskCompletionDetector.js +469 -0
  322. package/dist/core/taskCompletionDetector.js.map +1 -0
  323. package/dist/core/testFailureMonitor.d.ts +67 -0
  324. package/dist/core/testFailureMonitor.d.ts.map +1 -0
  325. package/dist/core/testFailureMonitor.js +262 -0
  326. package/dist/core/testFailureMonitor.js.map +1 -0
  327. package/dist/core/toolPreconditions.d.ts +34 -0
  328. package/dist/core/toolPreconditions.d.ts.map +1 -0
  329. package/dist/core/toolPreconditions.js +242 -0
  330. package/dist/core/toolPreconditions.js.map +1 -0
  331. package/dist/core/toolRuntime.d.ts +185 -0
  332. package/dist/core/toolRuntime.d.ts.map +1 -0
  333. package/dist/core/toolRuntime.js +412 -0
  334. package/dist/core/toolRuntime.js.map +1 -0
  335. package/dist/core/types/utilityTypes.d.ts +183 -0
  336. package/dist/core/types/utilityTypes.d.ts.map +1 -0
  337. package/dist/core/types/utilityTypes.js +273 -0
  338. package/dist/core/types/utilityTypes.js.map +1 -0
  339. package/dist/core/types.d.ts +334 -0
  340. package/dist/core/types.d.ts.map +1 -0
  341. package/dist/core/types.js +76 -0
  342. package/dist/core/types.js.map +1 -0
  343. package/dist/core/unifiedOrchestrator.d.ts +47 -0
  344. package/dist/core/unifiedOrchestrator.d.ts.map +1 -0
  345. package/dist/core/unifiedOrchestrator.js +103 -0
  346. package/dist/core/unifiedOrchestrator.js.map +1 -0
  347. package/dist/core/unrestricted-mode.d.ts +42 -0
  348. package/dist/core/unrestricted-mode.d.ts.map +1 -0
  349. package/dist/core/unrestricted-mode.js +88 -0
  350. package/dist/core/unrestricted-mode.js.map +1 -0
  351. package/dist/core/updateChecker.d.ts +148 -0
  352. package/dist/core/updateChecker.d.ts.map +1 -0
  353. package/dist/core/updateChecker.js +593 -0
  354. package/dist/core/updateChecker.js.map +1 -0
  355. package/dist/headless/interactiveShell.d.ts +22 -0
  356. package/dist/headless/interactiveShell.d.ts.map +1 -0
  357. package/dist/headless/interactiveShell.js +4045 -0
  358. package/dist/headless/interactiveShell.js.map +1 -0
  359. package/dist/headless/quickMode.d.ts +26 -0
  360. package/dist/headless/quickMode.d.ts.map +1 -0
  361. package/dist/headless/quickMode.js +236 -0
  362. package/dist/headless/quickMode.js.map +1 -0
  363. package/dist/leanAgent.d.ts +73 -0
  364. package/dist/leanAgent.d.ts.map +1 -0
  365. package/dist/leanAgent.js +175 -0
  366. package/dist/leanAgent.js.map +1 -0
  367. package/dist/orchestration/index.d.ts +14 -0
  368. package/dist/orchestration/index.d.ts.map +1 -0
  369. package/dist/orchestration/index.js +12 -0
  370. package/dist/orchestration/index.js.map +1 -0
  371. package/dist/plugins/index.d.ts +49 -0
  372. package/dist/plugins/index.d.ts.map +1 -0
  373. package/dist/plugins/index.js +104 -0
  374. package/dist/plugins/index.js.map +1 -0
  375. package/dist/plugins/providers/anthropic/index.d.ts +9 -0
  376. package/dist/plugins/providers/anthropic/index.d.ts.map +1 -0
  377. package/dist/plugins/providers/anthropic/index.js +48 -0
  378. package/dist/plugins/providers/anthropic/index.js.map +1 -0
  379. package/dist/plugins/providers/deepseek/index.d.ts +11 -0
  380. package/dist/plugins/providers/deepseek/index.d.ts.map +1 -0
  381. package/dist/plugins/providers/deepseek/index.js +54 -0
  382. package/dist/plugins/providers/deepseek/index.js.map +1 -0
  383. package/dist/plugins/providers/index.d.ts +2 -0
  384. package/dist/plugins/providers/index.d.ts.map +1 -0
  385. package/dist/plugins/providers/index.js +17 -0
  386. package/dist/plugins/providers/index.js.map +1 -0
  387. package/dist/plugins/providers/openai/index.d.ts +10 -0
  388. package/dist/plugins/providers/openai/index.d.ts.map +1 -0
  389. package/dist/plugins/providers/openai/index.js +47 -0
  390. package/dist/plugins/providers/openai/index.js.map +1 -0
  391. package/dist/plugins/providers/xai/index.d.ts +10 -0
  392. package/dist/plugins/providers/xai/index.d.ts.map +1 -0
  393. package/dist/plugins/providers/xai/index.js +47 -0
  394. package/dist/plugins/providers/xai/index.js.map +1 -0
  395. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts +10 -0
  396. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts.map +1 -0
  397. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js +110 -0
  398. package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js.map +1 -0
  399. package/dist/plugins/tools/bash/localBashPlugin.d.ts +3 -0
  400. package/dist/plugins/tools/bash/localBashPlugin.d.ts.map +1 -0
  401. package/dist/plugins/tools/bash/localBashPlugin.js +14 -0
  402. package/dist/plugins/tools/bash/localBashPlugin.js.map +1 -0
  403. package/dist/plugins/tools/edit/editPlugin.d.ts +9 -0
  404. package/dist/plugins/tools/edit/editPlugin.d.ts.map +1 -0
  405. package/dist/plugins/tools/edit/editPlugin.js +15 -0
  406. package/dist/plugins/tools/edit/editPlugin.js.map +1 -0
  407. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.d.ts +3 -0
  408. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.d.ts.map +1 -0
  409. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.js +9 -0
  410. package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.js.map +1 -0
  411. package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts +3 -0
  412. package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts.map +1 -0
  413. package/dist/plugins/tools/filesystem/localFilesystemPlugin.js +14 -0
  414. package/dist/plugins/tools/filesystem/localFilesystemPlugin.js.map +1 -0
  415. package/dist/plugins/tools/gitHistory/gitHistoryPlugin.d.ts +3 -0
  416. package/dist/plugins/tools/gitHistory/gitHistoryPlugin.d.ts.map +1 -0
  417. package/dist/plugins/tools/gitHistory/gitHistoryPlugin.js +9 -0
  418. package/dist/plugins/tools/gitHistory/gitHistoryPlugin.js.map +1 -0
  419. package/dist/plugins/tools/index.d.ts +3 -0
  420. package/dist/plugins/tools/index.d.ts.map +1 -0
  421. package/dist/plugins/tools/index.js +3 -0
  422. package/dist/plugins/tools/index.js.map +1 -0
  423. package/dist/plugins/tools/integrity/integrityPlugin.d.ts +3 -0
  424. package/dist/plugins/tools/integrity/integrityPlugin.d.ts.map +1 -0
  425. package/dist/plugins/tools/integrity/integrityPlugin.js +31 -0
  426. package/dist/plugins/tools/integrity/integrityPlugin.js.map +1 -0
  427. package/dist/plugins/tools/mcp/mcpPlugin.d.ts +3 -0
  428. package/dist/plugins/tools/mcp/mcpPlugin.d.ts.map +1 -0
  429. package/dist/plugins/tools/mcp/mcpPlugin.js +27 -0
  430. package/dist/plugins/tools/mcp/mcpPlugin.js.map +1 -0
  431. package/dist/plugins/tools/nodeDefaults.d.ts +13 -0
  432. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -0
  433. package/dist/plugins/tools/nodeDefaults.js +31 -0
  434. package/dist/plugins/tools/nodeDefaults.js.map +1 -0
  435. package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts +3 -0
  436. package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts.map +1 -0
  437. package/dist/plugins/tools/orchestration/orchestrationPlugin.js +340 -0
  438. package/dist/plugins/tools/orchestration/orchestrationPlugin.js.map +1 -0
  439. package/dist/plugins/tools/registry.d.ts +22 -0
  440. package/dist/plugins/tools/registry.d.ts.map +1 -0
  441. package/dist/plugins/tools/registry.js +58 -0
  442. package/dist/plugins/tools/registry.js.map +1 -0
  443. package/dist/plugins/tools/search/localSearchPlugin.d.ts +3 -0
  444. package/dist/plugins/tools/search/localSearchPlugin.d.ts.map +1 -0
  445. package/dist/plugins/tools/search/localSearchPlugin.js +14 -0
  446. package/dist/plugins/tools/search/localSearchPlugin.js.map +1 -0
  447. package/dist/plugins/tools/skills/skillPlugin.d.ts +3 -0
  448. package/dist/plugins/tools/skills/skillPlugin.d.ts.map +1 -0
  449. package/dist/plugins/tools/skills/skillPlugin.js +27 -0
  450. package/dist/plugins/tools/skills/skillPlugin.js.map +1 -0
  451. package/dist/providers/baseProvider.d.ts +148 -0
  452. package/dist/providers/baseProvider.d.ts.map +1 -0
  453. package/dist/providers/baseProvider.js +284 -0
  454. package/dist/providers/baseProvider.js.map +1 -0
  455. package/dist/providers/openaiChatCompletionsProvider.d.ts +64 -0
  456. package/dist/providers/openaiChatCompletionsProvider.d.ts.map +1 -0
  457. package/dist/providers/openaiChatCompletionsProvider.js +1003 -0
  458. package/dist/providers/openaiChatCompletionsProvider.js.map +1 -0
  459. package/dist/providers/providerFactory.d.ts +22 -0
  460. package/dist/providers/providerFactory.d.ts.map +1 -0
  461. package/dist/providers/providerFactory.js +25 -0
  462. package/dist/providers/providerFactory.js.map +1 -0
  463. package/dist/providers/resilientProvider.d.ts +103 -0
  464. package/dist/providers/resilientProvider.d.ts.map +1 -0
  465. package/dist/providers/resilientProvider.js +462 -0
  466. package/dist/providers/resilientProvider.js.map +1 -0
  467. package/dist/runtime/agentController.d.ts +114 -0
  468. package/dist/runtime/agentController.d.ts.map +1 -0
  469. package/dist/runtime/agentController.js +707 -0
  470. package/dist/runtime/agentController.js.map +1 -0
  471. package/dist/runtime/agentHost.d.ts +61 -0
  472. package/dist/runtime/agentHost.d.ts.map +1 -0
  473. package/dist/runtime/agentHost.js +157 -0
  474. package/dist/runtime/agentHost.js.map +1 -0
  475. package/dist/runtime/agentSession.d.ts +45 -0
  476. package/dist/runtime/agentSession.d.ts.map +1 -0
  477. package/dist/runtime/agentSession.js +210 -0
  478. package/dist/runtime/agentSession.js.map +1 -0
  479. package/dist/runtime/agentWorkerPool.d.ts +167 -0
  480. package/dist/runtime/agentWorkerPool.d.ts.map +1 -0
  481. package/dist/runtime/agentWorkerPool.js +435 -0
  482. package/dist/runtime/agentWorkerPool.js.map +1 -0
  483. package/dist/runtime/node.d.ts +7 -0
  484. package/dist/runtime/node.d.ts.map +1 -0
  485. package/dist/runtime/node.js +25 -0
  486. package/dist/runtime/node.js.map +1 -0
  487. package/dist/runtime/universal.d.ts +18 -0
  488. package/dist/runtime/universal.d.ts.map +1 -0
  489. package/dist/runtime/universal.js +21 -0
  490. package/dist/runtime/universal.js.map +1 -0
  491. package/dist/shell/autoExecutor.d.ts +70 -0
  492. package/dist/shell/autoExecutor.d.ts.map +1 -0
  493. package/dist/shell/autoExecutor.js +320 -0
  494. package/dist/shell/autoExecutor.js.map +1 -0
  495. package/dist/shell/commandRegistry.d.ts +122 -0
  496. package/dist/shell/commandRegistry.d.ts.map +1 -0
  497. package/dist/shell/commandRegistry.js +398 -0
  498. package/dist/shell/commandRegistry.js.map +1 -0
  499. package/dist/shell/composableMessage.d.ts +178 -0
  500. package/dist/shell/composableMessage.d.ts.map +1 -0
  501. package/dist/shell/composableMessage.js +384 -0
  502. package/dist/shell/composableMessage.js.map +1 -0
  503. package/dist/shell/liveStatus.d.ts +27 -0
  504. package/dist/shell/liveStatus.d.ts.map +1 -0
  505. package/dist/shell/liveStatus.js +53 -0
  506. package/dist/shell/liveStatus.js.map +1 -0
  507. package/dist/shell/systemPrompt.d.ts +12 -0
  508. package/dist/shell/systemPrompt.d.ts.map +1 -0
  509. package/dist/shell/systemPrompt.js +16 -0
  510. package/dist/shell/systemPrompt.js.map +1 -0
  511. package/dist/shell/vimMode.d.ts +66 -0
  512. package/dist/shell/vimMode.d.ts.map +1 -0
  513. package/dist/shell/vimMode.js +435 -0
  514. package/dist/shell/vimMode.js.map +1 -0
  515. package/dist/tools/bashTools.d.ts +7 -0
  516. package/dist/tools/bashTools.d.ts.map +1 -0
  517. package/dist/tools/bashTools.js +773 -0
  518. package/dist/tools/bashTools.js.map +1 -0
  519. package/dist/tools/diffUtils.d.ts +43 -0
  520. package/dist/tools/diffUtils.d.ts.map +1 -0
  521. package/dist/tools/diffUtils.js +607 -0
  522. package/dist/tools/diffUtils.js.map +1 -0
  523. package/dist/tools/editTools.d.ts +29 -0
  524. package/dist/tools/editTools.d.ts.map +1 -0
  525. package/dist/tools/editTools.js +673 -0
  526. package/dist/tools/editTools.js.map +1 -0
  527. package/dist/tools/emailTools.d.ts +140 -0
  528. package/dist/tools/emailTools.d.ts.map +1 -0
  529. package/dist/tools/emailTools.js +793 -0
  530. package/dist/tools/emailTools.js.map +1 -0
  531. package/dist/tools/fileChangeTracker.d.ts +47 -0
  532. package/dist/tools/fileChangeTracker.d.ts.map +1 -0
  533. package/dist/tools/fileChangeTracker.js +154 -0
  534. package/dist/tools/fileChangeTracker.js.map +1 -0
  535. package/dist/tools/fileReadTracker.d.ts +69 -0
  536. package/dist/tools/fileReadTracker.d.ts.map +1 -0
  537. package/dist/tools/fileReadTracker.js +213 -0
  538. package/dist/tools/fileReadTracker.js.map +1 -0
  539. package/dist/tools/fileTools.d.ts +3 -0
  540. package/dist/tools/fileTools.d.ts.map +1 -0
  541. package/dist/tools/fileTools.js +333 -0
  542. package/dist/tools/fileTools.js.map +1 -0
  543. package/dist/tools/grepTools.d.ts +3 -0
  544. package/dist/tools/grepTools.d.ts.map +1 -0
  545. package/dist/tools/grepTools.js +128 -0
  546. package/dist/tools/grepTools.js.map +1 -0
  547. package/dist/tools/hitlTools.d.ts +7 -0
  548. package/dist/tools/hitlTools.d.ts.map +1 -0
  549. package/dist/tools/hitlTools.js +189 -0
  550. package/dist/tools/hitlTools.js.map +1 -0
  551. package/dist/tools/humanOpsTools.d.ts +3 -0
  552. package/dist/tools/humanOpsTools.d.ts.map +1 -0
  553. package/dist/tools/humanOpsTools.js +86 -0
  554. package/dist/tools/humanOpsTools.js.map +1 -0
  555. package/dist/tools/localExplore.d.ts +38 -0
  556. package/dist/tools/localExplore.d.ts.map +1 -0
  557. package/dist/tools/localExplore.js +30 -0
  558. package/dist/tools/localExplore.js.map +1 -0
  559. package/dist/tools/metaTools.d.ts +3 -0
  560. package/dist/tools/metaTools.d.ts.map +1 -0
  561. package/dist/tools/metaTools.js +148 -0
  562. package/dist/tools/metaTools.js.map +1 -0
  563. package/dist/tools/planningTools.d.ts +81 -0
  564. package/dist/tools/planningTools.d.ts.map +1 -0
  565. package/dist/tools/planningTools.js +370 -0
  566. package/dist/tools/planningTools.js.map +1 -0
  567. package/dist/tools/searchTools.d.ts +12 -0
  568. package/dist/tools/searchTools.d.ts.map +1 -0
  569. package/dist/tools/searchTools.js +363 -0
  570. package/dist/tools/searchTools.js.map +1 -0
  571. package/dist/tools/telemetryTools.d.ts +10 -0
  572. package/dist/tools/telemetryTools.d.ts.map +1 -0
  573. package/dist/tools/telemetryTools.js +9 -0
  574. package/dist/tools/telemetryTools.js.map +1 -0
  575. package/dist/tools/unifiedOps.d.ts +3 -0
  576. package/dist/tools/unifiedOps.d.ts.map +1 -0
  577. package/dist/tools/unifiedOps.js +57 -0
  578. package/dist/tools/unifiedOps.js.map +1 -0
  579. package/dist/tools/webTools.d.ts +26 -0
  580. package/dist/tools/webTools.d.ts.map +1 -0
  581. package/dist/tools/webTools.js +227 -0
  582. package/dist/tools/webTools.js.map +1 -0
  583. package/dist/ui/PromptController.d.ts +193 -0
  584. package/dist/ui/PromptController.d.ts.map +1 -0
  585. package/dist/ui/PromptController.js +394 -0
  586. package/dist/ui/PromptController.js.map +1 -0
  587. package/dist/ui/UnifiedUIRenderer.d.ts +843 -0
  588. package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -0
  589. package/dist/ui/UnifiedUIRenderer.js +5711 -0
  590. package/dist/ui/UnifiedUIRenderer.js.map +1 -0
  591. package/dist/ui/animatedStatus.d.ts +140 -0
  592. package/dist/ui/animatedStatus.d.ts.map +1 -0
  593. package/dist/ui/animatedStatus.js +480 -0
  594. package/dist/ui/animatedStatus.js.map +1 -0
  595. package/dist/ui/animation/AnimationScheduler.d.ts +197 -0
  596. package/dist/ui/animation/AnimationScheduler.d.ts.map +1 -0
  597. package/dist/ui/animation/AnimationScheduler.js +440 -0
  598. package/dist/ui/animation/AnimationScheduler.js.map +1 -0
  599. package/dist/ui/codeHighlighter.d.ts +6 -0
  600. package/dist/ui/codeHighlighter.d.ts.map +1 -0
  601. package/dist/ui/codeHighlighter.js +855 -0
  602. package/dist/ui/codeHighlighter.js.map +1 -0
  603. package/dist/ui/designSystem.d.ts +26 -0
  604. package/dist/ui/designSystem.d.ts.map +1 -0
  605. package/dist/ui/designSystem.js +114 -0
  606. package/dist/ui/designSystem.js.map +1 -0
  607. package/dist/ui/errorFormatter.d.ts +64 -0
  608. package/dist/ui/errorFormatter.d.ts.map +1 -0
  609. package/dist/ui/errorFormatter.js +316 -0
  610. package/dist/ui/errorFormatter.js.map +1 -0
  611. package/dist/ui/globalWriteLock.d.ts +63 -0
  612. package/dist/ui/globalWriteLock.d.ts.map +1 -0
  613. package/dist/ui/globalWriteLock.js +173 -0
  614. package/dist/ui/globalWriteLock.js.map +1 -0
  615. package/dist/ui/index.d.ts +32 -0
  616. package/dist/ui/index.d.ts.map +1 -0
  617. package/dist/ui/index.js +54 -0
  618. package/dist/ui/index.js.map +1 -0
  619. package/dist/ui/interrupts/InterruptManager.d.ts +157 -0
  620. package/dist/ui/interrupts/InterruptManager.d.ts.map +1 -0
  621. package/dist/ui/interrupts/InterruptManager.js +501 -0
  622. package/dist/ui/interrupts/InterruptManager.js.map +1 -0
  623. package/dist/ui/layout.d.ts +27 -0
  624. package/dist/ui/layout.d.ts.map +1 -0
  625. package/dist/ui/layout.js +184 -0
  626. package/dist/ui/layout.js.map +1 -0
  627. package/dist/ui/outputMode.d.ts +44 -0
  628. package/dist/ui/outputMode.d.ts.map +1 -0
  629. package/dist/ui/outputMode.js +123 -0
  630. package/dist/ui/outputMode.js.map +1 -0
  631. package/dist/ui/overlay/OverlayManager.d.ts +105 -0
  632. package/dist/ui/overlay/OverlayManager.d.ts.map +1 -0
  633. package/dist/ui/overlay/OverlayManager.js +304 -0
  634. package/dist/ui/overlay/OverlayManager.js.map +1 -0
  635. package/dist/ui/premiumComponents.d.ts +54 -0
  636. package/dist/ui/premiumComponents.d.ts.map +1 -0
  637. package/dist/ui/premiumComponents.js +241 -0
  638. package/dist/ui/premiumComponents.js.map +1 -0
  639. package/dist/ui/richText.d.ts +13 -0
  640. package/dist/ui/richText.d.ts.map +1 -0
  641. package/dist/ui/richText.js +444 -0
  642. package/dist/ui/richText.js.map +1 -0
  643. package/dist/ui/telemetry/ResponseTracker.d.ts +22 -0
  644. package/dist/ui/telemetry/ResponseTracker.d.ts.map +1 -0
  645. package/dist/ui/telemetry/ResponseTracker.js +60 -0
  646. package/dist/ui/telemetry/ResponseTracker.js.map +1 -0
  647. package/dist/ui/telemetry/UITelemetry.d.ts +181 -0
  648. package/dist/ui/telemetry/UITelemetry.d.ts.map +1 -0
  649. package/dist/ui/telemetry/UITelemetry.js +446 -0
  650. package/dist/ui/telemetry/UITelemetry.js.map +1 -0
  651. package/dist/ui/textHighlighter.d.ts +83 -0
  652. package/dist/ui/textHighlighter.d.ts.map +1 -0
  653. package/dist/ui/textHighlighter.js +267 -0
  654. package/dist/ui/textHighlighter.js.map +1 -0
  655. package/dist/ui/theme.d.ts +364 -0
  656. package/dist/ui/theme.d.ts.map +1 -0
  657. package/dist/ui/theme.js +471 -0
  658. package/dist/ui/theme.js.map +1 -0
  659. package/dist/ui/toolDisplay.d.ts +221 -0
  660. package/dist/ui/toolDisplay.d.ts.map +1 -0
  661. package/dist/ui/toolDisplay.js +1654 -0
  662. package/dist/ui/toolDisplay.js.map +1 -0
  663. package/dist/ui/uiConstants.d.ts +288 -0
  664. package/dist/ui/uiConstants.d.ts.map +1 -0
  665. package/dist/ui/uiConstants.js +472 -0
  666. package/dist/ui/uiConstants.js.map +1 -0
  667. package/dist/utils/askUserPrompt.d.ts +21 -0
  668. package/dist/utils/askUserPrompt.d.ts.map +1 -0
  669. package/dist/utils/askUserPrompt.js +87 -0
  670. package/dist/utils/askUserPrompt.js.map +1 -0
  671. package/dist/utils/asyncUtils.d.ts +95 -0
  672. package/dist/utils/asyncUtils.d.ts.map +1 -0
  673. package/dist/utils/asyncUtils.js +286 -0
  674. package/dist/utils/asyncUtils.js.map +1 -0
  675. package/dist/utils/debugLogger.d.ts +6 -0
  676. package/dist/utils/debugLogger.d.ts.map +1 -0
  677. package/dist/utils/debugLogger.js +39 -0
  678. package/dist/utils/debugLogger.js.map +1 -0
  679. package/dist/utils/errorUtils.d.ts +12 -0
  680. package/dist/utils/errorUtils.d.ts.map +1 -0
  681. package/dist/utils/errorUtils.js +83 -0
  682. package/dist/utils/errorUtils.js.map +1 -0
  683. package/dist/utils/frontmatter.d.ts +10 -0
  684. package/dist/utils/frontmatter.d.ts.map +1 -0
  685. package/dist/utils/frontmatter.js +78 -0
  686. package/dist/utils/frontmatter.js.map +1 -0
  687. package/dist/utils/packageInfo.d.ts +14 -0
  688. package/dist/utils/packageInfo.d.ts.map +1 -0
  689. package/dist/utils/packageInfo.js +45 -0
  690. package/dist/utils/packageInfo.js.map +1 -0
  691. package/dist/utils/planFormatter.d.ts +34 -0
  692. package/dist/utils/planFormatter.d.ts.map +1 -0
  693. package/dist/utils/planFormatter.js +141 -0
  694. package/dist/utils/planFormatter.js.map +1 -0
  695. package/dist/utils/securityUtils.d.ts +132 -0
  696. package/dist/utils/securityUtils.d.ts.map +1 -0
  697. package/dist/utils/securityUtils.js +324 -0
  698. package/dist/utils/securityUtils.js.map +1 -0
  699. package/dist/utils/statusReporter.d.ts +6 -0
  700. package/dist/utils/statusReporter.d.ts.map +1 -0
  701. package/dist/utils/statusReporter.js +26 -0
  702. package/dist/utils/statusReporter.js.map +1 -0
  703. package/dist/workspace.d.ts +8 -0
  704. package/dist/workspace.d.ts.map +1 -0
  705. package/dist/workspace.js +135 -0
  706. package/dist/workspace.js.map +1 -0
  707. package/dist/workspace.validator.d.ts +49 -0
  708. package/dist/workspace.validator.d.ts.map +1 -0
  709. package/dist/workspace.validator.js +215 -0
  710. package/dist/workspace.validator.js.map +1 -0
  711. package/package.json +121 -0
@@ -0,0 +1,793 @@
1
+ import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { homedir } from 'node:os';
4
+ import nodemailer from 'nodemailer';
5
+ import { getSecretValue, setSecretValue } from '../core/secretStore.js';
6
+ import { reportStatusError } from '../utils/statusReporter.js';
7
+ export class EmailTools {
8
+ configDir;
9
+ logDir;
10
+ constructor() {
11
+ this.configDir = join(homedir(), '.agi', 'email');
12
+ this.logDir = join(homedir(), '.agi', 'email-logs');
13
+ [this.configDir, this.logDir].forEach(dir => {
14
+ if (!existsSync(dir)) {
15
+ mkdirSync(dir, { recursive: true });
16
+ }
17
+ });
18
+ }
19
+ /**
20
+ * Save SMTP configuration to secret store
21
+ */
22
+ async saveConfig(config) {
23
+ try {
24
+ // Save basic SMTP credentials
25
+ setSecretValue('SMTP_USER', config.smtpUser);
26
+ setSecretValue('SMTP_PASSWORD', config.smtpPassword);
27
+ // Save optional configuration
28
+ if (config.smtpProvider) {
29
+ setSecretValue('SMTP_PROVIDER', config.smtpProvider);
30
+ }
31
+ if (config.smtpHost) {
32
+ setSecretValue('SMTP_HOST', config.smtpHost);
33
+ }
34
+ if (config.smtpPort) {
35
+ setSecretValue('SMTP_PORT', config.smtpPort.toString());
36
+ }
37
+ if (config.smtpFromName) {
38
+ setSecretValue('SMTP_FROM_NAME', config.smtpFromName);
39
+ }
40
+ // Also save as JSON file for easy retrieval
41
+ const configFile = join(this.configDir, 'smtp-config.json');
42
+ writeFileSync(configFile, JSON.stringify(config, null, 2));
43
+ return true;
44
+ }
45
+ catch (error) {
46
+ reportStatusError(error, 'Failed to save SMTP config');
47
+ return false;
48
+ }
49
+ }
50
+ /**
51
+ * Load SMTP configuration from secret store
52
+ */
53
+ async loadConfig() {
54
+ try {
55
+ const smtpUser = getSecretValue('SMTP_USER');
56
+ const smtpPassword = getSecretValue('SMTP_PASSWORD');
57
+ if (!smtpUser || !smtpPassword) {
58
+ return null;
59
+ }
60
+ const config = {
61
+ smtpUser,
62
+ smtpPassword,
63
+ smtpProvider: getSecretValue('SMTP_PROVIDER') || undefined,
64
+ smtpHost: getSecretValue('SMTP_HOST') || undefined,
65
+ smtpFromName: getSecretValue('SMTP_FROM_NAME') || undefined,
66
+ };
67
+ const port = getSecretValue('SMTP_PORT');
68
+ if (port) {
69
+ config.smtpPort = parseInt(port, 10);
70
+ }
71
+ return config;
72
+ }
73
+ catch (error) {
74
+ reportStatusError(error, 'Failed to load SMTP config');
75
+ return null;
76
+ }
77
+ }
78
+ /**
79
+ * Test SMTP connection with current configuration
80
+ */
81
+ async testConnection() {
82
+ const config = await this.loadConfig();
83
+ if (!config) {
84
+ return {
85
+ success: false,
86
+ error: 'No SMTP configuration found. Use --save-smtp first.',
87
+ timestamp: new Date().toISOString()
88
+ };
89
+ }
90
+ try {
91
+ const transporter = this.createTransporter(config);
92
+ await transporter.verify();
93
+ // Try to send a test email to self
94
+ const testInfo = await transporter.sendMail({
95
+ from: config.smtpFromName ? `"${config.smtpFromName}" <${config.smtpUser}>` : config.smtpUser,
96
+ to: config.smtpUser,
97
+ subject: 'AGI Email Tools - SMTP Test',
98
+ text: `Test email sent successfully at ${new Date().toISOString()}\n\nSMTP Configuration:\nUser: ${config.smtpUser}\nProvider: ${config.smtpProvider || 'custom'}\nHost: ${config.smtpHost || 'default'}\nPort: ${config.smtpPort || 'default'}`,
99
+ headers: {
100
+ 'X-AGI-Test': 'true',
101
+ 'X-Timestamp': new Date().toISOString()
102
+ }
103
+ });
104
+ return {
105
+ success: true,
106
+ messageId: testInfo.messageId,
107
+ response: testInfo.response,
108
+ timestamp: new Date().toISOString()
109
+ };
110
+ }
111
+ catch (error) {
112
+ return {
113
+ success: false,
114
+ error: error instanceof Error ? error.message : 'Unknown error',
115
+ timestamp: new Date().toISOString()
116
+ };
117
+ }
118
+ }
119
+ /**
120
+ * Send a single email
121
+ */
122
+ async sendEmail(message, fromName) {
123
+ const config = await this.loadConfig();
124
+ if (!config) {
125
+ return {
126
+ success: false,
127
+ error: 'No SMTP configuration found. Use --save-smtp first.',
128
+ timestamp: new Date().toISOString()
129
+ };
130
+ }
131
+ try {
132
+ const transporter = this.createTransporter(config);
133
+ const mailOptions = {
134
+ from: fromName || config.smtpFromName
135
+ ? `"${fromName || config.smtpFromName}" <${config.smtpUser}>`
136
+ : config.smtpUser,
137
+ to: Array.isArray(message.to) ? message.to.join(', ') : message.to,
138
+ subject: message.subject,
139
+ text: message.text,
140
+ html: message.html,
141
+ cc: message.cc ? (Array.isArray(message.cc) ? message.cc.join(', ') : message.cc) : undefined,
142
+ bcc: message.bcc ? (Array.isArray(message.bcc) ? message.bcc.join(', ') : message.bcc) : undefined,
143
+ replyTo: message.replyTo,
144
+ headers: {
145
+ 'X-AGI-Sent': 'true',
146
+ 'X-Timestamp': new Date().toISOString(),
147
+ ...message.headers
148
+ },
149
+ attachments: message.attachments
150
+ };
151
+ const info = await transporter.sendMail(mailOptions);
152
+ // Log the email
153
+ this.logEmail({
154
+ to: mailOptions.to,
155
+ subject: mailOptions.subject,
156
+ messageId: info.messageId,
157
+ success: true,
158
+ timestamp: new Date().toISOString()
159
+ });
160
+ return {
161
+ success: true,
162
+ messageId: info.messageId,
163
+ response: info.response,
164
+ timestamp: new Date().toISOString()
165
+ };
166
+ }
167
+ catch (error) {
168
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
169
+ const errorStr = String(error);
170
+ // Detect bounce conditions
171
+ let bounced = false;
172
+ let bounceReason = '';
173
+ let permanentFailure = false;
174
+ // Common bounce patterns
175
+ const bouncePatterns = [
176
+ { pattern: /recipient.*rejected|recipient.*not found/i, permanent: true, reason: 'Recipient not found' },
177
+ { pattern: /mailbox.*not found|mailbox.*does not exist/i, permanent: true, reason: 'Mailbox does not exist' },
178
+ { pattern: /user.*unknown|user.*not found/i, permanent: true, reason: 'Unknown user' },
179
+ { pattern: /address.*not found|address.*invalid/i, permanent: true, reason: 'Invalid address' },
180
+ { pattern: /domain.*not found|domain.*does not exist/i, permanent: true, reason: 'Domain not found' },
181
+ { pattern: /quota.*exceeded|mailbox.*full/i, permanent: false, reason: 'Mailbox full' },
182
+ { pattern: /spam.*rejected|spam.*detected/i, permanent: false, reason: 'Spam rejection' },
183
+ { pattern: /blacklisted|blocked|rejected.*policy/i, permanent: false, reason: 'Blocked by policy' },
184
+ { pattern: /relay.*denied|relay.*not permitted/i, permanent: false, reason: 'Relay denied' },
185
+ { pattern: /550|551|552|553|554/i, permanent: true, reason: 'SMTP permanent failure' },
186
+ { pattern: /450|451/i, permanent: false, reason: 'SMTP temporary failure' },
187
+ { pattern: /bounce|bounced/i, permanent: true, reason: 'Bounced email' }
188
+ ];
189
+ for (const pattern of bouncePatterns) {
190
+ if (pattern.pattern.test(errorMessage) || pattern.pattern.test(errorStr)) {
191
+ bounced = true;
192
+ bounceReason = pattern.reason;
193
+ permanentFailure = pattern.permanent;
194
+ break;
195
+ }
196
+ }
197
+ const emailLog = {
198
+ to: Array.isArray(message.to) ? message.to.join(', ') : message.to,
199
+ subject: message.subject,
200
+ error: errorMessage,
201
+ success: false,
202
+ bounced,
203
+ bounceReason: bounceReason || undefined,
204
+ permanentFailure,
205
+ timestamp: new Date().toISOString()
206
+ };
207
+ this.logEmail(emailLog);
208
+ // Save to non-working emails list if bounced
209
+ if (bounced) {
210
+ this.saveNonWorkingEmail({
211
+ email: Array.isArray(message.to) ? message.to[0] : message.to,
212
+ reason: bounceReason,
213
+ permanent: permanentFailure,
214
+ timestamp: new Date().toISOString(),
215
+ error: errorMessage
216
+ });
217
+ }
218
+ return {
219
+ success: false,
220
+ error: errorMessage,
221
+ bounced,
222
+ bounceReason: bounceReason || undefined,
223
+ permanentFailure,
224
+ timestamp: new Date().toISOString()
225
+ };
226
+ }
227
+ }
228
+ /**
229
+ * Send bulk emails with rate limiting
230
+ */
231
+ async sendBulkEmails(options) {
232
+ const results = [];
233
+ const config = await this.loadConfig();
234
+ if (!config) {
235
+ return options.emails.map(email => ({
236
+ to: email.to,
237
+ subject: email.subject,
238
+ success: false,
239
+ error: 'No SMTP configuration found',
240
+ timestamp: new Date().toISOString()
241
+ }));
242
+ }
243
+ const delay = options.delayBetweenEmails || 5000; // 5 seconds default
244
+ const maxRetries = options.maxRetries || 3;
245
+ const stopOnError = options.stopOnError !== false; // default true
246
+ for (let i = 0; i < options.emails.length; i++) {
247
+ const email = options.emails[i];
248
+ let retryCount = 0;
249
+ let success = false;
250
+ let result = null;
251
+ while (retryCount < maxRetries && !success) {
252
+ result = await this.sendEmail({
253
+ to: email.to,
254
+ subject: email.subject,
255
+ text: email.text
256
+ });
257
+ if (result.success) {
258
+ success = true;
259
+ }
260
+ else {
261
+ retryCount++;
262
+ if (retryCount < maxRetries) {
263
+ console.log(`Retrying ${email.to} (${retryCount}/${maxRetries})...`);
264
+ await new Promise(resolve => setTimeout(resolve, 2000)); // 2 second delay between retries
265
+ }
266
+ }
267
+ }
268
+ results.push({
269
+ to: email.to,
270
+ subject: email.subject,
271
+ ...(result || {
272
+ success: false,
273
+ error: 'Failed after all retries',
274
+ timestamp: new Date().toISOString()
275
+ })
276
+ });
277
+ // Stop if requested and this email failed
278
+ if (stopOnError && !success) {
279
+ console.log(`Stopping due to error on: ${email.to}`);
280
+ break;
281
+ }
282
+ // Delay between emails (except after the last one)
283
+ if (i < options.emails.length - 1) {
284
+ await new Promise(resolve => setTimeout(resolve, delay));
285
+ }
286
+ }
287
+ return results;
288
+ }
289
+ /**
290
+ * Get email sending statistics
291
+ */
292
+ getStats() {
293
+ const logFile = join(this.logDir, 'email-sent.json');
294
+ if (!existsSync(logFile)) {
295
+ return { total: 0, successful: 0, failed: 0, lastSent: null };
296
+ }
297
+ try {
298
+ const logs = JSON.parse(readFileSync(logFile, 'utf-8'));
299
+ const successful = logs.filter((log) => log.success).length;
300
+ const failed = logs.filter((log) => !log.success).length;
301
+ const lastSent = logs.length > 0 ? logs[logs.length - 1].timestamp : null;
302
+ return {
303
+ total: logs.length,
304
+ successful,
305
+ failed,
306
+ lastSent
307
+ };
308
+ }
309
+ catch {
310
+ return { total: 0, successful: 0, failed: 0, lastSent: null };
311
+ }
312
+ }
313
+ /**
314
+ * List all sent emails
315
+ */
316
+ listSent(limit = 50) {
317
+ const logFile = join(this.logDir, 'email-sent.json');
318
+ if (!existsSync(logFile)) {
319
+ return [];
320
+ }
321
+ try {
322
+ const logs = JSON.parse(readFileSync(logFile, 'utf-8'));
323
+ return logs.slice(-limit).reverse(); // Most recent first
324
+ }
325
+ catch {
326
+ return [];
327
+ }
328
+ }
329
+ /**
330
+ * Clear all logs
331
+ */
332
+ clearLogs() {
333
+ const logFile = join(this.logDir, 'email-sent.json');
334
+ if (existsSync(logFile)) {
335
+ writeFileSync(logFile, '[]');
336
+ }
337
+ }
338
+ /**
339
+ * Create transporter from configuration
340
+ */
341
+ createTransporter(config) {
342
+ // For common providers, use simplified configuration
343
+ if (config.smtpProvider) {
344
+ switch (config.smtpProvider.toLowerCase()) {
345
+ case 'gmail':
346
+ return nodemailer.createTransport({
347
+ service: 'gmail',
348
+ auth: {
349
+ user: config.smtpUser,
350
+ pass: config.smtpPassword
351
+ }
352
+ });
353
+ case 'outlook':
354
+ case 'office365':
355
+ return nodemailer.createTransport({
356
+ host: 'smtp.office365.com',
357
+ port: 587,
358
+ secure: false,
359
+ auth: {
360
+ user: config.smtpUser,
361
+ pass: config.smtpPassword
362
+ }
363
+ });
364
+ case 'yahoo':
365
+ return nodemailer.createTransport({
366
+ host: 'smtp.mail.yahoo.com',
367
+ port: 587,
368
+ secure: false,
369
+ auth: {
370
+ user: config.smtpUser,
371
+ pass: config.smtpPassword
372
+ }
373
+ });
374
+ }
375
+ }
376
+ // Custom SMTP configuration
377
+ return nodemailer.createTransport({
378
+ host: config.smtpHost || 'smtp.gmail.com',
379
+ port: config.smtpPort || 587,
380
+ secure: config.useSsl || false,
381
+ requireTLS: config.useTls !== false, // default true
382
+ auth: {
383
+ user: config.smtpUser,
384
+ pass: config.smtpPassword
385
+ }
386
+ });
387
+ }
388
+ /**
389
+ * Log email sending activity
390
+ */
391
+ logEmail(log) {
392
+ const logFile = join(this.logDir, 'email-sent.json');
393
+ let logs = [];
394
+ if (existsSync(logFile)) {
395
+ try {
396
+ logs = JSON.parse(readFileSync(logFile, 'utf-8'));
397
+ }
398
+ catch {
399
+ logs = [];
400
+ }
401
+ }
402
+ logs.push(log);
403
+ writeFileSync(logFile, JSON.stringify(logs, null, 2));
404
+ }
405
+ /**
406
+ * Save a non-working email address to the bounce list
407
+ */
408
+ saveNonWorkingEmail(bouncedEmail) {
409
+ const bounceFile = join(this.logDir, 'non-working-emails.json');
410
+ let bouncedEmails = [];
411
+ if (existsSync(bounceFile)) {
412
+ try {
413
+ bouncedEmails = JSON.parse(readFileSync(bounceFile, 'utf-8'));
414
+ }
415
+ catch {
416
+ bouncedEmails = [];
417
+ }
418
+ }
419
+ // Check if this email already exists in the bounce list
420
+ const existingIndex = bouncedEmails.findIndex(e => e.email === bouncedEmail.email);
421
+ if (existingIndex >= 0) {
422
+ // Update existing entry
423
+ bouncedEmails[existingIndex] = {
424
+ ...bouncedEmails[existingIndex],
425
+ ...bouncedEmail,
426
+ bounceCount: (bouncedEmails[existingIndex].bounceCount || 1) + 1,
427
+ lastBounce: bouncedEmail.timestamp
428
+ };
429
+ }
430
+ else {
431
+ // Add new entry
432
+ bouncedEmails.push({
433
+ ...bouncedEmail,
434
+ bounceCount: 1,
435
+ firstBounce: bouncedEmail.timestamp,
436
+ lastBounce: bouncedEmail.timestamp
437
+ });
438
+ }
439
+ writeFileSync(bounceFile, JSON.stringify(bouncedEmails, null, 2));
440
+ // Also save to a separate permanent failures file if it's a permanent failure
441
+ if (bouncedEmail.permanent) {
442
+ const permanentFile = join(this.logDir, 'permanent-failures.json');
443
+ let permanentFailures = [];
444
+ if (existsSync(permanentFile)) {
445
+ try {
446
+ permanentFailures = JSON.parse(readFileSync(permanentFile, 'utf-8'));
447
+ }
448
+ catch {
449
+ permanentFailures = [];
450
+ }
451
+ }
452
+ // Check if already in permanent failures
453
+ if (!permanentFailures.some(e => e.email === bouncedEmail.email)) {
454
+ permanentFailures.push({
455
+ email: bouncedEmail.email,
456
+ reason: bouncedEmail.reason,
457
+ timestamp: bouncedEmail.timestamp,
458
+ error: bouncedEmail.error
459
+ });
460
+ writeFileSync(permanentFile, JSON.stringify(permanentFailures, null, 2));
461
+ }
462
+ }
463
+ }
464
+ /**
465
+ * Get list of non-working emails
466
+ */
467
+ getNonWorkingEmails() {
468
+ const bounceFile = join(this.logDir, 'non-working-emails.json');
469
+ if (!existsSync(bounceFile)) {
470
+ return [];
471
+ }
472
+ try {
473
+ return JSON.parse(readFileSync(bounceFile, 'utf-8'));
474
+ }
475
+ catch {
476
+ return [];
477
+ }
478
+ }
479
+ /**
480
+ * Get list of permanent failures
481
+ */
482
+ getPermanentFailures() {
483
+ const permanentFile = join(this.logDir, 'permanent-failures.json');
484
+ if (!existsSync(permanentFile)) {
485
+ return [];
486
+ }
487
+ try {
488
+ return JSON.parse(readFileSync(permanentFile, 'utf-8'));
489
+ }
490
+ catch {
491
+ return [];
492
+ }
493
+ }
494
+ /**
495
+ * Check if an email address is known to be non-working
496
+ */
497
+ isNonWorkingEmail(email) {
498
+ const nonWorking = this.getNonWorkingEmails();
499
+ return nonWorking.some(e => e.email.toLowerCase() === email.toLowerCase());
500
+ }
501
+ /**
502
+ * Clear non-working emails list
503
+ */
504
+ clearNonWorkingEmails() {
505
+ const bounceFile = join(this.logDir, 'non-working-emails.json');
506
+ const permanentFile = join(this.logDir, 'permanent-failures.json');
507
+ if (existsSync(bounceFile)) {
508
+ writeFileSync(bounceFile, '[]');
509
+ }
510
+ if (existsSync(permanentFile)) {
511
+ writeFileSync(permanentFile, '[]');
512
+ }
513
+ }
514
+ }
515
+ // CLI helper functions
516
+ export async function handleEmailCommand(args) {
517
+ const tools = new EmailTools();
518
+ if (args.length === 0 || args[0] === 'help') {
519
+ printEmailHelp();
520
+ return;
521
+ }
522
+ const command = args[0];
523
+ const remainingArgs = args.slice(1);
524
+ switch (command) {
525
+ case 'save':
526
+ await handleSaveCommand(remainingArgs);
527
+ break;
528
+ case 'test':
529
+ await handleTestCommand();
530
+ break;
531
+ case 'stats': {
532
+ const stats = tools.getStats();
533
+ console.log('šŸ“Š Email Statistics:');
534
+ console.log(`Total sent: ${stats.total}`);
535
+ console.log(`Successful: ${stats.successful}`);
536
+ console.log(`Failed: ${stats.failed}`);
537
+ if (stats.lastSent) {
538
+ console.log(`Last sent: ${new Date(stats.lastSent).toLocaleString()}`);
539
+ }
540
+ break;
541
+ }
542
+ case 'list': {
543
+ const limit = parseInt(remainingArgs[0], 10) || 10;
544
+ const emails = tools.listSent(limit);
545
+ console.log(`šŸ“§ Last ${limit} emails:`);
546
+ emails.forEach((email, i) => {
547
+ const status = email.success ? 'āœ…' : 'āŒ';
548
+ console.log(`${i + 1}. ${status} ${email.to} - "${email.subject}" (${new Date(email.timestamp).toLocaleString()})`);
549
+ });
550
+ break;
551
+ }
552
+ case 'clear':
553
+ tools.clearLogs();
554
+ console.log('āœ… Email logs cleared.');
555
+ break;
556
+ case 'bounces':
557
+ await handleBouncesCommand(remainingArgs);
558
+ break;
559
+ case 'check':
560
+ await handleCheckCommand(remainingArgs);
561
+ break;
562
+ default:
563
+ console.log(`Unknown command: ${command}`);
564
+ printEmailHelp();
565
+ }
566
+ }
567
+ async function handleSaveCommand(args) {
568
+ const tools = new EmailTools();
569
+ // Interactive mode
570
+ if (args.length === 0) {
571
+ console.log('Interactive SMTP configuration setup:');
572
+ const readline = await import('node:readline/promises');
573
+ const rl = readline.createInterface({
574
+ input: process.stdin,
575
+ output: process.stdout
576
+ });
577
+ try {
578
+ const smtpUser = await rl.question('SMTP Username/Email: ');
579
+ const smtpPassword = await rl.question('SMTP Password/App Password: ');
580
+ const smtpProvider = await rl.question('Provider (gmail, outlook, yahoo, or custom): ');
581
+ let smtpHost = '';
582
+ let smtpPort = '';
583
+ let smtpFromName = '';
584
+ if (smtpProvider.toLowerCase() === 'custom') {
585
+ smtpHost = await rl.question('SMTP Host (e.g., smtp.gmail.com): ');
586
+ smtpPort = await rl.question('SMTP Port (e.g., 587): ');
587
+ }
588
+ smtpFromName = await rl.question('From Name (optional): ');
589
+ const config = {
590
+ smtpUser,
591
+ smtpPassword,
592
+ smtpProvider: smtpProvider.toLowerCase() === 'custom' ? undefined : smtpProvider,
593
+ smtpHost: smtpHost || undefined,
594
+ smtpPort: smtpPort ? parseInt(smtpPort, 10) : undefined,
595
+ smtpFromName: smtpFromName || undefined
596
+ };
597
+ const success = await tools.saveConfig(config);
598
+ if (success) {
599
+ console.log('āœ… SMTP configuration saved successfully!');
600
+ }
601
+ else {
602
+ console.log('āŒ Failed to save SMTP configuration');
603
+ }
604
+ }
605
+ finally {
606
+ rl.close();
607
+ }
608
+ }
609
+ else {
610
+ // Command line mode
611
+ console.log('Use interactive mode for security. Run without arguments.');
612
+ console.log('Example: agi email save');
613
+ }
614
+ }
615
+ async function handleTestCommand() {
616
+ const tools = new EmailTools();
617
+ console.log('Testing SMTP connection...');
618
+ const result = await tools.testConnection();
619
+ if (result.success) {
620
+ console.log('āœ… SMTP connection successful!');
621
+ console.log(`Message ID: ${result.messageId}`);
622
+ console.log(`Response: ${result.response}`);
623
+ }
624
+ else {
625
+ console.log('āŒ SMTP connection failed');
626
+ console.log(`Error: ${result.error}`);
627
+ }
628
+ }
629
+ async function handleBouncesCommand(args) {
630
+ const tools = new EmailTools();
631
+ const subCommand = args[0]?.toLowerCase() || 'list';
632
+ switch (subCommand) {
633
+ case 'list':
634
+ const nonWorking = tools.getNonWorkingEmails();
635
+ const permanent = tools.getPermanentFailures();
636
+ console.log('šŸ“¬ Non-Working Email Addresses:');
637
+ console.log('─'.repeat(80));
638
+ if (nonWorking.length === 0) {
639
+ console.log('No non-working emails recorded.');
640
+ }
641
+ else {
642
+ nonWorking.forEach((email, index) => {
643
+ const status = email.permanent ? 'šŸ”“ PERMANENT' : '🟔 TEMPORARY';
644
+ console.log(`${index + 1}. ${email.email}`);
645
+ console.log(` Reason: ${email.reason}`);
646
+ console.log(` Status: ${status}`);
647
+ console.log(` Bounces: ${email.bounceCount}`);
648
+ console.log(` First: ${new Date(email.firstBounce).toLocaleString()}`);
649
+ console.log(` Last: ${new Date(email.lastBounce).toLocaleString()}`);
650
+ if (email.error) {
651
+ console.log(` Error: ${email.error.substring(0, 100)}${email.error.length > 100 ? '...' : ''}`);
652
+ }
653
+ console.log('─'.repeat(80));
654
+ });
655
+ }
656
+ console.log('\nšŸ”“ Permanent Failures:');
657
+ console.log('─'.repeat(80));
658
+ if (permanent.length === 0) {
659
+ console.log('No permanent failures recorded.');
660
+ }
661
+ else {
662
+ permanent.forEach((email, index) => {
663
+ console.log(`${index + 1}. ${email.email}`);
664
+ console.log(` Reason: ${email.reason}`);
665
+ console.log(` Date: ${new Date(email.timestamp).toLocaleString()}`);
666
+ if (email.error) {
667
+ console.log(` Error: ${email.error.substring(0, 80)}${email.error.length > 80 ? '...' : ''}`);
668
+ }
669
+ console.log('─'.repeat(80));
670
+ });
671
+ }
672
+ break;
673
+ case 'clear':
674
+ const readline = await import('node:readline/promises');
675
+ const rl = readline.createInterface({
676
+ input: process.stdin,
677
+ output: process.stdout
678
+ });
679
+ try {
680
+ const answer = await rl.question('Are you sure you want to clear all bounce records? (yes/no): ');
681
+ if (answer.toLowerCase() === 'yes') {
682
+ tools.clearNonWorkingEmails();
683
+ console.log('āœ… Bounce records cleared.');
684
+ }
685
+ else {
686
+ console.log('Operation cancelled.');
687
+ }
688
+ }
689
+ finally {
690
+ rl.close();
691
+ }
692
+ break;
693
+ case 'stats':
694
+ const allNonWorking = tools.getNonWorkingEmails();
695
+ const permanentFailures = tools.getPermanentFailures();
696
+ const permanentCount = allNonWorking.filter(e => e.permanent).length;
697
+ const temporaryCount = allNonWorking.filter(e => !e.permanent).length;
698
+ const totalBounces = allNonWorking.reduce((sum, e) => sum + e.bounceCount, 0);
699
+ console.log('šŸ“Š Bounce Statistics:');
700
+ console.log(`Total non-working emails: ${allNonWorking.length}`);
701
+ console.log(`Permanent failures: ${permanentCount}`);
702
+ console.log(`Temporary failures: ${temporaryCount}`);
703
+ console.log(`Total bounce events: ${totalBounces}`);
704
+ console.log(`Unique permanent failures: ${permanentFailures.length}`);
705
+ if (allNonWorking.length > 0) {
706
+ console.log('\nšŸ“ˆ Most Frequent Failures:');
707
+ const sorted = [...allNonWorking].sort((a, b) => b.bounceCount - a.bounceCount).slice(0, 5);
708
+ sorted.forEach((email, index) => {
709
+ console.log(`${index + 1}. ${email.email} - ${email.bounceCount} bounce${email.bounceCount !== 1 ? 's' : ''}`);
710
+ });
711
+ }
712
+ break;
713
+ default:
714
+ console.log('Usage: agi email bounces [list|clear|stats]');
715
+ console.log(' list - Show all non-working email addresses');
716
+ console.log(' clear - Clear all bounce records (requires confirmation)');
717
+ console.log(' stats - Show bounce statistics');
718
+ }
719
+ }
720
+ async function handleCheckCommand(args) {
721
+ const tools = new EmailTools();
722
+ if (args.length === 0) {
723
+ console.log('Usage: agi email check <email-address>');
724
+ console.log('Example: agi email check user@example.com');
725
+ return;
726
+ }
727
+ const email = args[0];
728
+ const isNonWorking = tools.isNonWorkingEmail(email);
729
+ console.log(`Checking email: ${email}`);
730
+ if (isNonWorking) {
731
+ const nonWorking = tools.getNonWorkingEmails();
732
+ const emailRecord = nonWorking.find(e => e.email.toLowerCase() === email.toLowerCase());
733
+ if (emailRecord) {
734
+ console.log('āŒ This email address is marked as non-working.');
735
+ console.log(`Reason: ${emailRecord.reason}`);
736
+ console.log(`Status: ${emailRecord.permanent ? 'PERMANENT FAILURE' : 'TEMPORARY FAILURE'}`);
737
+ console.log(`Bounce count: ${emailRecord.bounceCount}`);
738
+ console.log(`First bounce: ${new Date(emailRecord.firstBounce).toLocaleString()}`);
739
+ console.log(`Last bounce: ${new Date(emailRecord.lastBounce).toLocaleString()}`);
740
+ if (emailRecord.permanent) {
741
+ console.log('āš ļø Warning: This is a permanent failure. Sending to this address will likely fail.');
742
+ }
743
+ }
744
+ }
745
+ else {
746
+ console.log('āœ… This email address is not marked as non-working.');
747
+ console.log('(No bounce records found for this address)');
748
+ }
749
+ }
750
+ function printEmailHelp() {
751
+ console.log(`
752
+ AGI Email Tools - Send emails using SMTP
753
+
754
+ Commands:
755
+ save Configure SMTP settings interactively
756
+ test Test SMTP connection
757
+ send <to> "<subject>" "<text>" [--from-name "Name"]
758
+ Send a single email
759
+ bulk <emails-file.json> [--delay 5000] [--max-retries 3] [--stop-on-error]
760
+ Send bulk emails from JSON file
761
+ stats Show email sending statistics
762
+ list [limit] List recently sent emails (default: 10)
763
+ clear Clear all email logs (confirmation required)
764
+ bounces [list|clear|stats] Manage bounce records
765
+ check <email> Check if an email address is marked as non-working
766
+ help Show this help message
767
+
768
+ Examples:
769
+ agi email save
770
+ agi email test
771
+ agi email send "user@example.com" "Test Subject" "Email body text"
772
+ agi email send "user@example.com" "Test" "Body" --from-name "AGI System"
773
+ agi email bulk emails.json --delay 10000
774
+ agi email list 20
775
+ agi email bounces list
776
+ agi email bounces stats
777
+ agi email check user@example.com
778
+
779
+ SMTP Configuration:
780
+ The 'save' command will store your SMTP credentials securely in the system keychain.
781
+ Supported providers: Gmail, Outlook/Office365, Yahoo, or custom SMTP servers.
782
+
783
+ For Gmail, you need an "App Password" if 2-factor authentication is enabled.
784
+ Generate at: https://myaccount.google.com/apppasswords
785
+
786
+ Bounce Detection:
787
+ The system automatically detects bounced emails and saves them to a non-working list.
788
+ Permanent failures (like invalid addresses) are marked and can be checked before sending.
789
+ Use 'agi email bounces list' to see all non-working addresses.
790
+ Use 'agi email check <address>' to verify if an address is known to bounce.
791
+ `);
792
+ }
793
+ //# sourceMappingURL=emailTools.js.map