@agenticmail/claudecode 0.1.7 → 0.1.8

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.
@@ -2,7 +2,7 @@ import {
2
2
  listAccounts,
3
3
  renderPersonaBody,
4
4
  resolveConfig
5
- } from "./chunk-YWSO3QOQ.js";
5
+ } from "./chunk-M5HV2M67.js";
6
6
 
7
7
  // src/persona-loader.ts
8
8
  import { existsSync, readFileSync } from "fs";
@@ -82,25 +82,25 @@ async function runWorker(query, persona, userPrompt, agent, mcpServerName, mcpCo
82
82
  env: mcpEnv
83
83
  }
84
84
  },
85
- // Restrict to MCP tools only — workers should never reach for
86
- // Bash / Read / Edit / etc. Listing them avoids accidental leakage.
87
- allowedTools: [
88
- `mcp__${mcpServerName}__whoami`,
89
- `mcp__${mcpServerName}__list_inbox`,
90
- `mcp__${mcpServerName}__read_email`,
91
- `mcp__${mcpServerName}__send_email`,
92
- `mcp__${mcpServerName}__reply_email`,
93
- `mcp__${mcpServerName}__search_emails`,
94
- `mcp__${mcpServerName}__list_agents`,
95
- `mcp__${mcpServerName}__message_agent`,
96
- `mcp__${mcpServerName}__call_agent`,
97
- `mcp__${mcpServerName}__wait_for_email`,
98
- `mcp__${mcpServerName}__check_tasks`,
99
- `mcp__${mcpServerName}__claim_task`,
100
- `mcp__${mcpServerName}__submit_result`,
101
- `mcp__${mcpServerName}__request_tools`,
102
- `mcp__${mcpServerName}__invoke`
103
- ],
85
+ // No `allowedTools` restriction.
86
+ //
87
+ // Earlier versions of the dispatcher locked workers to MCP-only tools
88
+ // ("you operate an email account, not a developer environment"). That
89
+ // was the wrong design: AgenticMail agents are real Claude Code
90
+ // subagents running under the host's OAuth, and the work humans
91
+ // delegate to them (write code, run tests, do research, edit files)
92
+ // demands the full native toolset (Read, Write, Edit, Bash, Glob,
93
+ // Grep, WebFetch, WebSearch, NotebookEdit, …). Restricting them
94
+ // turned "Zephyr implements the game" into "Zephyr emails source
95
+ // code as plaintext and the human has to copy-paste it" — which
96
+ // defeats the point of having agents in the first place.
97
+ //
98
+ // Omitting allowedTools lets the SDK fall through to its defaults
99
+ // (all built-in tools + every tool exposed by the MCP servers we
100
+ // declare above). Outbound mail is still guarded by AgenticMail's
101
+ // own outbound guard (HIGH-severity sends held for owner approval)
102
+ // and the worker is sandboxed by Claude Code's permission system
103
+ // just like any other subagent.
104
104
  permissionMode: "bypassPermissions",
105
105
  abortController: abortSignal ? wrapSignal(abortSignal) : void 0
106
106
  };
@@ -172,8 +172,14 @@ function newMailPrompt(agent, event) {
172
172
  ` When in doubt, stay silent \u2014 over-replying creates noise. Better to let`,
173
173
  ` the right teammate take the turn than to step on theirs.`,
174
174
  ``,
175
- `5. **If it's your turn \u2014 reply-all so the whole thread sees it.**`,
176
- ` reply_email({ uid: ${uid ?? "<uid>"}, replyAll: true, text: "...", _account: "${agent.name}" })`,
175
+ `5. **If it's your turn \u2014 do the actual work, THEN reply-all about it.**`,
176
+ ` You have full native tools: Read, Write, Edit, Bash, Glob, Grep, WebFetch,`,
177
+ ` WebSearch, NotebookEdit, etc. If the task is "implement X", write the file`,
178
+ ` with Write or Edit and verify with Bash \u2014 do NOT paste source code into an`,
179
+ ` email body and call it shipped. The thread is for COORDINATION ("done,`,
180
+ ` see ./foo.py, runs with \`python3 foo.py\`"); the filesystem is for`,
181
+ ` DELIVERABLES. Then:`,
182
+ ` reply_email({ uid: ${uid ?? "<uid>"}, replyAll: true, text: "...", _account: "${agent.name}" })`,
177
183
  ` Sign with your name. Be substantive but concise. If you are handing off`,
178
184
  ` to the next teammate, name them explicitly in your reply ("Orion \u2014 over to you, please \u2026").`,
179
185
  ``,
@@ -7,7 +7,7 @@ import {
7
7
  deleteAccount,
8
8
  getAccountByName,
9
9
  resolveConfig
10
- } from "./chunk-YWSO3QOQ.js";
10
+ } from "./chunk-M5HV2M67.js";
11
11
 
