@agenticmail/claudecode 0.1.16 → 0.1.17
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/README.md +18 -1
- package/dist/{chunk-RNKJRBEF.js → chunk-SO75WFJB.js} +59 -2
- package/dist/dispatcher-bin.js +1 -1
- package/dist/dispatcher.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,24 @@ Agent { subagent_type: "agenticmail-fola", prompt: "draft a reply to my last ema
|
|
|
16
16
|
|
|
17
17
|
This package is to Claude Code what `@agenticmail/openclaw` is to OpenClaw: an integration package that wires AgenticMail into the host AI runtime. It mirrors that package's layout 1:1, so if you know one, you know the other.
|
|
18
18
|
|
|
19
|
-
## ✨ What's new in 0.1.
|
|
19
|
+
## ✨ What's new in 0.1.17
|
|
20
|
+
|
|
21
|
+
- **⏱ Compact-and-continue (0.1.17)** — workers can now run across multiple SDK turns when one isn't enough to finish a task. `runWorker` is wrapped by `runWorkerWithCompaction`, which on a context-overflow error (`prompt is too long`, `context_length_exceeded`, etc.) synthesises a breadcrumb checkpoint from the captured tool-call log + last assistant text, builds a continuation prompt prefixed with "Resuming after context reset / do NOT redo these steps", and loops. Capped at 4 iterations by default so cost is bounded; on cap exhaustion the worker exits with `compaction budget exhausted` so the host sees what happened.
|
|
22
|
+
- **🪝 Mail-hook resolves with absolute path (0.1.16)** — the hook command registered in `~/.claude/settings.json` is now `node "<abs-path>/mail-hook.js"` instead of the bare bin name. `import.meta.url` + a 3-step filesystem probe (`dist/` sibling → `dist/` alongside `src/` → `../dist/`) handle both published builds and dev checkouts (`tsx`-loaded `src/install.ts` no longer points at a non-existent `src/mail-hook.js`). The `command not found` and `MODULE_NOT_FOUND` errors are gone. Existing installs auto-heal on the next `agenticmail claudecode` run because the upserter rewrites the command with the freshly-resolved path.
|
|
23
|
+
- **📨 Stop hook output rewritten (0.1.15 / 0.1.16)** — the Stop hook's `reason` is printed to the user in the transcript. The original text was written assuming only the model would see it; phrases like "you do NOT need to ping the user" and "surface them to the user" read as awkward instruction-leakage. New shape:
|
|
24
|
+
```
|
|
25
|
+
🎀 New AgenticMail (bridge inbox) — N messages since the last check:
|
|
26
|
+
|
|
27
|
+
· UID 2 — vesper · Re: Audit assignment…
|
|
28
|
+
> <up to 180 chars of preview body>
|
|
29
|
+
|
|
30
|
+
Full body: mcp__agenticmail__read_email. Reply: mcp__agenticmail__reply_email (replyAll: true).
|
|
31
|
+
```
|
|
32
|
+
Same body for both UserPromptSubmit and Stop. Hard wall-time bound (1.5 s global timeout, 800 ms per fetch) and proper stdin listener cleanup so the hook never holds the harness REPL.
|
|
33
|
+
- **🤖 Autonomous-mode awareness via Stop hook (0.1.14)** — the mail hook now registers on `Stop` in addition to `UserPromptSubmit`. Long headless Claude Code runs (no user prompts firing for hours) finally see teammate replies: when bridge mail is unread at a turn boundary, the hook returns `{decision: 'block', reason: '…'}` forcing Claude to continue with the new-mail summary in context. This is the schema-correct supported way to inject context at Stop, unlike the 0.8.22 PreToolUse attempt which used the wrong output shape.
|
|
34
|
+
- **📥 Long-running workers (0.1.14)** — dropped the 30-min hard timeout. Per-worker log file at `~/.agenticmail/worker-logs/<id>.log` capturing every SDK tool call / result / assistant chunk. 30 s heartbeats POSTed to the API so `check_activity` shows real progress. Per-worker scratch cwd at `~/.agenticmail/worker-cwds/<id>/` prevents parallel agents from clobbering each other's output. Tail via the MCP `tail_worker` tool.
|
|
35
|
+
|
|
36
|
+
## ✨ Earlier — 0.1.14
|
|
20
37
|
|
|
21
38
|
- **Workers run for hours** — dropped the 30-min hard timeout. Per-worker log file at `~/.agenticmail/worker-logs/<id>.log` capturing every SDK tool call + result + assistant chunk as a one-liner. Heartbeats POSTed to the API every 30 s so `check_activity` sees real progress. Per-worker scratch cwd at `~/.agenticmail/worker-cwds/<id>/` prevents parallel agents from clobbering each other's output. Tail via the new MCP tool `tail_worker`.
|
|
22
39
|
- **Autonomous-mode awareness via Stop hook** — the mail hook now registers on the **Stop** Claude Code event too. Long headless runs (no user prompts) finally see teammate replies: when bridge mail is unread at a turn boundary, the hook returns `{decision: 'block', reason: '...'}`, forcing Claude to continue with the new-mail summary in context. This is the schema-correct supported way to inject context at Stop, unlike the 0.8.22 PreToolUse attempt.
|
|
@@ -104,6 +104,64 @@ function threadIdFromSubject(subject) {
|
|
|
104
104
|
}
|
|
105
105
|
var DEFAULT_MAX_WAKES_PER_THREAD = 10;
|
|
106
106
|
var DEFAULT_WAKE_WINDOW_MS = 24 * 60 * 60 * 1e3;
|
|
107
|
+
async function runWorkerWithCompaction(query, persona, initialPrompt, agent, mcpServerName, mcpCommand, mcpArgs, mcpEnv, log, observer, cwd, maxIterations = 4) {
|
|
108
|
+
let prompt = initialPrompt;
|
|
109
|
+
let lastResult = null;
|
|
110
|
+
const breadcrumbs = [];
|
|
111
|
+
const captureObserver = {
|
|
112
|
+
onMessage(tag, summary) {
|
|
113
|
+
observer.onMessage(tag, summary);
|
|
114
|
+
if (tag === "tool_use") breadcrumbs.push(`\u2713 ${summary}`);
|
|
115
|
+
else if (tag === "tool_result") breadcrumbs.push(` \u2192 ${summary}`);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
for (let iter = 0; iter < maxIterations; iter++) {
|
|
119
|
+
if (iter > 0) {
|
|
120
|
+
log("info", `[dispatcher] compaction iter ${iter + 1}/${maxIterations} for "${agent.name}"`);
|
|
121
|
+
}
|
|
122
|
+
lastResult = await runWorker(
|
|
123
|
+
query,
|
|
124
|
+
persona,
|
|
125
|
+
prompt,
|
|
126
|
+
agent,
|
|
127
|
+
mcpServerName,
|
|
128
|
+
mcpCommand,
|
|
129
|
+
mcpArgs,
|
|
130
|
+
mcpEnv,
|
|
131
|
+
log,
|
|
132
|
+
void 0,
|
|
133
|
+
captureObserver,
|
|
134
|
+
cwd
|
|
135
|
+
);
|
|
136
|
+
if (lastResult.ok) return lastResult;
|
|
137
|
+
if (!isContextOverflowError(lastResult.error)) return lastResult;
|
|
138
|
+
if (iter === maxIterations - 1) {
|
|
139
|
+
return { ok: false, error: `compaction budget exhausted (${maxIterations} iters): ${lastResult.error}` };
|
|
140
|
+
}
|
|
141
|
+
const checkpoint = breadcrumbs.slice(-40).join("\n");
|
|
142
|
+
prompt = [
|
|
143
|
+
initialPrompt,
|
|
144
|
+
"",
|
|
145
|
+
"## Resuming after context reset",
|
|
146
|
+
"",
|
|
147
|
+
"You hit the model context limit on the previous turn. Here is a",
|
|
148
|
+
"breadcrumb of what you already accomplished in that turn \u2014",
|
|
149
|
+
"do NOT redo any of these steps:",
|
|
150
|
+
"",
|
|
151
|
+
checkpoint || "(no breadcrumbs captured)",
|
|
152
|
+
"",
|
|
153
|
+
"Continue from where you left off. If you have already produced",
|
|
154
|
+
"the final deliverable on the previous turn (e.g. submit_result,",
|
|
155
|
+
"reply_email), do nothing this turn and end cleanly."
|
|
156
|
+
].join("\n");
|
|
157
|
+
log("info", `[dispatcher] context overflow on "${agent.name}" \u2014 compacting (${breadcrumbs.length} breadcrumbs)`);
|
|
158
|
+
}
|
|
159
|
+
return lastResult ?? { ok: false, error: "worker did not run" };
|
|
160
|
+
}
|
|
161
|
+
function isContextOverflowError(msg) {
|
|
162
|
+
const m = msg.toLowerCase();
|
|
163
|
+
return m.includes("prompt is too long") || m.includes("context_length_exceeded") || m.includes("context length exceeded") || m.includes("max tokens") || m.includes("maximum context") || m.includes("token limit");
|
|
164
|
+
}
|
|
107
165
|
async function runWorker(query, persona, userPrompt, agent, mcpServerName, mcpCommand, mcpArgs, mcpEnv, log, abortSignal, observer, cwd) {
|
|
108
166
|
const opts = {
|
|
109
167
|
systemPrompt: persona,
|
|
@@ -778,7 +836,7 @@ var Dispatcher = class {
|
|
|
778
836
|
});
|
|
779
837
|
this.log("info", `[dispatcher] waking "${account.name}" \u2014 ${ctx.kind}${ctx.taskId ? " " + ctx.taskId : ctx.uid ? " uid=" + ctx.uid : ""}`);
|
|
780
838
|
const mcpEnv = await this.buildMcpEnv();
|
|
781
|
-
workerResult = await
|
|
839
|
+
workerResult = await runWorkerWithCompaction(
|
|
782
840
|
this.query,
|
|
783
841
|
body,
|
|
784
842
|
prompt,
|
|
@@ -788,7 +846,6 @@ var Dispatcher = class {
|
|
|
788
846
|
this.cfg.mcpArgs,
|
|
789
847
|
mcpEnv,
|
|
790
848
|
this.log,
|
|
791
|
-
void 0,
|
|
792
849
|
observer,
|
|
793
850
|
cwdDir
|
|
794
851
|
);
|
package/dist/dispatcher-bin.js
CHANGED
package/dist/dispatcher.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenticmail/claudecode",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
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",
|