@agenticmail/openclaw 0.5.49 → 0.5.51

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.
package/dist/index.cjs CHANGED
@@ -3079,21 +3079,20 @@ function activate(api) {
3079
3079
  api.registerService(createMailMonitorService(ctx));
3080
3080
  }
3081
3081
  {
3082
- const gatewayPort = process.env.OPENCLAW_PORT || process.env.PORT || "3000";
3083
- const agentApiKey = ctx.config.apiKey;
3084
- const sseUrl = `${ctx.config.apiUrl}/api/agenticmail/events`;
3085
- let sseRetryMs = 5e3;
3086
- let sseController = null;
3087
- const startMainWatcher = () => {
3082
+ let startMainWatcher2 = function() {
3088
3083
  if (sseController) return;
3089
3084
  sseController = new AbortController();
3085
+ const ctrl = sseController;
3090
3086
  (async () => {
3091
3087
  try {
3092
3088
  const res = await fetch(sseUrl, {
3093
3089
  headers: { "Authorization": `Bearer ${agentApiKey}`, "Accept": "text/event-stream" },
3094
- signal: sseController.signal
3090
+ signal: ctrl.signal
3095
3091
  });
3096
- if (!res.ok || !res.body) return;
3092
+ if (!res.ok || !res.body) {
3093
+ scheduleReconnect();
3094
+ return;
3095
+ }
3097
3096
  sseRetryMs = 5e3;
3098
3097
  const reader = res.body.getReader();
3099
3098
  const decoder = new TextDecoder();
@@ -3108,37 +3107,31 @@ function activate(api) {
3108
3107
  const frame = buffer.slice(0, boundary);
3109
3108
  buffer = buffer.slice(boundary + 2);
3110
3109
  for (const line of frame.split("\n")) {
3111
- if (line.startsWith("data: ")) {
3112
- try {
3113
- const event = JSON.parse(line.slice(6));
3114
- if (event.type === "new" && event.uid) {
3115
- const from = event.from ?? "unknown";
3116
- const subject = event.subject ?? "(no subject)";
3117
- const wakeText = `New email received from ${from}: "${subject}". Read it with agenticmail_read(uid=${event.uid}), assess urgency, and decide: if urgent or time-sensitive, notify the user now. Otherwise, note it in memory and batch-notify later.`;
3118
- const hooksToken = process.env.OPENCLAW_HOOKS_TOKEN;
3119
- if (hooksToken) {
3120
- try {
3121
- const wakeUrl = `http://127.0.0.1:${gatewayPort}/hooks/wake`;
3122
- const resp = await fetch(wakeUrl, {
3123
- method: "POST",
3124
- headers: {
3125
- "Content-Type": "application/json",
3126
- "Authorization": `Bearer ${hooksToken}`
3127
- },
3128
- body: JSON.stringify({ text: wakeText, mode: "now" }),
3129
- signal: AbortSignal.timeout(5e3)
3130
- });
3131
- if (!resp.ok) {
3132
- const errBody = await resp.text().catch(() => "");
3133
- console.warn(`[agenticmail] email wake failed (${resp.status}): ${errBody}`);
3134
- }
3135
- } catch {
3110
+ if (!line.startsWith("data: ")) continue;
3111
+ try {
3112
+ const event = JSON.parse(line.slice(6));
3113
+ if (event.type === "new" && event.uid) {
3114
+ const from = event.from ?? "unknown";
3115
+ const subject = event.subject ?? "(no subject)";
3116
+ const wakeText = `New email received from ${from}: "${subject}". Read it with agenticmail_read(uid=${event.uid}), assess urgency, and decide: if urgent or time-sensitive, notify the user now. Otherwise, note it in memory and batch-notify later.`;
3117
+ const hooksToken = process.env.OPENCLAW_HOOKS_TOKEN;
3118
+ const gwPort = process.env.OPENCLAW_PORT || "18789";
3119
+ if (hooksToken) {
3120
+ try {
3121
+ const resp = await fetch(`http://127.0.0.1:${gwPort}/hooks/wake`, {
3122
+ method: "POST",
3123
+ headers: { "Content-Type": "application/json", "Authorization": `Bearer ${hooksToken}` },
3124
+ body: JSON.stringify({ text: wakeText, mode: "now" }),
3125
+ signal: AbortSignal.timeout(5e3)
3126
+ });
3127
+ if (!resp.ok) {
3128
+ console.warn(`[agenticmail] email wake failed (${resp.status})`);
3136
3129
  }
3137
- } else {
3130
+ } catch {
3138
3131
  }
3139
3132
  }
3140
- } catch {
3141
3133
  }
3134
+ } catch {
3142
3135
  }
3143
3136
  }
3144
3137
  }
@@ -3150,14 +3143,21 @@ function activate(api) {
3150
3143
  }
3151
3144
  }
3152
3145
  } catch {
3153
- } finally {
3154
- sseController = null;
3155
- sseRetryMs = Math.min(sseRetryMs * 1.5, 6e4);
3156
- setTimeout(startMainWatcher, sseRetryMs);
3157
3146
  }
3147
+ scheduleReconnect();
3158
3148
  })();
3159
3149
  };
3160
- setTimeout(startMainWatcher, 3e3);
3150
+ var startMainWatcher = startMainWatcher2;
3151
+ const agentApiKey = ctx.config.apiKey;
3152
+ const sseUrl = `${ctx.config.apiUrl}/api/agenticmail/events`;
3153
+ let sseRetryMs = 5e3;
3154
+ let sseController = null;
3155
+ const scheduleReconnect = () => {
3156
+ sseController = null;
3157
+ sseRetryMs = Math.min(sseRetryMs * 1.5, 6e4);
3158
+ setTimeout(startMainWatcher2, sseRetryMs);
3159
+ };
3160
+ setTimeout(startMainWatcher2, 3e3);
3161
3161
  }
3162
3162
  if (api?.registerCommand) {
3163
3163
  api.registerCommand({
package/dist/index.js CHANGED
@@ -3043,21 +3043,20 @@ function activate(api) {
3043
3043
  api.registerService(createMailMonitorService(ctx));
3044
3044
  }
3045
3045
  {
3046
- const gatewayPort = process.env.OPENCLAW_PORT || process.env.PORT || "3000";
3047
- const agentApiKey = ctx.config.apiKey;
3048
- const sseUrl = `${ctx.config.apiUrl}/api/agenticmail/events`;
3049
- let sseRetryMs = 5e3;
3050
- let sseController = null;
3051
- const startMainWatcher = () => {
3046
+ let startMainWatcher2 = function() {
3052
3047
  if (sseController) return;
3053
3048
  sseController = new AbortController();
3049
+ const ctrl = sseController;
3054
3050
  (async () => {
3055
3051
  try {
3056
3052
  const res = await fetch(sseUrl, {
3057
3053
  headers: { "Authorization": `Bearer ${agentApiKey}`, "Accept": "text/event-stream" },
3058
- signal: sseController.signal
3054
+ signal: ctrl.signal
3059
3055
  });
3060
- if (!res.ok || !res.body) return;
3056
+ if (!res.ok || !res.body) {
3057
+ scheduleReconnect();
3058
+ return;
3059
+ }
3061
3060
  sseRetryMs = 5e3;
3062
3061
  const reader = res.body.getReader();
3063
3062
  const decoder = new TextDecoder();
@@ -3072,37 +3071,31 @@ function activate(api) {
3072
3071
  const frame = buffer.slice(0, boundary);
3073
3072
  buffer = buffer.slice(boundary + 2);
3074
3073
  for (const line of frame.split("\n")) {
3075
- if (line.startsWith("data: ")) {
3076
- try {
3077
- const event = JSON.parse(line.slice(6));
3078
- if (event.type === "new" && event.uid) {
3079
- const from = event.from ?? "unknown";
3080
- const subject = event.subject ?? "(no subject)";
3081
- const wakeText = `New email received from ${from}: "${subject}". Read it with agenticmail_read(uid=${event.uid}), assess urgency, and decide: if urgent or time-sensitive, notify the user now. Otherwise, note it in memory and batch-notify later.`;
3082
- const hooksToken = process.env.OPENCLAW_HOOKS_TOKEN;
3083
- if (hooksToken) {
3084
- try {
3085
- const wakeUrl = `http://127.0.0.1:${gatewayPort}/hooks/wake`;
3086
- const resp = await fetch(wakeUrl, {
3087
- method: "POST",
3088
- headers: {
3089
- "Content-Type": "application/json",
3090
- "Authorization": `Bearer ${hooksToken}`
3091
- },
3092
- body: JSON.stringify({ text: wakeText, mode: "now" }),
3093
- signal: AbortSignal.timeout(5e3)
3094
- });
3095
- if (!resp.ok) {
3096
- const errBody = await resp.text().catch(() => "");
3097
- console.warn(`[agenticmail] email wake failed (${resp.status}): ${errBody}`);
3098
- }
3099
- } catch {
3074
+ if (!line.startsWith("data: ")) continue;
3075
+ try {
3076
+ const event = JSON.parse(line.slice(6));
3077
+ if (event.type === "new" && event.uid) {
3078
+ const from = event.from ?? "unknown";
3079
+ const subject = event.subject ?? "(no subject)";
3080
+ const wakeText = `New email received from ${from}: "${subject}". Read it with agenticmail_read(uid=${event.uid}), assess urgency, and decide: if urgent or time-sensitive, notify the user now. Otherwise, note it in memory and batch-notify later.`;
3081
+ const hooksToken = process.env.OPENCLAW_HOOKS_TOKEN;
3082
+ const gwPort = process.env.OPENCLAW_PORT || "18789";
3083
+ if (hooksToken) {
3084
+ try {
3085
+ const resp = await fetch(`http://127.0.0.1:${gwPort}/hooks/wake`, {
3086
+ method: "POST",
3087
+ headers: { "Content-Type": "application/json", "Authorization": `Bearer ${hooksToken}` },
3088
+ body: JSON.stringify({ text: wakeText, mode: "now" }),
3089
+ signal: AbortSignal.timeout(5e3)
3090
+ });
3091
+ if (!resp.ok) {
3092
+ console.warn(`[agenticmail] email wake failed (${resp.status})`);
3100
3093
  }
3101
- } else {
3094
+ } catch {
3102
3095
  }
3103
3096
  }
3104
- } catch {
3105
3097
  }
3098
+ } catch {
3106
3099
  }
3107
3100
  }
3108
3101
  }
@@ -3114,14 +3107,21 @@ function activate(api) {
3114
3107
  }
3115
3108
  }
3116
3109
  } catch {
3117
- } finally {
3118
- sseController = null;
3119
- sseRetryMs = Math.min(sseRetryMs * 1.5, 6e4);
3120
- setTimeout(startMainWatcher, sseRetryMs);
3121
3110
  }
3111
+ scheduleReconnect();
3122
3112
  })();
3123
3113
  };
3124
- setTimeout(startMainWatcher, 3e3);
3114
+ var startMainWatcher = startMainWatcher2;
3115
+ const agentApiKey = ctx.config.apiKey;
3116
+ const sseUrl = `${ctx.config.apiUrl}/api/agenticmail/events`;
3117
+ let sseRetryMs = 5e3;
3118
+ let sseController = null;
3119
+ const scheduleReconnect = () => {
3120
+ sseController = null;
3121
+ sseRetryMs = Math.min(sseRetryMs * 1.5, 6e4);
3122
+ setTimeout(startMainWatcher2, sseRetryMs);
3123
+ };
3124
+ setTimeout(startMainWatcher2, 3e3);
3125
3125
  }
3126
3126
  if (api?.registerCommand) {
3127
3127
  api.registerCommand({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/openclaw",
3
- "version": "0.5.49",
3
+ "version": "0.5.51",
4
4
  "description": "OpenClaw plugin for AgenticMail — email, SMS, and phone number access for OpenClaw agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",