12
12
  // src/uninstall.ts
13
13
  import { existsSync, readdirSync, readFileSync, unlinkSync } from "fs";
@@ -121,30 +121,6 @@ function resolveConfig(opts = {}) {
121
121
  }
122
122
 
123
123
  // src/subagent-template.ts
124
- var ESSENTIAL_TOOL_NAMES = [
125
- "whoami",
126
- "list_inbox",
127
- "read_email",
128
- "send_email",
129
- "reply_email",
130
- "search_emails",
131
- "list_agents",
132
- "message_agent",
133
- // call_agent is the one-shot RPC primitive — sync request, sync answer.
134
- // For multi-step coordination use the thread pattern (send_email with
135
- // CC + reply_email with replyAll) instead.
136
- "call_agent",
137
- // wait_for_email is the thread-coordination primitive: block until a
138
- // specific reply lands in your inbox (filter by from / subject /
139
- // inReplyTo / participants). Essential for delegate-then-wait flows;
140
- // making subagents discover it via request_tools would be a usability
141
- // disaster for the most common coordination pattern.
142
- "wait_for_email",
143
- "check_tasks",
144
- // Meta-tools — these unlock the other ~50 tools on demand.
145
- "request_tools",
146
- "invoke"
147
- ];
148
124
  var MANAGED_BY_MARKER = "@agenticmail/claudecode";
