@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.
64 lines • 2.44 kB
TypeScript
import type { PersistedMailCredentials } from "../cloud/mail-credential-store.js";
/**
* Outbound-mail port (Cogent Mail M2.2). Following RemoteDataSource / Dependency_Injection
* (typescript-master-vault/concepts/RemoteDataSource.md, Dependency_Injection.md): the send
* tool depends on THIS interface, not on nodemailer, so it is unit-testable with an in-memory
* double and the SMTP library is swappable + loaded lazily (off the cold-start path).
*/
export interface OutgoingMail {
from: string;
to: string[];
subject: string;
text: string;
attachments: {
filename: string;
content: Buffer;
}[];
}
export interface MailSender {
send(mail: OutgoingMail): Promise<{
messageId: string;
}>;
}
/** In-memory sender: records what was sent. The test double the tool/service drives. */
export declare class InMemoryMailSender implements MailSender {
readonly sent: OutgoingMail[];
send(mail: OutgoingMail): Promise<{
messageId: string;
}>;
}
/**
* Real SMTP sender. nodemailer is imported LAZILY (dynamic import) so it never loads on
* the bridge's cold-start path — only when the agent actually sends mail. `transportFactory`
* is an injection seam for tests (default builds a real nodemailer SMTP transport from the creds).
*/
export declare class NodemailerMailSender implements MailSender {
private readonly creds;
private readonly transportFactory?;
constructor(creds: PersistedMailCredentials, transportFactory?: (() => Promise<{
sendMail(opts: unknown): Promise<{
messageId?: string;
}>;
}>) | undefined);
send(mail: OutgoingMail): Promise<{
messageId: string;
}>;
private defaultTransport;
}
/**
* Compose and send a mail from the agent's mailbox: reads each attachment from its local path
* (streaming the bytes into a Buffer), builds the {@link OutgoingMail}, and sends via the port.
* A missing/unreadable attachment path fails loud (the caller surfaces it as errorResult) rather
* than silently dropping the file. Returns the message id + the sending address.
*/
export declare function buildAndSendMail(sender: MailSender, creds: PersistedMailCredentials, params: {
to: string[];
subject: string;
text: string;
attachmentPaths?: string[];
}): Promise<{
messageId: string;
from: string;
to: string[];
}>;
//# sourceMappingURL=mail-sender.d.ts.map