UNPKG

@essentialai/cogent-bridge

Version:

Cogent Bridge — cross-agent comms for Claude Code, OpenAI Codex and Slack. Codex users: install with `curl -fsSL https://cogent.tools/install.sh | sh`, then start with `cogent-codex` for real-time peer wake.

49 lines • 2.85 kB
import { z } from "zod"; import { successResult, errorResult } from "../errors.js"; import { saveMailCredentials, MAIL_DEFAULT_HOST } from "../cloud/mail-credential-store.js"; import { assertValidEmail, assertAllowedMailDomain } from "../mail/validate.js"; const DEFAULT_MAIL_HOST = MAIL_DEFAULT_HOST; /** * cogent_setup_mail — store this agent's mailbox credentials locally (Cogent Mail M2). * The operator provisions the mailbox in the admin Mail panel (M1), which shows the * address + password ONCE; the agent runs this tool to save them to its per-cwd 0600 * store so cogent_send_mail / cogent_fetch_mail can use them. (Auto-provision on register * SHIPPED for TEAM — `mail-acquisition-test` exit 0, 2026-09-16; this tool remains the manual * path for FREE and for re-storing credentials after a rotation.) */ export function registerSetupMailTool(server) { server.registerTool("cogent_setup_mail", { title: "Configure this agent's mailbox", description: "Store the agent's mailbox address + password (from the admin Mail panel) locally so " + "cogent_send_mail and cogent_fetch_mail can use them. Hosts default to mail.cogent.tools " + "(IMAP 993 / SMTP 465).", inputSchema: { address: z.string().describe("Full mailbox address, e.g. claude-agent-backend@mail.cogent.tools"), password: z.string().describe("Mailbox password (shown once in the admin Mail panel on create/rotate)"), imapHost: z.string().optional().describe(`IMAP host (default ${DEFAULT_MAIL_HOST})`), imapPort: z.number().int().positive().optional().describe("IMAP port (default 993)"), smtpHost: z.string().optional().describe(`SMTP host (default ${DEFAULT_MAIL_HOST})`), smtpPort: z.number().int().positive().optional().describe("SMTP submission port (default 465)"), }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }, }, async ({ address, password, imapHost, imapPort, smtpHost, smtpPort }) => { try { assertValidEmail(address, "address"); // reject fat-finger creds before persisting assertAllowedMailDomain(address, "address"); // F4: org-only — block BYO external mailboxes await saveMailCredentials({ address, password, imapHost: imapHost ?? DEFAULT_MAIL_HOST, imapPort: imapPort ?? 993, smtpHost: smtpHost ?? DEFAULT_MAIL_HOST, smtpPort: smtpPort ?? 465, savedAt: new Date().toISOString(), }); return successResult({ configured: true, address }); } catch (err) { return errorResult(err); } }); } //# sourceMappingURL=setup-mail.js.map