@agenticmail/claudecode 0.1.14 → 0.1.15
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/mail-hook.js +39 -23
- package/package.json +1 -1
package/dist/mail-hook.js
CHANGED
|
@@ -8,29 +8,43 @@ var AGENTICMAIL_DIR = join(homedir(), ".agenticmail");
|
|
|
8
8
|
var CONFIG_PATH = join(AGENTICMAIL_DIR, "config.json");
|
|
9
9
|
var CURSOR_PATH = join(AGENTICMAIL_DIR, "claudecode-hook-cursor.json");
|
|
10
10
|
var HOOK_VERSION = "1";
|
|
11
|
-
var HTTP_TIMEOUT_MS =
|
|
11
|
+
var HTTP_TIMEOUT_MS = 800;
|
|
12
|
+
var GLOBAL_TIMEOUT_MS = 1500;
|
|
12
13
|
var STOP_THROTTLE_MS = 15e3;
|
|
13
14
|
async function readStdinJson() {
|
|
14
15
|
if (process.stdin.isTTY) return null;
|
|
15
16
|
return new Promise((resolve) => {
|
|
16
17
|
let buf = "";
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let settled = false;
|
|
19
|
+
const onData = (chunk) => {
|
|
19
20
|
buf += chunk;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (!buf.trim())
|
|
23
|
-
resolve(null);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
21
|
+
};
|
|
22
|
+
const onEnd = () => finish(() => {
|
|
23
|
+
if (!buf.trim()) return null;
|
|
26
24
|
try {
|
|
27
|
-
|
|
25
|
+
return JSON.parse(buf);
|
|
28
26
|
} catch {
|
|
29
|
-
|
|
27
|
+
return null;
|
|
30
28
|
}
|
|
31
29
|
});
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const onError = () => finish(() => null);
|
|
31
|
+
const finish = (compute) => {
|
|
32
|
+
if (settled) return;
|
|
33
|
+
settled = true;
|
|
34
|
+
process.stdin.removeListener("data", onData);
|
|
35
|
+
process.stdin.removeListener("end", onEnd);
|
|
36
|
+
process.stdin.removeListener("error", onError);
|
|
37
|
+
try {
|
|
38
|
+
process.stdin.unref();
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
resolve(compute());
|
|
42
|
+
};
|
|
43
|
+
process.stdin.setEncoding("utf-8");
|
|
44
|
+
process.stdin.on("data", onData);
|
|
45
|
+
process.stdin.on("end", onEnd);
|
|
46
|
+
process.stdin.on("error", onError);
|
|
47
|
+
setTimeout(() => finish(() => null), 200).unref();
|
|
34
48
|
});
|
|
35
49
|
}
|
|
36
50
|
async function main() {
|
|
@@ -108,20 +122,20 @@ async function main() {
|
|
|
108
122
|
}
|
|
109
123
|
newOnes.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
|
110
124
|
const lines = [];
|
|
111
|
-
|
|
125
|
+
const count = newOnes.length;
|
|
126
|
+
lines.push(`\u{1F380} New AgenticMail (bridge inbox) \u2014 ${count} message${count === 1 ? "" : "s"} since the last check:`);
|
|
127
|
+
lines.push("");
|
|
112
128
|
for (const m of newOnes) {
|
|
113
129
|
const fromAddr = m.from?.[0]?.address ?? "unknown";
|
|
114
130
|
const fromName = m.from?.[0]?.name ?? "";
|
|
115
131
|
const fromDisp = fromName && fromName !== fromAddr ? `${fromName} <${fromAddr}>` : fromAddr;
|
|
116
132
|
const subj = m.subject ?? "(no subject)";
|
|
117
|
-
const preview = (m.preview ?? "").replace(/\s+/g, " ").trim().slice(0,
|
|
118
|
-
|
|
119
|
-
lines.push(
|
|
133
|
+
const preview = (m.preview ?? "").replace(/\s+/g, " ").trim().slice(0, 180);
|
|
134
|
+
lines.push(` \xB7 UID ${m.uid} \u2014 ${fromDisp} \xB7 ${subj}`);
|
|
135
|
+
if (preview) lines.push(` > ${preview}${preview.length === 180 ? "\u2026" : ""}`);
|
|
136
|
+
lines.push("");
|
|
120
137
|
}
|
|
121
|
-
lines.push("");
|
|
122
|
-
lines.push(
|
|
123
|
-
"These are real replies from sub-agents (or mid-task questions). If any of them are addressed to you (Claude Code, the host), surface them to the user and act on whichever they direct you to. Use mcp__agenticmail__read_email for the full body, mcp__agenticmail__reply_email (with replyAll: true) to respond on the thread. You do NOT need to ping the user \u2014 just be aware these landed."
|
|
124
|
-
);
|
|
138
|
+
lines.push("Full body: mcp__agenticmail__read_email. Reply: mcp__agenticmail__reply_email (replyAll: true).");
|
|
125
139
|
const newestMs = Math.max(...newOnes.map((m) => new Date(m.date).getTime()));
|
|
126
140
|
try {
|
|
127
141
|
if (!existsSync(dirname(CURSOR_PATH))) mkdirSync(dirname(CURSOR_PATH), { recursive: true });
|
|
@@ -149,6 +163,8 @@ async function main() {
|
|
|
149
163
|
}));
|
|
150
164
|
}
|
|
151
165
|
}
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
var globalTimeout = new Promise((resolve) => {
|
|
167
|
+
setTimeout(() => resolve(), GLOBAL_TIMEOUT_MS).unref();
|
|
154
168
|
});
|
|
169
|
+
Promise.race([main(), globalTimeout]).catch(() => {
|
|
170
|
+
}).finally(() => process.exit(0));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenticmail/claudecode",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Claude Code integration for AgenticMail — surfaces every AgenticMail agent as a native Claude Code subagent so any Claude Code session can delegate to them with the Agent tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|