@agenticmail/core 0.9.2 → 0.9.4

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
@@ -964,7 +964,13 @@ var MailReceiver = class {
964
964
  async fetchMessage(uid, mailbox = "INBOX") {
965
965
  const lock = await this.client.getMailboxLock(mailbox);
966
966
  try {
967
- const { content } = await this.client.download(String(uid), void 0, { uid: true });
967
+ const result = await this.client.download(String(uid), void 0, { uid: true });
968
+ const content = result?.content;
969
+ if (!content) {
970
+ const err = new Error(`Message UID ${uid} not found in mailbox "${mailbox}"`);
971
+ err.code = "MESSAGE_NOT_FOUND";
972
+ throw err;
973
+ }
968
974
  const chunks = [];
969
975
  for await (const chunk of content) {
970
976
  chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
@@ -2006,7 +2012,7 @@ var import_uuid = require("uuid");
2006
2012
  var import_node_crypto = require("crypto");
2007
2013
 
2008
2014
  // src/accounts/types.ts
2009
- var AGENT_ROLES = ["secretary", "assistant", "researcher", "writer", "custom"];
2015
+ var AGENT_ROLES = ["secretary", "assistant", "researcher", "writer", "custom", "bridge"];
2010
2016
  var DEFAULT_AGENT_ROLE = "secretary";
2011
2017
  var DEFAULT_AGENT_NAME = "secretary";
2012
2018
 
@@ -2135,6 +2141,27 @@ var AccountManager = class {
2135
2141
  const result = stmt.run(id);
2136
2142
  return result.changes > 0;
2137
2143
  }
2144
+ /**
2145
+ * Update an agent's role. Used by host-integration installers
2146
+ * (`@agenticmail/claudecode`, `@agenticmail/codex`) to migrate a
2147
+ * pre-existing bridge account from `'assistant'` (the workaround they
2148
+ * used before the `'bridge'` role landed) to the canonical
2149
+ * `'bridge'` role. Returns the updated agent, or null when the id
2150
+ * doesn't exist.
2151
+ *
2152
+ * Caller is responsible for validating the role string against
2153
+ * AGENT_ROLES — this method trusts what it's given.
2154
+ */
2155
+ async updateRole(id, role) {
2156
+ const existing = await this.getById(id);
2157
+ if (!existing) return null;
2158
+ if (existing.role === role) return existing;
2159
+ const stmt = this.db.prepare(`
2160
+ UPDATE agents SET role = ?, updated_at = datetime('now') WHERE id = ?
2161
+ `);
2162
+ stmt.run(role, id);
2163
+ return this.getById(id);
2164
+ }
2138
2165
  async updateMetadata(id, metadata) {
2139
2166
  const existing = await this.getById(id);
2140
2167
  if (!existing) return null;
package/dist/index.d.cts CHANGED
@@ -305,8 +305,19 @@ declare function getDatabase(config: AgenticMailConfig): Database;
305
305
  declare function closeDatabase(): void;
306
306
  declare function createTestDatabase(): Database;
307
307
 
308
- /** Predefined agent roles */
309
- type AgentRole = 'secretary' | 'assistant' | 'researcher' | 'writer' | 'custom';
308
+ /** Predefined agent roles.
309
+ *
310
+ * `bridge` is the host-bridge identity — the account that represents an
311
+ * external LLM host (Claude Code, Codex, Hermes, …) inside AgenticMail.
312
+ * It owns its own inbox + API key like any other account but is logically
313
+ * special: it's not a teammate the user assigns work to, it's the host
314
+ * itself acting on behalf of itself. The web UI / list_agents / wake
315
+ * gating SHOULD treat bridge accounts distinctly (they aren't typically
316
+ * spawned as subagents; they don't show up in coordination team pickers
317
+ * by default). The host-integration packages (@agenticmail/claudecode,
318
+ * @agenticmail/codex) use this role when provisioning their bridge.
319
+ */
320
+ type AgentRole = 'secretary' | 'assistant' | 'researcher' | 'writer' | 'custom' | 'bridge';
310
321
  declare const AGENT_ROLES: readonly AgentRole[];
311
322
  declare const DEFAULT_AGENT_ROLE: AgentRole;
312
323
  declare const DEFAULT_AGENT_NAME = "secretary";
@@ -348,6 +359,18 @@ declare class AccountManager {
348
359
  list(): Promise<Agent[]>;
349
360
  getByRole(role: AgentRole): Promise<Agent[]>;
350
361
  delete(id: string): Promise<boolean>;
362
+ /**
363
+ * Update an agent's role. Used by host-integration installers
364
+ * (`@agenticmail/claudecode`, `@agenticmail/codex`) to migrate a
365
+ * pre-existing bridge account from `'assistant'` (the workaround they
366
+ * used before the `'bridge'` role landed) to the canonical
367
+ * `'bridge'` role. Returns the updated agent, or null when the id
368
+ * doesn't exist.
369
+ *
370
+ * Caller is responsible for validating the role string against
371
+ * AGENT_ROLES — this method trusts what it's given.
372
+ */
373
+ updateRole(id: string, role: AgentRole): Promise<Agent | null>;
351
374
  updateMetadata(id: string, metadata: Record<string, unknown>): Promise<Agent | null>;
352
375
  getCredentials(id: string): Promise<{
353
376
  email: string;
package/dist/index.d.ts CHANGED
@@ -305,8 +305,19 @@ declare function getDatabase(config: AgenticMailConfig): Database;
305
305
  declare function closeDatabase(): void;
306
306
  declare function createTestDatabase(): Database;
307
307
 
308
- /** Predefined agent roles */
309
- type AgentRole = 'secretary' | 'assistant' | 'researcher' | 'writer' | 'custom';
308
+ /** Predefined agent roles.
309
+ *
310
+ * `bridge` is the host-bridge identity — the account that represents an
311
+ * external LLM host (Claude Code, Codex, Hermes, …) inside AgenticMail.
312
+ * It owns its own inbox + API key like any other account but is logically
313
+ * special: it's not a teammate the user assigns work to, it's the host
314
+ * itself acting on behalf of itself. The web UI / list_agents / wake
315
+ * gating SHOULD treat bridge accounts distinctly (they aren't typically
316
+ * spawned as subagents; they don't show up in coordination team pickers
317
+ * by default). The host-integration packages (@agenticmail/claudecode,
318
+ * @agenticmail/codex) use this role when provisioning their bridge.
319
+ */
320
+ type AgentRole = 'secretary' | 'assistant' | 'researcher' | 'writer' | 'custom' | 'bridge';
310
321
  declare const AGENT_ROLES: readonly AgentRole[];
311
322
  declare const DEFAULT_AGENT_ROLE: AgentRole;
312
323
  declare const DEFAULT_AGENT_NAME = "secretary";
@@ -348,6 +359,18 @@ declare class AccountManager {
348
359
  list(): Promise<Agent[]>;
349
360
  getByRole(role: AgentRole): Promise<Agent[]>;
350
361
  delete(id: string): Promise<boolean>;
362
+ /**
363
+ * Update an agent's role. Used by host-integration installers
364
+ * (`@agenticmail/claudecode`, `@agenticmail/codex`) to migrate a
365
+ * pre-existing bridge account from `'assistant'` (the workaround they
366
+ * used before the `'bridge'` role landed) to the canonical
367
+ * `'bridge'` role. Returns the updated agent, or null when the id
368
+ * doesn't exist.
369
+ *
370
+ * Caller is responsible for validating the role string against
371
+ * AGENT_ROLES — this method trusts what it's given.
372
+ */
373
+ updateRole(id: string, role: AgentRole): Promise<Agent | null>;
351
374
  updateMetadata(id: string, metadata: Record<string, unknown>): Promise<Agent | null>;
352
375
  getCredentials(id: string): Promise<{
353
376
  email: string;
package/dist/index.js CHANGED
@@ -205,7 +205,13 @@ var MailReceiver = class {
205
205
  async fetchMessage(uid, mailbox = "INBOX") {
206
206
  const lock = await this.client.getMailboxLock(mailbox);
207
207
  try {
208
- const { content } = await this.client.download(String(uid), void 0, { uid: true });
208
+ const result = await this.client.download(String(uid), void 0, { uid: true });
209
+ const content = result?.content;
210
+ if (!content) {
211
+ const err = new Error(`Message UID ${uid} not found in mailbox "${mailbox}"`);
212
+ err.code = "MESSAGE_NOT_FOUND";
213
+ throw err;
214
+ }
209
215
  const chunks = [];
210
216
  for await (const chunk of content) {
211
217
  chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
@@ -1247,7 +1253,7 @@ import { v4 as uuidv4 } from "uuid";
1247
1253
  import { randomBytes } from "crypto";
1248
1254
 
1249
1255
  // src/accounts/types.ts
1250
- var AGENT_ROLES = ["secretary", "assistant", "researcher", "writer", "custom"];
1256
+ var AGENT_ROLES = ["secretary", "assistant", "researcher", "writer", "custom", "bridge"];
1251
1257
  var DEFAULT_AGENT_ROLE = "secretary";
1252
1258
  var DEFAULT_AGENT_NAME = "secretary";
1253
1259
 
@@ -1376,6 +1382,27 @@ var AccountManager = class {
1376
1382
  const result = stmt.run(id);
1377
1383
  return result.changes > 0;
1378
1384
  }
1385
+ /**
1386
+ * Update an agent's role. Used by host-integration installers
1387
+ * (`@agenticmail/claudecode`, `@agenticmail/codex`) to migrate a
1388
+ * pre-existing bridge account from `'assistant'` (the workaround they
1389
+ * used before the `'bridge'` role landed) to the canonical
1390
+ * `'bridge'` role. Returns the updated agent, or null when the id
1391
+ * doesn't exist.
1392
+ *
1393
+ * Caller is responsible for validating the role string against
1394
+ * AGENT_ROLES — this method trusts what it's given.
1395
+ */
1396
+ async updateRole(id, role) {
1397
+ const existing = await this.getById(id);
1398
+ if (!existing) return null;
1399
+ if (existing.role === role) return existing;
1400
+ const stmt = this.db.prepare(`
1401
+ UPDATE agents SET role = ?, updated_at = datetime('now') WHERE id = ?
1402
+ `);
1403
+ stmt.run(role, id);
1404
+ return this.getById(id);
1405
+ }
1379
1406
  async updateMetadata(id, metadata) {
1380
1407
  const existing = await this.getById(id);
1381
1408
  if (!existing) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/core",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "Core SDK for AgenticMail — email, SMS, and phone number access for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",