@agenticmail/core 0.9.8 → 0.9.10
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 +323 -52
- package/dist/index.d.cts +131 -22
- package/dist/index.d.ts +131 -22
- package/dist/index.js +314 -52
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -481,6 +481,7 @@ interface MailSenderOptions {
|
|
|
481
481
|
password: string;
|
|
482
482
|
authUser?: string;
|
|
483
483
|
secure?: boolean;
|
|
484
|
+
tlsRejectUnauthorized?: boolean;
|
|
484
485
|
}
|
|
485
486
|
interface SendResultWithRaw extends SendResult {
|
|
486
487
|
/** Raw RFC822 message bytes (for appending to Sent folder) */
|
|
@@ -1442,13 +1443,13 @@ declare class RelayBridge {
|
|
|
1442
1443
|
declare function startRelayBridge(options: RelayBridgeOptions): RelayBridge;
|
|
1443
1444
|
|
|
1444
1445
|
/**
|
|
1445
|
-
* SMS Manager -
|
|
1446
|
+
* SMS Manager - provider-backed SMS integration
|
|
1446
1447
|
*
|
|
1447
1448
|
* How it works:
|
|
1448
|
-
* 1. User
|
|
1449
|
-
* 2.
|
|
1450
|
-
* 3.
|
|
1451
|
-
* 4.
|
|
1449
|
+
* 1. User chooses a provider for the agent phone number
|
|
1450
|
+
* 2. Google Voice uses email forwarding/web instructions
|
|
1451
|
+
* 3. 46elks uses direct API sends and inbound webhooks
|
|
1452
|
+
* 4. All inbound/outbound messages are stored in the SMS table
|
|
1452
1453
|
*
|
|
1453
1454
|
* SMS config is stored in agent metadata under the "sms" key.
|
|
1454
1455
|
*/
|
|
@@ -1456,16 +1457,24 @@ declare function startRelayBridge(options: RelayBridgeOptions): RelayBridge;
|
|
|
1456
1457
|
interface SmsConfig {
|
|
1457
1458
|
/** Whether SMS is enabled for this agent */
|
|
1458
1459
|
enabled: boolean;
|
|
1459
|
-
/**
|
|
1460
|
+
/** Phone number in E.164 format where possible */
|
|
1460
1461
|
phoneNumber: string;
|
|
1461
1462
|
/** The email address Google Voice forwards SMS to (the Gmail used for GV signup) */
|
|
1462
|
-
forwardingEmail
|
|
1463
|
+
forwardingEmail?: string;
|
|
1463
1464
|
/** App password for forwarding email (only needed if different from relay email) */
|
|
1464
1465
|
forwardingPassword?: string;
|
|
1465
1466
|
/** Whether the GV Gmail is the same as the relay email */
|
|
1466
1467
|
sameAsRelay?: boolean;
|
|
1467
|
-
/**
|
|
1468
|
-
provider: 'google_voice';
|
|
1468
|
+
/** SMS provider */
|
|
1469
|
+
provider: 'google_voice' | '46elks';
|
|
1470
|
+
/** 46elks API username */
|
|
1471
|
+
username?: string;
|
|
1472
|
+
/** 46elks API password */
|
|
1473
|
+
password?: string;
|
|
1474
|
+
/** Provider API base URL override */
|
|
1475
|
+
apiUrl?: string;
|
|
1476
|
+
/** Secret required on inbound provider webhooks */
|
|
1477
|
+
webhookSecret?: string;
|
|
1469
1478
|
/** When SMS was configured */
|
|
1470
1479
|
configuredAt: string;
|
|
1471
1480
|
}
|
|
@@ -1485,6 +1494,37 @@ interface SmsMessage {
|
|
|
1485
1494
|
createdAt: string;
|
|
1486
1495
|
metadata?: Record<string, unknown>;
|
|
1487
1496
|
}
|
|
1497
|
+
interface SendSmsInput {
|
|
1498
|
+
to: string;
|
|
1499
|
+
body: string;
|
|
1500
|
+
dryRun?: boolean;
|
|
1501
|
+
}
|
|
1502
|
+
interface SendSmsResult {
|
|
1503
|
+
provider: SmsConfig['provider'];
|
|
1504
|
+
id?: string;
|
|
1505
|
+
status: string;
|
|
1506
|
+
from: string;
|
|
1507
|
+
to: string;
|
|
1508
|
+
body: string;
|
|
1509
|
+
raw?: unknown;
|
|
1510
|
+
}
|
|
1511
|
+
interface InboundSmsEvent {
|
|
1512
|
+
provider: SmsConfig['provider'];
|
|
1513
|
+
id?: string;
|
|
1514
|
+
from: string;
|
|
1515
|
+
to: string;
|
|
1516
|
+
body: string;
|
|
1517
|
+
timestamp: string;
|
|
1518
|
+
raw?: unknown;
|
|
1519
|
+
}
|
|
1520
|
+
interface SmsProvider {
|
|
1521
|
+
id: SmsConfig['provider'];
|
|
1522
|
+
sendSms(config: SmsConfig, input: SendSmsInput): Promise<SendSmsResult>;
|
|
1523
|
+
parseInboundSms(payload: Record<string, unknown>): InboundSmsEvent | null;
|
|
1524
|
+
}
|
|
1525
|
+
declare function redactSmsConfig(config: SmsConfig): SmsConfig;
|
|
1526
|
+
declare function getSmsProvider(provider: SmsConfig['provider']): SmsProvider;
|
|
1527
|
+
declare function mapProviderSmsStatus(status: string): SmsMessage['status'];
|
|
1488
1528
|
/** Normalize a phone number to E.164-ish format (+1XXXXXXXXXX) */
|
|
1489
1529
|
declare function normalizePhoneNumber(raw: string): string | null;
|
|
1490
1530
|
/** Validate a phone number (basic) */
|
|
@@ -1506,12 +1546,24 @@ declare function parseGoogleVoiceSms(emailBody: string, emailFrom: string): Pars
|
|
|
1506
1546
|
declare function extractVerificationCode(smsBody: string): string | null;
|
|
1507
1547
|
declare class SmsManager {
|
|
1508
1548
|
private db;
|
|
1549
|
+
private encryptionKey?;
|
|
1509
1550
|
private initialized;
|
|
1510
|
-
|
|
1551
|
+
/**
|
|
1552
|
+
* Optional master key used to encrypt SMS credentials at rest (same
|
|
1553
|
+
* AES-256-GCM scheme GatewayManager uses for relay/domain secrets).
|
|
1554
|
+
* When absent (e.g. tests, or a deployment with no master key) configs
|
|
1555
|
+
* are stored as-is and reads tolerate plaintext — so upgrades and
|
|
1556
|
+
* downgrades both stay safe.
|
|
1557
|
+
*/
|
|
1558
|
+
constructor(db: Database, encryptionKey?: string | undefined);
|
|
1559
|
+
/** Encrypt the credential fields of an SMS config before persisting. */
|
|
1560
|
+
private encryptConfig;
|
|
1561
|
+
/** Decrypt the credential fields of an SMS config after loading. */
|
|
1562
|
+
private decryptConfig;
|
|
1511
1563
|
private ensureTable;
|
|
1512
|
-
/** Get SMS config from agent metadata */
|
|
1564
|
+
/** Get SMS config from agent metadata (credential fields decrypted). */
|
|
1513
1565
|
getSmsConfig(agentId: string): SmsConfig | null;
|
|
1514
|
-
/** Save SMS config to agent metadata */
|
|
1566
|
+
/** Save SMS config to agent metadata (credential fields encrypted). */
|
|
1515
1567
|
saveSmsConfig(agentId: string, config: SmsConfig): void;
|
|
1516
1568
|
/**
|
|
1517
1569
|
* Resolve the operator's "where do I get pinged" address from an
|
|
@@ -1537,12 +1589,17 @@ declare class SmsManager {
|
|
|
1537
1589
|
getAlertEmail(agentId: string): string | null;
|
|
1538
1590
|
/** Remove SMS config from agent metadata */
|
|
1539
1591
|
removeSmsConfig(agentId: string): void;
|
|
1540
|
-
/**
|
|
1541
|
-
|
|
1592
|
+
/** Find the agent whose SMS config owns a phone number. */
|
|
1593
|
+
findAgentBySmsNumber(phoneNumber: string, provider?: SmsConfig['provider']): {
|
|
1594
|
+
agentId: string;
|
|
1595
|
+
config: SmsConfig;
|
|
1596
|
+
} | null;
|
|
1597
|
+
/** Record an inbound SMS (parsed from email or provider webhook) */
|
|
1598
|
+
recordInbound(agentId: string, parsed: ParsedSms, metadata?: Record<string, unknown>): SmsMessage;
|
|
1542
1599
|
/** Record an outbound SMS attempt */
|
|
1543
|
-
recordOutbound(agentId: string, phoneNumber: string, body: string, status?: 'pending' | 'sent' | 'failed'): SmsMessage;
|
|
1544
|
-
/** Update SMS status */
|
|
1545
|
-
updateStatus(id: string, status: SmsMessage['status']): void;
|
|
1600
|
+
recordOutbound(agentId: string, phoneNumber: string, body: string, status?: 'pending' | 'sent' | 'failed', metadata?: Record<string, unknown>): SmsMessage;
|
|
1601
|
+
/** Update SMS status and optional provider metadata */
|
|
1602
|
+
updateStatus(id: string, status: SmsMessage['status'], metadata?: Record<string, unknown>): void;
|
|
1546
1603
|
/** List SMS messages for an agent */
|
|
1547
1604
|
listMessages(agentId: string, opts?: {
|
|
1548
1605
|
direction?: 'inbound' | 'outbound';
|
|
@@ -1843,8 +1900,8 @@ declare function operatorPrefsStoragePath(): string;
|
|
|
1843
1900
|
*
|
|
1844
1901
|
* # What this is for
|
|
1845
1902
|
*
|
|
1846
|
-
* When a sub-agent replies into
|
|
1847
|
-
* (`claudecode@localhost` / `codex@localhost`), the dispatcher
|
|
1903
|
+
* When a sub-agent replies into a host bridge inbox
|
|
1904
|
+
* (`claudecode@localhost` / `codex@localhost` / etc.), the dispatcher
|
|
1848
1905
|
* historically had no way to react: bridges are skipped by
|
|
1849
1906
|
* `shouldWatch` because they belong to the human operator's host CLI,
|
|
1850
1907
|
* not to an automated worker. The mail would sit unread until the
|
|
@@ -1877,6 +1934,12 @@ declare function operatorPrefsStoragePath(): string;
|
|
|
1877
1934
|
* "sessionId": "019a2b3c-…",
|
|
1878
1935
|
* "workspace": "/Users/ope/Desktop/facebook-project",
|
|
1879
1936
|
* "lastSeenMs": 1778905100000
|
|
1937
|
+
* },
|
|
1938
|
+
* "openclaw": {
|
|
1939
|
+
* "sessionId": "openclaw-session-key",
|
|
1940
|
+
* "workspace": "/Users/ope/Desktop/facebook-project",
|
|
1941
|
+
* "lastSeenMs": 1778905000000,
|
|
1942
|
+
* "resumeMode": "wake"
|
|
1880
1943
|
* }
|
|
1881
1944
|
* }
|
|
1882
1945
|
* }
|
|
@@ -1907,14 +1970,24 @@ declare function operatorPrefsStoragePath(): string;
|
|
|
1907
1970
|
* that crashes the next reader. Same shape as `dispatcher-state.ts`.
|
|
1908
1971
|
*/
|
|
1909
1972
|
/** Canonical names for the host integrations that own bridge inboxes. */
|
|
1910
|
-
type HostName = 'claudecode' | 'codex';
|
|
1973
|
+
type HostName = 'claudecode' | 'codex' | 'openclaw' | 'gemini' | 'hermes';
|
|
1974
|
+
/**
|
|
1975
|
+
* How a host can be woken from a persisted session record.
|
|
1976
|
+
*
|
|
1977
|
+
* - `resume`: the host can resume a durable prior conversation/thread.
|
|
1978
|
+
* - `wake`: the host can target a live or recently known session key, but does
|
|
1979
|
+
* not guarantee full headless resume semantics.
|
|
1980
|
+
* - `wake-only`: the host can receive a wake notification, but the dispatcher
|
|
1981
|
+
* must not treat it as a resumed worker turn.
|
|
1982
|
+
*/
|
|
1983
|
+
type HostSessionResumeMode = 'resume' | 'wake' | 'wake-only';
|
|
1911
1984
|
/**
|
|
1912
1985
|
* A snapshot of one host CLI's last-known session. Persisted to disk
|
|
1913
1986
|
* by the mail-hook on every fire; loaded by the dispatcher when
|
|
1914
1987
|
* bridge mail arrives so a resume can be attempted.
|
|
1915
1988
|
*/
|
|
1916
1989
|
interface HostSession {
|
|
1917
|
-
/** Stable session_id from the host CLI
|
|
1990
|
+
/** Stable session_id/thread_id/session key from the host CLI/runtime. */
|
|
1918
1991
|
sessionId: string;
|
|
1919
1992
|
/** Wall-clock timestamp of the last hook fire on this session. */
|
|
1920
1993
|
lastSeenMs: number;
|
|
@@ -1924,6 +1997,10 @@ interface HostSession {
|
|
|
1924
1997
|
/** Optional: model name the host session was using, surfaced
|
|
1925
1998
|
* in logs for diagnostic context. */
|
|
1926
1999
|
model?: string;
|
|
2000
|
+
/** Optional: describes whether this host supports true resume or only wake. */
|
|
2001
|
+
resumeMode?: HostSessionResumeMode;
|
|
2002
|
+
/** Optional host-specific metadata. Must not contain secrets. */
|
|
2003
|
+
hostMetadata?: Record<string, unknown>;
|
|
1927
2004
|
}
|
|
1928
2005
|
/** Default freshness window — sessions older than this are skipped. */
|
|
1929
2006
|
declare const DEFAULT_SESSION_MAX_AGE_MS: number;
|
|
@@ -1961,6 +2038,38 @@ declare function forgetHostSession(host: HostName): void;
|
|
|
1961
2038
|
/** Exposed for tests + the `agenticmail status` diagnostic command. */
|
|
1962
2039
|
declare function hostSessionStoragePath(): string;
|
|
1963
2040
|
|
|
2041
|
+
type BridgeWakeError = 'session-expired' | 'sdk-missing' | 'timeout' | 'other';
|
|
2042
|
+
interface BridgeWakeResult {
|
|
2043
|
+
ok: boolean;
|
|
2044
|
+
text?: string;
|
|
2045
|
+
error?: BridgeWakeError;
|
|
2046
|
+
errorMessage?: string;
|
|
2047
|
+
durationMs?: number;
|
|
2048
|
+
}
|
|
2049
|
+
interface BridgeWakePromptArgs {
|
|
2050
|
+
bridgeName: string;
|
|
2051
|
+
uid: number;
|
|
2052
|
+
subject?: string;
|
|
2053
|
+
from?: string;
|
|
2054
|
+
preview?: string;
|
|
2055
|
+
}
|
|
2056
|
+
interface ResumeErrorClassificationOptions {
|
|
2057
|
+
expiredMarkers?: readonly string[];
|
|
2058
|
+
sdkMissingMarkers?: readonly string[];
|
|
2059
|
+
}
|
|
2060
|
+
declare const BRIDGE_OPERATOR_LIVE_WINDOW_MS = 30000;
|
|
2061
|
+
declare function bridgeWakeErrorMessage(err: unknown): string;
|
|
2062
|
+
declare function classifyResumeError(err: unknown, options?: ResumeErrorClassificationOptions): BridgeWakeError;
|
|
2063
|
+
declare function bridgeWakeLastSeenAgeMs(session: Pick<HostSession, 'lastSeenMs'> | null | undefined, nowMs?: number): number | null;
|
|
2064
|
+
declare function shouldSkipBridgeWakeForLiveOperator(session: Pick<HostSession, 'lastSeenMs'> | null | undefined, nowMs?: number, liveWindowMs?: number): boolean;
|
|
2065
|
+
/**
|
|
2066
|
+
* Build the prompt a host session sees on bridge wake. Host adapters
|
|
2067
|
+
* keep their own SDK resume call, but share this operator-facing
|
|
2068
|
+
* instruction shape so Claude Code, Codex, OpenClaw and later hosts
|
|
2069
|
+
* do not drift semantically.
|
|
2070
|
+
*/
|
|
2071
|
+
declare function composeBridgeWakePrompt(args: BridgeWakePromptArgs): string;
|
|
2072
|
+
|
|
1964
2073
|
/**
|
|
1965
2074
|
* SSRF-safe URL validation for the AgenticMail API base URL.
|
|
1966
2075
|
*
|
|
@@ -2568,4 +2677,4 @@ declare class AgentMemoryStore {
|
|
|
2568
2677
|
renderForPrompt(memory: AgentMemoryRead | null): string;
|
|
2569
2678
|
}
|
|
2570
2679
|
|
|
2571
|
-
export { AGENT_ROLES, AccountManager, type AddressInfo, type Agent, AgentDeletionService, type AgentMemoryFields, type AgentMemoryOptions, type AgentMemoryRead, AgentMemoryStore, type AgentRole, AgenticMailClient, type AgenticMailClientOptions, type AgenticMailConfig, type ArchiveAndDeleteOptions, type ArchivedEmail, type Attachment, type AttachmentAdvisory, type CachedMessage, CloudflareClient, type CreateAgentOptions, DEFAULT_AGENT_NAME, DEFAULT_AGENT_ROLE, DEFAULT_SESSION_MAX_AGE_MS, DNSConfigurator, type Database, type DeletionReport, type DeletionSummary, DependencyChecker, DependencyInstaller, type DependencyStatus, type DnsRecord, type DnsSetupResult, type DomainInfo, DomainManager, type DomainModeConfig, type DomainPurchaseResult, DomainPurchaser, type DomainSearchResult, type DomainSetupResult, type EmailEnvelope, type EmailRouteAction, type EmailRouteClass, type EmailRouteClassification, type EmailRouteInput, EmailSearchIndex, type FolderInfo, type GatewayConfig, GatewayManager, type GatewayManagerOptions, type GatewayMode, type GatewayStatus, type HostName, type HostSession, type InboundEmail, type InboxEvent, type InboxExpungeEvent, type InboxFlagsEvent, type InboxNewEvent, InboxWatcher, type InboxWatcherOptions, type InstallProgress, type LinkAdvisory, type LocalSmtpConfig, MailReceiver, type MailReceiverOptions, MailSender, type MailSenderOptions, type MailboxInfo, type OutboundCategory, type OutboundScanInput, type OutboundScanResult, type OutboundWarning, type ParsedAttachment, type ParsedEmail, type ParsedSms, PathTraversalError, type PurchasedDomain, REDACTED, RELAY_PRESETS, RelayBridge, type RelayBridgeOptions, type RelayConfig, RelayGateway, type RelayProvider, type RelaySearchResult, SPAM_THRESHOLD, type SafeJoinOptions, type SanitizeDetection, type SanitizeResult, type SearchCriteria, type SearchableEmail, type SecurityAdvisory, type SendMailOptions, type SendResult, type SendResultWithRaw, ServiceManager, type ServiceStatus, type SetupConfig, SetupManager, type SetupResult, type Severity, type SmsConfig, SmsManager, type SmsMessage, SmsPoller, type SpamCategory, type SpamResult, type SpamRuleMatch, StalwartAdmin, type StalwartAdminOptions, type StalwartPrincipal, ThreadCache, type ThreadCacheEntry, type ThreadCacheOptions, type ThreadIdInput, type TunnelConfig, TunnelManager, UnsafeApiUrlError, WARNING_THRESHOLD, type WatcherOptions, assertWithinBase, buildApiUrl, buildInboundSecurityAdvisory, classifyEmailRoute, closeDatabase, createTestDatabase, debug, debugWarn, ensureDataDir, extractVerificationCode, flushTelemetry, forgetHostSession, getDatabase, getOperatorEmail, hostSessionStoragePath, isInternalEmail, isSessionFresh, isValidPhoneNumber, loadHostSession, normalizeAddress, normalizePhoneNumber, normalizeSubject, operatorPrefsStoragePath, parseEmail, parseGoogleVoiceSms, recordToolCall, redactObject, redactSecret, resolveConfig, safeJoin, sanitizeEmail, saveConfig, saveHostSession, scanOutboundEmail, scoreEmail, setOperatorEmail, setTelemetryVersion, startRelayBridge, threadIdFor, tryJoin, validateApiUrl };
|
|
2680
|
+
export { AGENT_ROLES, AccountManager, type AddressInfo, type Agent, AgentDeletionService, type AgentMemoryFields, type AgentMemoryOptions, type AgentMemoryRead, AgentMemoryStore, type AgentRole, AgenticMailClient, type AgenticMailClientOptions, type AgenticMailConfig, type ArchiveAndDeleteOptions, type ArchivedEmail, type Attachment, type AttachmentAdvisory, BRIDGE_OPERATOR_LIVE_WINDOW_MS, type BridgeWakeError, type BridgeWakePromptArgs, type BridgeWakeResult, type CachedMessage, CloudflareClient, type CreateAgentOptions, DEFAULT_AGENT_NAME, DEFAULT_AGENT_ROLE, DEFAULT_SESSION_MAX_AGE_MS, DNSConfigurator, type Database, type DeletionReport, type DeletionSummary, DependencyChecker, DependencyInstaller, type DependencyStatus, type DnsRecord, type DnsSetupResult, type DomainInfo, DomainManager, type DomainModeConfig, type DomainPurchaseResult, DomainPurchaser, type DomainSearchResult, type DomainSetupResult, type EmailEnvelope, type EmailRouteAction, type EmailRouteClass, type EmailRouteClassification, type EmailRouteInput, EmailSearchIndex, type FolderInfo, type GatewayConfig, GatewayManager, type GatewayManagerOptions, type GatewayMode, type GatewayStatus, type HostName, type HostSession, type HostSessionResumeMode, type InboundEmail, type InboundSmsEvent, type InboxEvent, type InboxExpungeEvent, type InboxFlagsEvent, type InboxNewEvent, InboxWatcher, type InboxWatcherOptions, type InstallProgress, type LinkAdvisory, type LocalSmtpConfig, MailReceiver, type MailReceiverOptions, MailSender, type MailSenderOptions, type MailboxInfo, type OutboundCategory, type OutboundScanInput, type OutboundScanResult, type OutboundWarning, type ParsedAttachment, type ParsedEmail, type ParsedSms, PathTraversalError, type PurchasedDomain, REDACTED, RELAY_PRESETS, RelayBridge, type RelayBridgeOptions, type RelayConfig, RelayGateway, type RelayProvider, type RelaySearchResult, type ResumeErrorClassificationOptions, SPAM_THRESHOLD, type SafeJoinOptions, type SanitizeDetection, type SanitizeResult, type SearchCriteria, type SearchableEmail, type SecurityAdvisory, type SendMailOptions, type SendResult, type SendResultWithRaw, type SendSmsInput, type SendSmsResult, ServiceManager, type ServiceStatus, type SetupConfig, SetupManager, type SetupResult, type Severity, type SmsConfig, SmsManager, type SmsMessage, SmsPoller, type SmsProvider, type SpamCategory, type SpamResult, type SpamRuleMatch, StalwartAdmin, type StalwartAdminOptions, type StalwartPrincipal, ThreadCache, type ThreadCacheEntry, type ThreadCacheOptions, type ThreadIdInput, type TunnelConfig, TunnelManager, UnsafeApiUrlError, WARNING_THRESHOLD, type WatcherOptions, assertWithinBase, bridgeWakeErrorMessage, bridgeWakeLastSeenAgeMs, buildApiUrl, buildInboundSecurityAdvisory, classifyEmailRoute, classifyResumeError, closeDatabase, composeBridgeWakePrompt, createTestDatabase, debug, debugWarn, ensureDataDir, extractVerificationCode, flushTelemetry, forgetHostSession, getDatabase, getOperatorEmail, getSmsProvider, hostSessionStoragePath, isInternalEmail, isSessionFresh, isValidPhoneNumber, loadHostSession, mapProviderSmsStatus, normalizeAddress, normalizePhoneNumber, normalizeSubject, operatorPrefsStoragePath, parseEmail, parseGoogleVoiceSms, recordToolCall, redactObject, redactSecret, redactSmsConfig, resolveConfig, safeJoin, sanitizeEmail, saveConfig, saveHostSession, scanOutboundEmail, scoreEmail, setOperatorEmail, setTelemetryVersion, shouldSkipBridgeWakeForLiveOperator, startRelayBridge, threadIdFor, tryJoin, validateApiUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -481,6 +481,7 @@ interface MailSenderOptions {
|
|
|
481
481
|
password: string;
|
|
482
482
|
authUser?: string;
|
|
483
483
|
secure?: boolean;
|
|
484
|
+
tlsRejectUnauthorized?: boolean;
|
|
484
485
|
}
|
|
485
486
|
interface SendResultWithRaw extends SendResult {
|
|
486
487
|
/** Raw RFC822 message bytes (for appending to Sent folder) */
|
|
@@ -1442,13 +1443,13 @@ declare class RelayBridge {
|
|
|
1442
1443
|
declare function startRelayBridge(options: RelayBridgeOptions): RelayBridge;
|
|
1443
1444
|
|
|
1444
1445
|
/**
|
|
1445
|
-
* SMS Manager -
|
|
1446
|
+
* SMS Manager - provider-backed SMS integration
|
|
1446
1447
|
*
|
|
1447
1448
|
* How it works:
|
|
1448
|
-
* 1. User
|
|
1449
|
-
* 2.
|
|
1450
|
-
* 3.
|
|
1451
|
-
* 4.
|
|
1449
|
+
* 1. User chooses a provider for the agent phone number
|
|
1450
|
+
* 2. Google Voice uses email forwarding/web instructions
|
|
1451
|
+
* 3. 46elks uses direct API sends and inbound webhooks
|
|
1452
|
+
* 4. All inbound/outbound messages are stored in the SMS table
|
|
1452
1453
|
*
|
|
1453
1454
|
* SMS config is stored in agent metadata under the "sms" key.
|
|
1454
1455
|
*/
|
|
@@ -1456,16 +1457,24 @@ declare function startRelayBridge(options: RelayBridgeOptions): RelayBridge;
|
|
|
1456
1457
|
interface SmsConfig {
|
|
1457
1458
|
/** Whether SMS is enabled for this agent */
|
|
1458
1459
|
enabled: boolean;
|
|
1459
|
-
/**
|
|
1460
|
+
/** Phone number in E.164 format where possible */
|
|
1460
1461
|
phoneNumber: string;
|
|
1461
1462
|
/** The email address Google Voice forwards SMS to (the Gmail used for GV signup) */
|
|
1462
|
-
forwardingEmail
|
|
1463
|
+
forwardingEmail?: string;
|
|
1463
1464
|
/** App password for forwarding email (only needed if different from relay email) */
|
|
1464
1465
|
forwardingPassword?: string;
|
|
1465
1466
|
/** Whether the GV Gmail is the same as the relay email */
|
|
1466
1467
|
sameAsRelay?: boolean;
|
|
1467
|
-
/**
|
|
1468
|
-
provider: 'google_voice';
|
|
1468
|
+
/** SMS provider */
|
|
1469
|
+
provider: 'google_voice' | '46elks';
|
|
1470
|
+
/** 46elks API username */
|
|
1471
|
+
username?: string;
|
|
1472
|
+
/** 46elks API password */
|
|
1473
|
+
password?: string;
|
|
1474
|
+
/** Provider API base URL override */
|
|
1475
|
+
apiUrl?: string;
|
|
1476
|
+
/** Secret required on inbound provider webhooks */
|
|
1477
|
+
webhookSecret?: string;
|
|
1469
1478
|
/** When SMS was configured */
|
|
1470
1479
|
configuredAt: string;
|
|
1471
1480
|
}
|
|
@@ -1485,6 +1494,37 @@ interface SmsMessage {
|
|
|
1485
1494
|
createdAt: string;
|
|
1486
1495
|
metadata?: Record<string, unknown>;
|
|
1487
1496
|
}
|
|
1497
|
+
interface SendSmsInput {
|
|
1498
|
+
to: string;
|
|
1499
|
+
body: string;
|
|
1500
|
+
dryRun?: boolean;
|
|
1501
|
+
}
|
|
1502
|
+
interface SendSmsResult {
|
|
1503
|
+
provider: SmsConfig['provider'];
|
|
1504
|
+
id?: string;
|
|
1505
|
+
status: string;
|
|
1506
|
+
from: string;
|
|
1507
|
+
to: string;
|
|
1508
|
+
body: string;
|
|
1509
|
+
raw?: unknown;
|
|
1510
|
+
}
|
|
1511
|
+
interface InboundSmsEvent {
|
|
1512
|
+
provider: SmsConfig['provider'];
|
|
1513
|
+
id?: string;
|
|
1514
|
+
from: string;
|
|
1515
|
+
to: string;
|
|
1516
|
+
body: string;
|
|
1517
|
+
timestamp: string;
|
|
1518
|
+
raw?: unknown;
|
|
1519
|
+
}
|
|
1520
|
+
interface SmsProvider {
|
|
1521
|
+
id: SmsConfig['provider'];
|
|
1522
|
+
sendSms(config: SmsConfig, input: SendSmsInput): Promise<SendSmsResult>;
|
|
1523
|
+
parseInboundSms(payload: Record<string, unknown>): InboundSmsEvent | null;
|
|
1524
|
+
}
|
|
1525
|
+
declare function redactSmsConfig(config: SmsConfig): SmsConfig;
|
|
1526
|
+
declare function getSmsProvider(provider: SmsConfig['provider']): SmsProvider;
|
|
1527
|
+
declare function mapProviderSmsStatus(status: string): SmsMessage['status'];
|
|
1488
1528
|
/** Normalize a phone number to E.164-ish format (+1XXXXXXXXXX) */
|
|
1489
1529
|
declare function normalizePhoneNumber(raw: string): string | null;
|
|
1490
1530
|
/** Validate a phone number (basic) */
|
|
@@ -1506,12 +1546,24 @@ declare function parseGoogleVoiceSms(emailBody: string, emailFrom: string): Pars
|
|
|
1506
1546
|
declare function extractVerificationCode(smsBody: string): string | null;
|
|
1507
1547
|
declare class SmsManager {
|
|
1508
1548
|
private db;
|
|
1549
|
+
private encryptionKey?;
|
|
1509
1550
|
private initialized;
|
|
1510
|
-
|
|
1551
|
+
/**
|
|
1552
|
+
* Optional master key used to encrypt SMS credentials at rest (same
|
|
1553
|
+
* AES-256-GCM scheme GatewayManager uses for relay/domain secrets).
|
|
1554
|
+
* When absent (e.g. tests, or a deployment with no master key) configs
|
|
1555
|
+
* are stored as-is and reads tolerate plaintext — so upgrades and
|
|
1556
|
+
* downgrades both stay safe.
|
|
1557
|
+
*/
|
|
1558
|
+
constructor(db: Database, encryptionKey?: string | undefined);
|
|
1559
|
+
/** Encrypt the credential fields of an SMS config before persisting. */
|
|
1560
|
+
private encryptConfig;
|
|
1561
|
+
/** Decrypt the credential fields of an SMS config after loading. */
|
|
1562
|
+
private decryptConfig;
|
|
1511
1563
|
private ensureTable;
|
|
1512
|
-
/** Get SMS config from agent metadata */
|
|
1564
|
+
/** Get SMS config from agent metadata (credential fields decrypted). */
|
|
1513
1565
|
getSmsConfig(agentId: string): SmsConfig | null;
|
|
1514
|
-
/** Save SMS config to agent metadata */
|
|
1566
|
+
/** Save SMS config to agent metadata (credential fields encrypted). */
|
|
1515
1567
|
saveSmsConfig(agentId: string, config: SmsConfig): void;
|
|
1516
1568
|
/**
|
|
1517
1569
|
* Resolve the operator's "where do I get pinged" address from an
|
|
@@ -1537,12 +1589,17 @@ declare class SmsManager {
|
|
|
1537
1589
|
getAlertEmail(agentId: string): string | null;
|
|
1538
1590
|
/** Remove SMS config from agent metadata */
|
|
1539
1591
|
removeSmsConfig(agentId: string): void;
|
|
1540
|
-
/**
|
|
1541
|
-
|
|
1592
|
+
/** Find the agent whose SMS config owns a phone number. */
|
|
1593
|
+
findAgentBySmsNumber(phoneNumber: string, provider?: SmsConfig['provider']): {
|
|
1594
|
+
agentId: string;
|
|
1595
|
+
config: SmsConfig;
|
|
1596
|
+
} | null;
|
|
1597
|
+
/** Record an inbound SMS (parsed from email or provider webhook) */
|
|
1598
|
+
recordInbound(agentId: string, parsed: ParsedSms, metadata?: Record<string, unknown>): SmsMessage;
|
|
1542
1599
|
/** Record an outbound SMS attempt */
|
|
1543
|
-
recordOutbound(agentId: string, phoneNumber: string, body: string, status?: 'pending' | 'sent' | 'failed'): SmsMessage;
|
|
1544
|
-
/** Update SMS status */
|
|
1545
|
-
updateStatus(id: string, status: SmsMessage['status']): void;
|
|
1600
|
+
recordOutbound(agentId: string, phoneNumber: string, body: string, status?: 'pending' | 'sent' | 'failed', metadata?: Record<string, unknown>): SmsMessage;
|
|
1601
|
+
/** Update SMS status and optional provider metadata */
|
|
1602
|
+
updateStatus(id: string, status: SmsMessage['status'], metadata?: Record<string, unknown>): void;
|
|
1546
1603
|
/** List SMS messages for an agent */
|
|
1547
1604
|
listMessages(agentId: string, opts?: {
|
|
1548
1605
|
direction?: 'inbound' | 'outbound';
|
|
@@ -1843,8 +1900,8 @@ declare function operatorPrefsStoragePath(): string;
|
|
|
1843
1900
|
*
|
|
1844
1901
|
* # What this is for
|
|
1845
1902
|
*
|
|
1846
|
-
* When a sub-agent replies into
|
|
1847
|
-
* (`claudecode@localhost` / `codex@localhost`), the dispatcher
|
|
1903
|
+
* When a sub-agent replies into a host bridge inbox
|
|
1904
|
+
* (`claudecode@localhost` / `codex@localhost` / etc.), the dispatcher
|
|
1848
1905
|
* historically had no way to react: bridges are skipped by
|
|
1849
1906
|
* `shouldWatch` because they belong to the human operator's host CLI,
|
|
1850
1907
|
* not to an automated worker. The mail would sit unread until the
|
|
@@ -1877,6 +1934,12 @@ declare function operatorPrefsStoragePath(): string;
|
|
|
1877
1934
|
* "sessionId": "019a2b3c-…",
|
|
1878
1935
|
* "workspace": "/Users/ope/Desktop/facebook-project",
|
|
1879
1936
|
* "lastSeenMs": 1778905100000
|
|
1937
|
+
* },
|
|
1938
|
+
* "openclaw": {
|
|
1939
|
+
* "sessionId": "openclaw-session-key",
|
|
1940
|
+
* "workspace": "/Users/ope/Desktop/facebook-project",
|
|
1941
|
+
* "lastSeenMs": 1778905000000,
|
|
1942
|
+
* "resumeMode": "wake"
|
|
1880
1943
|
* }
|
|
1881
1944
|
* }
|
|
1882
1945
|
* }
|
|
@@ -1907,14 +1970,24 @@ declare function operatorPrefsStoragePath(): string;
|
|
|
1907
1970
|
* that crashes the next reader. Same shape as `dispatcher-state.ts`.
|
|
1908
1971
|
*/
|
|
1909
1972
|
/** Canonical names for the host integrations that own bridge inboxes. */
|
|
1910
|
-
type HostName = 'claudecode' | 'codex';
|
|
1973
|
+
type HostName = 'claudecode' | 'codex' | 'openclaw' | 'gemini' | 'hermes';
|
|
1974
|
+
/**
|
|
1975
|
+
* How a host can be woken from a persisted session record.
|
|
1976
|
+
*
|
|
1977
|
+
* - `resume`: the host can resume a durable prior conversation/thread.
|
|
1978
|
+
* - `wake`: the host can target a live or recently known session key, but does
|
|
1979
|
+
* not guarantee full headless resume semantics.
|
|
1980
|
+
* - `wake-only`: the host can receive a wake notification, but the dispatcher
|
|
1981
|
+
* must not treat it as a resumed worker turn.
|
|
1982
|
+
*/
|
|
1983
|
+
type HostSessionResumeMode = 'resume' | 'wake' | 'wake-only';
|
|
1911
1984
|
/**
|
|
1912
1985
|
* A snapshot of one host CLI's last-known session. Persisted to disk
|
|
1913
1986
|
* by the mail-hook on every fire; loaded by the dispatcher when
|
|
1914
1987
|
* bridge mail arrives so a resume can be attempted.
|
|
1915
1988
|
*/
|
|
1916
1989
|
interface HostSession {
|
|
1917
|
-
/** Stable session_id from the host CLI
|
|
1990
|
+
/** Stable session_id/thread_id/session key from the host CLI/runtime. */
|
|
1918
1991
|
sessionId: string;
|
|
1919
1992
|
/** Wall-clock timestamp of the last hook fire on this session. */
|
|
1920
1993
|
lastSeenMs: number;
|
|
@@ -1924,6 +1997,10 @@ interface HostSession {
|
|
|
1924
1997
|
/** Optional: model name the host session was using, surfaced
|
|
1925
1998
|
* in logs for diagnostic context. */
|
|
1926
1999
|
model?: string;
|
|
2000
|
+
/** Optional: describes whether this host supports true resume or only wake. */
|
|
2001
|
+
resumeMode?: HostSessionResumeMode;
|
|
2002
|
+
/** Optional host-specific metadata. Must not contain secrets. */
|
|
2003
|
+
hostMetadata?: Record<string, unknown>;
|
|
1927
2004
|
}
|
|
1928
2005
|
/** Default freshness window — sessions older than this are skipped. */
|
|
1929
2006
|
declare const DEFAULT_SESSION_MAX_AGE_MS: number;
|
|
@@ -1961,6 +2038,38 @@ declare function forgetHostSession(host: HostName): void;
|
|
|
1961
2038
|
/** Exposed for tests + the `agenticmail status` diagnostic command. */
|
|
1962
2039
|
declare function hostSessionStoragePath(): string;
|
|
1963
2040
|
|
|
2041
|
+
type BridgeWakeError = 'session-expired' | 'sdk-missing' | 'timeout' | 'other';
|
|
2042
|
+
interface BridgeWakeResult {
|
|
2043
|
+
ok: boolean;
|
|
2044
|
+
text?: string;
|
|
2045
|
+
error?: BridgeWakeError;
|
|
2046
|
+
errorMessage?: string;
|
|
2047
|
+
durationMs?: number;
|
|
2048
|
+
}
|
|
2049
|
+
interface BridgeWakePromptArgs {
|
|
2050
|
+
bridgeName: string;
|
|
2051
|
+
uid: number;
|
|
2052
|
+
subject?: string;
|
|
2053
|
+
from?: string;
|
|
2054
|
+
preview?: string;
|
|
2055
|
+
}
|
|
2056
|
+
interface ResumeErrorClassificationOptions {
|
|
2057
|
+
expiredMarkers?: readonly string[];
|
|
2058
|
+
sdkMissingMarkers?: readonly string[];
|
|
2059
|
+
}
|
|
2060
|
+
declare const BRIDGE_OPERATOR_LIVE_WINDOW_MS = 30000;
|
|
2061
|
+
declare function bridgeWakeErrorMessage(err: unknown): string;
|
|
2062
|
+
declare function classifyResumeError(err: unknown, options?: ResumeErrorClassificationOptions): BridgeWakeError;
|
|
2063
|
+
declare function bridgeWakeLastSeenAgeMs(session: Pick<HostSession, 'lastSeenMs'> | null | undefined, nowMs?: number): number | null;
|
|
2064
|
+
declare function shouldSkipBridgeWakeForLiveOperator(session: Pick<HostSession, 'lastSeenMs'> | null | undefined, nowMs?: number, liveWindowMs?: number): boolean;
|
|
2065
|
+
/**
|
|
2066
|
+
* Build the prompt a host session sees on bridge wake. Host adapters
|
|
2067
|
+
* keep their own SDK resume call, but share this operator-facing
|
|
2068
|
+
* instruction shape so Claude Code, Codex, OpenClaw and later hosts
|
|
2069
|
+
* do not drift semantically.
|
|
2070
|
+
*/
|
|
2071
|
+
declare function composeBridgeWakePrompt(args: BridgeWakePromptArgs): string;
|
|
2072
|
+
|
|
1964
2073
|
/**
|
|
1965
2074
|
* SSRF-safe URL validation for the AgenticMail API base URL.
|
|
1966
2075
|
*
|
|
@@ -2568,4 +2677,4 @@ declare class AgentMemoryStore {
|
|
|
2568
2677
|
renderForPrompt(memory: AgentMemoryRead | null): string;
|
|
2569
2678
|
}
|
|
2570
2679
|
|
|
2571
|
-
export { AGENT_ROLES, AccountManager, type AddressInfo, type Agent, AgentDeletionService, type AgentMemoryFields, type AgentMemoryOptions, type AgentMemoryRead, AgentMemoryStore, type AgentRole, AgenticMailClient, type AgenticMailClientOptions, type AgenticMailConfig, type ArchiveAndDeleteOptions, type ArchivedEmail, type Attachment, type AttachmentAdvisory, type CachedMessage, CloudflareClient, type CreateAgentOptions, DEFAULT_AGENT_NAME, DEFAULT_AGENT_ROLE, DEFAULT_SESSION_MAX_AGE_MS, DNSConfigurator, type Database, type DeletionReport, type DeletionSummary, DependencyChecker, DependencyInstaller, type DependencyStatus, type DnsRecord, type DnsSetupResult, type DomainInfo, DomainManager, type DomainModeConfig, type DomainPurchaseResult, DomainPurchaser, type DomainSearchResult, type DomainSetupResult, type EmailEnvelope, type EmailRouteAction, type EmailRouteClass, type EmailRouteClassification, type EmailRouteInput, EmailSearchIndex, type FolderInfo, type GatewayConfig, GatewayManager, type GatewayManagerOptions, type GatewayMode, type GatewayStatus, type HostName, type HostSession, type InboundEmail, type InboxEvent, type InboxExpungeEvent, type InboxFlagsEvent, type InboxNewEvent, InboxWatcher, type InboxWatcherOptions, type InstallProgress, type LinkAdvisory, type LocalSmtpConfig, MailReceiver, type MailReceiverOptions, MailSender, type MailSenderOptions, type MailboxInfo, type OutboundCategory, type OutboundScanInput, type OutboundScanResult, type OutboundWarning, type ParsedAttachment, type ParsedEmail, type ParsedSms, PathTraversalError, type PurchasedDomain, REDACTED, RELAY_PRESETS, RelayBridge, type RelayBridgeOptions, type RelayConfig, RelayGateway, type RelayProvider, type RelaySearchResult, SPAM_THRESHOLD, type SafeJoinOptions, type SanitizeDetection, type SanitizeResult, type SearchCriteria, type SearchableEmail, type SecurityAdvisory, type SendMailOptions, type SendResult, type SendResultWithRaw, ServiceManager, type ServiceStatus, type SetupConfig, SetupManager, type SetupResult, type Severity, type SmsConfig, SmsManager, type SmsMessage, SmsPoller, type SpamCategory, type SpamResult, type SpamRuleMatch, StalwartAdmin, type StalwartAdminOptions, type StalwartPrincipal, ThreadCache, type ThreadCacheEntry, type ThreadCacheOptions, type ThreadIdInput, type TunnelConfig, TunnelManager, UnsafeApiUrlError, WARNING_THRESHOLD, type WatcherOptions, assertWithinBase, buildApiUrl, buildInboundSecurityAdvisory, classifyEmailRoute, closeDatabase, createTestDatabase, debug, debugWarn, ensureDataDir, extractVerificationCode, flushTelemetry, forgetHostSession, getDatabase, getOperatorEmail, hostSessionStoragePath, isInternalEmail, isSessionFresh, isValidPhoneNumber, loadHostSession, normalizeAddress, normalizePhoneNumber, normalizeSubject, operatorPrefsStoragePath, parseEmail, parseGoogleVoiceSms, recordToolCall, redactObject, redactSecret, resolveConfig, safeJoin, sanitizeEmail, saveConfig, saveHostSession, scanOutboundEmail, scoreEmail, setOperatorEmail, setTelemetryVersion, startRelayBridge, threadIdFor, tryJoin, validateApiUrl };
|
|
2680
|
+
export { AGENT_ROLES, AccountManager, type AddressInfo, type Agent, AgentDeletionService, type AgentMemoryFields, type AgentMemoryOptions, type AgentMemoryRead, AgentMemoryStore, type AgentRole, AgenticMailClient, type AgenticMailClientOptions, type AgenticMailConfig, type ArchiveAndDeleteOptions, type ArchivedEmail, type Attachment, type AttachmentAdvisory, BRIDGE_OPERATOR_LIVE_WINDOW_MS, type BridgeWakeError, type BridgeWakePromptArgs, type BridgeWakeResult, type CachedMessage, CloudflareClient, type CreateAgentOptions, DEFAULT_AGENT_NAME, DEFAULT_AGENT_ROLE, DEFAULT_SESSION_MAX_AGE_MS, DNSConfigurator, type Database, type DeletionReport, type DeletionSummary, DependencyChecker, DependencyInstaller, type DependencyStatus, type DnsRecord, type DnsSetupResult, type DomainInfo, DomainManager, type DomainModeConfig, type DomainPurchaseResult, DomainPurchaser, type DomainSearchResult, type DomainSetupResult, type EmailEnvelope, type EmailRouteAction, type EmailRouteClass, type EmailRouteClassification, type EmailRouteInput, EmailSearchIndex, type FolderInfo, type GatewayConfig, GatewayManager, type GatewayManagerOptions, type GatewayMode, type GatewayStatus, type HostName, type HostSession, type HostSessionResumeMode, type InboundEmail, type InboundSmsEvent, type InboxEvent, type InboxExpungeEvent, type InboxFlagsEvent, type InboxNewEvent, InboxWatcher, type InboxWatcherOptions, type InstallProgress, type LinkAdvisory, type LocalSmtpConfig, MailReceiver, type MailReceiverOptions, MailSender, type MailSenderOptions, type MailboxInfo, type OutboundCategory, type OutboundScanInput, type OutboundScanResult, type OutboundWarning, type ParsedAttachment, type ParsedEmail, type ParsedSms, PathTraversalError, type PurchasedDomain, REDACTED, RELAY_PRESETS, RelayBridge, type RelayBridgeOptions, type RelayConfig, RelayGateway, type RelayProvider, type RelaySearchResult, type ResumeErrorClassificationOptions, SPAM_THRESHOLD, type SafeJoinOptions, type SanitizeDetection, type SanitizeResult, type SearchCriteria, type SearchableEmail, type SecurityAdvisory, type SendMailOptions, type SendResult, type SendResultWithRaw, type SendSmsInput, type SendSmsResult, ServiceManager, type ServiceStatus, type SetupConfig, SetupManager, type SetupResult, type Severity, type SmsConfig, SmsManager, type SmsMessage, SmsPoller, type SmsProvider, type SpamCategory, type SpamResult, type SpamRuleMatch, StalwartAdmin, type StalwartAdminOptions, type StalwartPrincipal, ThreadCache, type ThreadCacheEntry, type ThreadCacheOptions, type ThreadIdInput, type TunnelConfig, TunnelManager, UnsafeApiUrlError, WARNING_THRESHOLD, type WatcherOptions, assertWithinBase, bridgeWakeErrorMessage, bridgeWakeLastSeenAgeMs, buildApiUrl, buildInboundSecurityAdvisory, classifyEmailRoute, classifyResumeError, closeDatabase, composeBridgeWakePrompt, createTestDatabase, debug, debugWarn, ensureDataDir, extractVerificationCode, flushTelemetry, forgetHostSession, getDatabase, getOperatorEmail, getSmsProvider, hostSessionStoragePath, isInternalEmail, isSessionFresh, isValidPhoneNumber, loadHostSession, mapProviderSmsStatus, normalizeAddress, normalizePhoneNumber, normalizeSubject, operatorPrefsStoragePath, parseEmail, parseGoogleVoiceSms, recordToolCall, redactObject, redactSecret, redactSmsConfig, resolveConfig, safeJoin, sanitizeEmail, saveConfig, saveHostSession, scanOutboundEmail, scoreEmail, setOperatorEmail, setTelemetryVersion, shouldSkipBridgeWakeForLiveOperator, startRelayBridge, threadIdFor, tryJoin, validateApiUrl };
|