149
125
  function yamlQuote(s) {
150
126
  const cleaned = s.replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim();
@@ -182,14 +158,15 @@ function renderPersonaBody(input) {
182
158
  "",
183
159
  "## Operating instructions",
184
160
  "",
185
- `You start every session with a small **pre-loaded** set of MCP tools (the ones listed in your frontmatter). Everything else AgenticMail offers \u2014 signatures, drafts, templates, SMS, bulk mail ops, folders, scheduling, spam tools, setup wizards, account admin \u2014 is reachable through the two **meta-tools** that are always pre-loaded:`,
161
+ `You have access to TWO complementary toolsets:`,
186
162
  "",
187
- `- \`${tool("request_tools")}\` \u2014 Returns a text catalogue of unloaded tools. Use with \`query="signature"\` to filter, or \`sets=["sms", "mail_extras"]\` to scope to specific categories.`,
188
- `- \`${tool("invoke")}\` \u2014 Calls any AgenticMail tool by name with structured args. Example: \`${tool("invoke")}({ tool: "manage_signatures", args: { action: "create", name: "default", body: "\u2014\\n${agent.name}" }, _account: "${agent.name}" })\`.`,
163
+ `1. **AgenticMail MCP tools** (\`${tool("*")}\`) \u2014 your mailbox, contacts, tasks, signatures, drafts, SMS, agent coordination. The full ~62-tool surface; the most common ones (\`${tool("list_inbox")}\`, \`${tool("send_email")}\`, \`${tool("reply_email")}\`, \`${tool("search_emails")}\`, \`${tool("call_agent")}\`, \`${tool("wait_for_email")}\`, \u2026) are pre-loaded. Anything else is reachable via the meta-tools \`${tool("request_tools")}\` (discover) + \`${tool("invoke")}\` (call by name).`,
189
164
  "",
190
- `**On EVERY tool call you make \u2014 pre-loaded OR via \`invoke\` \u2014 you MUST pass \`_account: "${agent.name}"\`.** This tells the MCP server to authenticate as you, not as the integration's bridge identity. Without it, you'd be reading the bridge's empty inbox instead of your own, sending mail from the wrong address, and bypassing your owner's expectation that the agent named "${agent.name}" did the work.`,
165
+ `2. **Native Claude Code tools** \u2014 Read, Write, Edit, Bash, Glob, Grep, WebFetch, WebSearch, NotebookEdit, and friends. The same toolset the host session has. Use them when the work actually involves files, code, the shell, or the web \u2014 DO NOT paste source code into an email when you could write the file yourself and tell the team "shipped to ./void_fall.py, runs with python3 void_fall.py". You are a real agent doing real work, not a paste-buffer.`,
191
166
  "",
192
- `Pre-loaded examples:`,
167
+ `**On EVERY MCP call you make \u2014 pre-loaded OR via \`invoke\` \u2014 you MUST pass \`_account: "${agent.name}"\`.** This tells the MCP server to authenticate as you, not as the integration's bridge identity. Without it, you'd be reading the bridge's empty inbox instead of your own, sending mail from the wrong address, and bypassing your owner's expectation that the agent named "${agent.name}" did the work. Native tools (Read/Write/Bash/etc.) don't need \`_account\` \u2014 they're not MCP.`,
168
+ "",
169
+ `Common MCP examples:`,
193
170
  "",
194
171
  "```",
195
172
  `${tool("list_inbox")}({ _account: "${agent.name}", limit: 10 })`,
@@ -230,14 +207,16 @@ function renderPersonaBody(input) {
230
207
  "",
231
208
  "## What you can do",
232
209
  "",
233
- `Anything an AgenticMail account can do. The full toolbelt covers email (send/read/reply/forward/search/move/mark/tag/folder), contacts, drafts, templates, signatures, scheduling rules, spam, pending-approval, SMS (send/receive/voice), task coordination (check/claim/submit/call other agents), and your own metadata. If a tool you need isn't in your pre-loaded list, call \`${tool("request_tools")}\` first to find it, then \`${tool("invoke")}\` it. Never ask for permission to use a tool \u2014 just use it.`,
210
+ `Anything a real Claude Code agent can do, scoped to your AgenticMail identity. That means: every email / SMS / contacts / drafts / templates / signatures / rules / spam / tasks operation via MCP, AND every file / shell / search / web operation via native tools. If the work involves code \u2014 write the file, run it, debug it, commit it. If the work involves research \u2014 fetch the URLs, read the pages, summarise. Reply by email when you have something to TELL the team; do the actual WORK with native tools.`,
211
+ "",
212
+ `If a specific AgenticMail tool isn't already loaded, call \`${tool("request_tools")}\` to find it, then \`${tool("invoke")}\` to call it. Never ask for permission to use a tool \u2014 just use it.`,
234
213
  "",
235
214
  "## Hard rules",
236
215
  "",
237
- `- **Always pass \`_account: "${agent.name}"\`** on every \`${tool("*")}\` call.`,
238
- `- **Do NOT use generic Claude Code tools** (Read, Edit, Write, Bash, Glob, Grep, WebFetch, etc.). You are operating an email account, not a developer environment. The user's filesystem is none of your business; your "workspace" is your mailbox.`,
216
+ `- **Always pass \`_account: "${agent.name}"\`** on every \`${tool("*")}\` MCP call. (Native tools \u2014 Read/Write/Bash/etc. \u2014 don't need it.)`,
217
+ `- **Do real work with the right tool.** If a teammate asks you to implement something, write the file with Write or Edit \u2014 do not paste source code into an email body and call it done. The mail thread is for coordination ("shipped at \`./void_fall.py\`, runs with \`python3 void_fall.py\`, here's a 2-line summary"); the filesystem is for deliverables.`,
239
218
  `- **Do not invent email content.** If you didn't read a real message, do not summarise one. If you don't know the answer, check your inbox / contacts / tasks first.`,
240
- `- **Do not impersonate other agents.** You are ${agent.name}, and only ${agent.name}. If the user asks you to also do something as "writer" or "researcher", suggest that they call those agents directly (via \`Agent { subagent_type: "agenticmail-<name>" }\` in the host session) \u2014 don't pass \`_account: "writer"\` to act as writer; that would falsify the From: header in any outgoing mail.`,
219
+ `- **Do not impersonate other agents.** You are ${agent.name}, and only ${agent.name}. If the user asks you to also do something as "writer" or "researcher", suggest that they call those agents directly \u2014 don't pass \`_account: "writer"\` to act as writer; that would falsify the From: header in any outgoing mail.`,
241
220
  `- **Respect outbound guard.** If a send is blocked by the AgenticMail outbound guard, tell the user in plain English \u2014 recipient, subject, the specific warnings \u2014 and ask them to approve. Do NOT rewrite the email to evade detection.`,
242
221
  "",
243
222
  "## Output style",
@@ -247,15 +226,12 @@ function renderPersonaBody(input) {
247
226
  ].filter((line) => line !== void 0).join("\n");
248
227
  }
249
228
  function renderSubagentMarkdown(input) {
250
- const { name, agent, mcpServerName } = input;
251
- const tool = (n) => `mcp__${mcpServerName}__${n}`;
229
+ const { name, agent } = input;
252
230
  const description = describeAgent(agent);
253
- const allowedTools = ESSENTIAL_TOOL_NAMES.map((n) => tool(n)).join(", ");
254
231
  const frontmatter = [
255
232
  "---",
256
233
  `name: ${name}`,
257
234
  `description: ${yamlQuote(description)}`,
258
- `tools: ${allowedTools}`,
259
235
  `model: inherit`,
260
236
  `# managed-by: ${MANAGED_BY_MARKER}`,
261
237
  `# agenticmail-agent-id: ${agent.id}`,
@@ -9,7 +9,7 @@ import {
9
9
  listAccounts,
10
10
  renderSubagentMarkdown,
11
11
  resolveConfig
12
- } from "./chunk-YWSO3QOQ.js";
12
+ } from "./chunk-M5HV2M67.js";
13
13
 
14
14
  // src/install.ts
15
15
  import { existsSync, mkdirSync, readdirSync, writeFileSync, readFileSync, unlinkSync } from "fs";
@@ -7,7 +7,7 @@ import {
7
7
  MANAGED_BY_MARKER,
8
8
  getAccountByName,
9
9
  resolveConfig
10
- } from "./chunk-YWSO3QOQ.js";
10
+ } from "./chunk-M5HV2M67.js";
11
11
 
12
12
  // src/status.ts
13
13
  import { existsSync, readFileSync, readdirSync } from "fs";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  install
3
- } from "./chunk-WP2ELPRM.js";
3
+ } from "./chunk-V5LH4BNZ.js";
4
4
  import {
5
5
  status
6
- } from "./chunk-UC63VEBP.js";
6
+ } from "./chunk-VYBBCFP5.js";
7
7
  import {
8
8
  uninstall
9
- } from "./chunk-XGBVWZ3M.js";
9
+ } from "./chunk-JVDPUO35.js";
10
10
  import {
11
11
  AgenticMailApiError
12
- } from "./chunk-YWSO3QOQ.js";
12
+ } from "./chunk-M5HV2M67.js";
13
13
 
