@agenticmail/enterprise 0.5.366 → 0.5.367

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.
@@ -2016,63 +2016,6 @@ ${identity.personality.slice(0, 800)}` : "";
2016
2016
  if (managerEmail && emailConfig) {
2017
2017
  console.log(`[welcome] Sending introduction email to ${managerEmail}...`);
2018
2018
  try {
2019
- const { createEmailProvider } = await import("./agenticmail-L76WQBSU.js");
2020
- const providerType = emailConfig.provider || (emailConfig.oauthProvider === "google" ? "google" : emailConfig.oauthProvider === "microsoft" ? "microsoft" : "imap");
2021
- const emailProvider = createEmailProvider(providerType);
2022
- let currentAccessToken = emailConfig.oauthAccessToken;
2023
- const refreshTokenFn = emailConfig.oauthRefreshToken ? async () => {
2024
- const clientId = emailConfig.oauthClientId;
2025
- const clientSecret = emailConfig.oauthClientSecret;
2026
- const refreshToken = emailConfig.oauthRefreshToken;
2027
- const tokenUrl = providerType === "google" ? "https://oauth2.googleapis.com/token" : "https://login.microsoftonline.com/common/oauth2/v2.0/token";
2028
- const res = await fetch(tokenUrl, {
2029
- method: "POST",
2030
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
2031
- body: new URLSearchParams({
2032
- client_id: clientId,
2033
- client_secret: clientSecret,
2034
- refresh_token: refreshToken,
2035
- grant_type: "refresh_token"
2036
- })
2037
- });
2038
- const data = await res.json();
2039
- if (data.access_token) {
2040
- currentAccessToken = data.access_token;
2041
- emailConfig.oauthAccessToken = data.access_token;
2042
- if (data.expires_in) emailConfig.oauthTokenExpiry = new Date(Date.now() + data.expires_in * 1e3).toISOString();
2043
- lifecycle.saveAgent(AGENT_ID).catch(() => {
2044
- });
2045
- return data.access_token;
2046
- }
2047
- throw new Error(`Token refresh failed: ${JSON.stringify(data)}`);
2048
- } : void 0;
2049
- if (refreshTokenFn) {
2050
- try {
2051
- currentAccessToken = await refreshTokenFn();
2052
- console.log("[welcome] Refreshed OAuth token");
2053
- } catch (refreshErr) {
2054
- console.error(`[welcome] Token refresh failed: ${refreshErr.message}`);
2055
- }
2056
- }
2057
- await emailProvider.connect({
2058
- agentId,
2059
- name: config.displayName || config.name,
2060
- email: emailConfig.email || config.email?.address || "",
2061
- orgId,
2062
- accessToken: currentAccessToken,
2063
- refreshToken: refreshTokenFn,
2064
- provider: providerType,
2065
- // IMAP/SMTP fields
2066
- imapHost: emailConfig.imapHost,
2067
- imapPort: emailConfig.imapPort,
2068
- smtpHost: emailConfig.smtpHost,
2069
- smtpPort: emailConfig.smtpPort,
2070
- password: emailConfig.password
2071
- });
2072
- const agentName = config.displayName || config.name;
2073
- const role = config.identity?.role || "AI Agent";
2074
- const identity = config.identity || {};
2075
- const agentEmailAddr = config.email?.address || emailConfig?.email || "";
2076
2019
  let alreadySent = false;
2077
2020
  try {
2078
2021
  const sentCheck = await engineDb.query(
@@ -2092,6 +2035,63 @@ ${identity.personality.slice(0, 800)}` : "";
2092
2035
  if (alreadySent) {
2093
2036
  console.log("[welcome] Welcome email already sent, skipping");
2094
2037
  } else {
2038
+ const { createEmailProvider } = await import("./agenticmail-L76WQBSU.js");
2039
+ const providerType = emailConfig.provider || (emailConfig.oauthProvider === "google" ? "google" : emailConfig.oauthProvider === "microsoft" ? "microsoft" : "imap");
2040
+ const emailProvider = createEmailProvider(providerType);
2041
+ let currentAccessToken = emailConfig.oauthAccessToken;
2042
+ const refreshTokenFn = emailConfig.oauthRefreshToken ? async () => {
2043
+ const clientId = emailConfig.oauthClientId;
2044
+ const clientSecret = emailConfig.oauthClientSecret;
2045
+ const refreshToken = emailConfig.oauthRefreshToken;
2046
+ const tokenUrl = providerType === "google" ? "https://oauth2.googleapis.com/token" : "https://login.microsoftonline.com/common/oauth2/v2.0/token";
2047
+ const res = await fetch(tokenUrl, {
2048
+ method: "POST",
2049
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
2050
+ body: new URLSearchParams({
2051
+ client_id: clientId,
2052
+ client_secret: clientSecret,
2053
+ refresh_token: refreshToken,
2054
+ grant_type: "refresh_token"
2055
+ })
2056
+ });
2057
+ const data = await res.json();
2058
+ if (data.access_token) {
2059
+ currentAccessToken = data.access_token;
2060
+ emailConfig.oauthAccessToken = data.access_token;
2061
+ if (data.expires_in) emailConfig.oauthTokenExpiry = new Date(Date.now() + data.expires_in * 1e3).toISOString();
2062
+ lifecycle.saveAgent(AGENT_ID).catch(() => {
2063
+ });
2064
+ return data.access_token;
2065
+ }
2066
+ throw new Error(`Token refresh failed: ${JSON.stringify(data)}`);
2067
+ } : void 0;
2068
+ if (refreshTokenFn) {
2069
+ try {
2070
+ currentAccessToken = await refreshTokenFn();
2071
+ console.log("[welcome] Refreshed OAuth token");
2072
+ } catch (refreshErr) {
2073
+ console.error(`[welcome] Token refresh failed: ${refreshErr.message}`);
2074
+ }
2075
+ }
2076
+ await emailProvider.connect({
2077
+ agentId,
2078
+ name: config.displayName || config.name,
2079
+ email: emailConfig.email || config.email?.address || "",
2080
+ orgId,
2081
+ accessToken: currentAccessToken,
2082
+ refreshToken: refreshTokenFn,
2083
+ provider: providerType,
2084
+ // IMAP/SMTP fields
2085
+ imapHost: emailConfig.imapHost,
2086
+ imapPort: emailConfig.imapPort,
2087
+ smtpHost: emailConfig.smtpHost,
2088
+ smtpPort: emailConfig.smtpPort,
2089
+ password: emailConfig.password
2090
+ });
2091
+ const agentName = config.displayName || config.name;
2092
+ const role = config.identity?.role || "AI Agent";
2093
+ const identity = config.identity || {};
2094
+ const agentEmailAddr = config.email?.address || emailConfig?.email || "";
2095
2095
  console.log(`[welcome] Generating AI welcome email for ${managerEmail}...`);
2096
2096
  const welcomeSession = await runtime.spawnSession({
2097
2097
  agentId,
@@ -2124,6 +2124,10 @@ Available tools: ${providerType === "imap" ? "email_send (to, subject, body)" :
2124
2124
  } catch {
2125
2125
  }
2126
2126
  }
2127
+ try {
2128
+ await emailProvider.disconnect?.();
2129
+ } catch {
2130
+ }
2127
2131
  }
2128
2132
  } catch (err) {
2129
2133
  console.warn(`[welcome] Failed to send welcome email: ${err.message} \u2014 will not retry`);
package/dist/cli.js CHANGED
@@ -60,7 +60,7 @@ Skill Development:
60
60
  import("./cli-serve-YTFZUDRS.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
61
61
  break;
62
62
  case "agent":
63
- import("./cli-agent-TMZDB7ZQ.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
63
+ import("./cli-agent-JYQSLTKP.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
64
64
  break;
65
65
  case "setup":
66
66
  default:
@@ -0,0 +1 @@
1
+ 2026-03-05 21:07:47: [TaskPoller] Failed to deliver recovery response: The "path" argument must be of type string. Received undefined
@@ -6,3 +6,4 @@
6
6
  2026-03-05 06:30:44: ERROR: DATABASE_URL is required
7
7
  2026-03-05 06:30:59: ERROR: DATABASE_URL is required
8
8
  2026-03-05 06:31:11: Fatal error: current transaction is aborted, commands ignored until end of transaction block
9
+ 2026-03-05 21:05:33: [TaskPoller] spawnForTask error: No API key configured for provider: undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/enterprise",
3
- "version": "0.5.366",
3
+ "version": "0.5.367",
4
4
  "description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
5
5
  "type": "module",
6
6
  "bin": {