@agenticmail/openclaw 0.5.47 → 0.5.48
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 +35 -10
- package/dist/index.js +35 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3115,16 +3115,41 @@ function activate(api) {
|
|
|
3115
3115
|
const from = event.from ?? "unknown";
|
|
3116
3116
|
const subject = event.subject ?? "(no subject)";
|
|
3117
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
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3118
|
+
const hooksToken = process.env.OPENCLAW_HOOKS_TOKEN;
|
|
3119
|
+
let wakeSuccess = false;
|
|
3120
|
+
if (hooksToken) {
|
|
3121
|
+
try {
|
|
3122
|
+
const hookUrl = `http://127.0.0.1:${gatewayPort}/hooks/agent`;
|
|
3123
|
+
const resp = await fetch(hookUrl, {
|
|
3124
|
+
method: "POST",
|
|
3125
|
+
headers: {
|
|
3126
|
+
"Content-Type": "application/json",
|
|
3127
|
+
"Authorization": `Bearer ${hooksToken}`
|
|
3128
|
+
},
|
|
3129
|
+
body: JSON.stringify({
|
|
3130
|
+
event: "system",
|
|
3131
|
+
text: wakeText,
|
|
3132
|
+
sessionTarget: "main"
|
|
3133
|
+
}),
|
|
3134
|
+
signal: AbortSignal.timeout(5e3)
|
|
3135
|
+
});
|
|
3136
|
+
if (resp.ok) {
|
|
3137
|
+
wakeSuccess = true;
|
|
3138
|
+
console.log(`[agenticmail] Wake event sent via webhook for new email from ${from}: "${subject}"`);
|
|
3139
|
+
}
|
|
3140
|
+
} catch {
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
if (!wakeSuccess && api?.callTool) {
|
|
3144
|
+
try {
|
|
3145
|
+
await api.callTool("cron", { action: "wake", text: wakeText, mode: "now" });
|
|
3146
|
+
wakeSuccess = true;
|
|
3147
|
+
console.log(`[agenticmail] Wake event sent via cron tool for new email from ${from}: "${subject}"`);
|
|
3148
|
+
} catch {
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
if (!wakeSuccess) {
|
|
3152
|
+
console.warn(`[agenticmail] Could not send wake event for email from ${from}: "${subject}"`);
|
|
3128
3153
|
}
|
|
3129
3154
|
}
|
|
3130
3155
|
} catch {
|
package/dist/index.js
CHANGED
|
@@ -3079,16 +3079,41 @@ function activate(api) {
|
|
|
3079
3079
|
const from = event.from ?? "unknown";
|
|
3080
3080
|
const subject = event.subject ?? "(no subject)";
|
|
3081
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
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3082
|
+
const hooksToken = process.env.OPENCLAW_HOOKS_TOKEN;
|
|
3083
|
+
let wakeSuccess = false;
|
|
3084
|
+
if (hooksToken) {
|
|
3085
|
+
try {
|
|
3086
|
+
const hookUrl = `http://127.0.0.1:${gatewayPort}/hooks/agent`;
|
|
3087
|
+
const resp = await fetch(hookUrl, {
|
|
3088
|
+
method: "POST",
|
|
3089
|
+
headers: {
|
|
3090
|
+
"Content-Type": "application/json",
|
|
3091
|
+
"Authorization": `Bearer ${hooksToken}`
|
|
3092
|
+
},
|
|
3093
|
+
body: JSON.stringify({
|
|
3094
|
+
event: "system",
|
|
3095
|
+
text: wakeText,
|
|
3096
|
+
sessionTarget: "main"
|
|
3097
|
+
}),
|
|
3098
|
+
signal: AbortSignal.timeout(5e3)
|
|
3099
|
+
});
|
|
3100
|
+
if (resp.ok) {
|
|
3101
|
+
wakeSuccess = true;
|
|
3102
|
+
console.log(`[agenticmail] Wake event sent via webhook for new email from ${from}: "${subject}"`);
|
|
3103
|
+
}
|
|
3104
|
+
} catch {
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
if (!wakeSuccess && api?.callTool) {
|
|
3108
|
+
try {
|
|
3109
|
+
await api.callTool("cron", { action: "wake", text: wakeText, mode: "now" });
|
|
3110
|
+
wakeSuccess = true;
|
|
3111
|
+
console.log(`[agenticmail] Wake event sent via cron tool for new email from ${from}: "${subject}"`);
|
|
3112
|
+
} catch {
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
if (!wakeSuccess) {
|
|
3116
|
+
console.warn(`[agenticmail] Could not send wake event for email from ${from}: "${subject}"`);
|
|
3092
3117
|
}
|
|
3093
3118
|
}
|
|
3094
3119
|
} catch {
|
package/package.json
CHANGED