14
14
  // src/http-routes.ts
15
15
  import { Router } from "express";
package/dist/cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  install
4
- } from "./chunk-WP2ELPRM.js";
4
+ } from "./chunk-V5LH4BNZ.js";
5
5
  import {
6
6
  status
7
- } from "./chunk-UC63VEBP.js";
7
+ } from "./chunk-VYBBCFP5.js";
8
8
  import {
9
9
  uninstall
10
- } from "./chunk-XGBVWZ3M.js";
10
+ } from "./chunk-JVDPUO35.js";
11
11
  import "./chunk-US5FT2UB.js";
12
12
  import {
13
13
  AgenticMailApiError
14
- } from "./chunk-YWSO3QOQ.js";
14
+ } from "./chunk-M5HV2M67.js";
15
15
 
16
16
  // src/cli.ts
17
17
  var GREEN = (s) => `\x1B[32m${s}\x1B[0m`;
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  Dispatcher
4
- } from "./chunk-3ZBSRXAK.js";
5
- import "./chunk-YWSO3QOQ.js";
4
+ } from "./chunk-5HUEJNT5.js";
5
+ import "./chunk-M5HV2M67.js";
6
6
 
7
7
  // src/dispatcher-bin.ts
8
8
  async function main() {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Dispatcher
3
- } from "./chunk-3ZBSRXAK.js";
4
- import "./chunk-YWSO3QOQ.js";
3
+ } from "./chunk-5HUEJNT5.js";
4
+ import "./chunk-M5HV2M67.js";
5
5
  export {
6
6
  Dispatcher
7
7
  };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createIntegrationRoutes
3
- } from "./chunk-N43A7EQB.js";
4
- import "./chunk-WP2ELPRM.js";
5
- import "./chunk-UC63VEBP.js";
6
- import "./chunk-XGBVWZ3M.js";
3
+ } from "./chunk-XHDRGX46.js";
4
+ import "./chunk-V5LH4BNZ.js";
5
+ import "./chunk-VYBBCFP5.js";
6
+ import "./chunk-JVDPUO35.js";
7
7
  import "./chunk-US5FT2UB.js";
8
- import "./chunk-YWSO3QOQ.js";
8
+ import "./chunk-M5HV2M67.js";
9
9
  export {
10
10
  createIntegrationRoutes
11
11
  };
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  Dispatcher,
3
3
  loadPersonaForAgent
4
- } from "./chunk-3ZBSRXAK.js";
4
+ } from "./chunk-5HUEJNT5.js";
5
5
  import {
6
6
  createIntegrationRoutes
7
- } from "./chunk-N43A7EQB.js";
7
+ } from "./chunk-XHDRGX46.js";
8
8
  import {
9
9
  install
10
- } from "./chunk-WP2ELPRM.js";
10
+ } from "./chunk-V5LH4BNZ.js";
11
11
  import {
12
12
  status
13
- } from "./chunk-UC63VEBP.js";
13
+ } from "./chunk-VYBBCFP5.js";
14
14
  import {
15
15
  uninstall
16
- } from "./chunk-XGBVWZ3M.js";
16
+ } from "./chunk-JVDPUO35.js";
17
17
  import "./chunk-US5FT2UB.js";
18
18
  import {
19
19
  AgenticMailApiError,
@@ -26,7 +26,7 @@ import {
26
26
  renderPersonaBody,
27
27
  renderSubagentMarkdown,
28
28
  resolveConfig
29
- } from "./chunk-YWSO3QOQ.js";
29
+ } from "./chunk-M5HV2M67.js";
30
30
  export {
31
31
  AgenticMailApiError,
32
32
  Dispatcher,
package/dist/install.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  install,
3
3
  selectExposableAgents
4
- } from "./chunk-WP2ELPRM.js";
4
+ } from "./chunk-V5LH4BNZ.js";
5
5
  import "./chunk-US5FT2UB.js";
6
- import "./chunk-YWSO3QOQ.js";
6
+ import "./chunk-M5HV2M67.js";
7
7
  export {
8
8
  install,
9
9
  selectExposableAgents
package/dist/status.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  status
3
- } from "./chunk-UC63VEBP.js";
3
+ } from "./chunk-VYBBCFP5.js";
4
4
  import "./chunk-US5FT2UB.js";
5
- import "./chunk-YWSO3QOQ.js";
5
+ import "./chunk-M5HV2M67.js";
6
6
  export {
7
7
  status
8
8
  };
package/dist/uninstall.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  uninstall
3
- } from "./chunk-XGBVWZ3M.js";
3
+ } from "./chunk-JVDPUO35.js";
4
4
  import "./chunk-US5FT2UB.js";
5
- import "./chunk-YWSO3QOQ.js";
5
+ import "./chunk-M5HV2M67.js";
6
6
  export {
7
7
  uninstall
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/claudecode",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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",