@agenticmail/core 0.9.23 → 0.9.25

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.d.ts CHANGED
@@ -2732,6 +2732,21 @@ declare const GET_DATETIME_TOOL: RealtimeToolDefinition;
2732
2732
  * opt in. Kept in the file so the tool surface is documented in one place.
2733
2733
  */
2734
2734
  declare const SEARCH_EMAIL_TOOL: RealtimeToolDefinition;
2735
+ /**
2736
+ * Phase 3 (skill library) — find the right skill playbook for the
2737
+ * situation just hit on the call. Always call BEFORE {@link LOAD_SKILL_TOOL}
2738
+ * so the loaded skill actually matches the situation. Fast (file-on-
2739
+ * disk search) — a brief "one moment" is enough; no long hold needed.
2740
+ */
2741
+ declare const SEARCH_SKILLS_TOOL: RealtimeToolDefinition;
2742
+ /**
2743
+ * Phase 3 (skill library) — load a skill playbook into the session
2744
+ * for the rest of the call. Tell the caller "hold on one moment"
2745
+ * BEFORE calling — loading involves a `session.update` round-trip.
2746
+ * Max two skills are loaded at once; a third FIFO-evicts the
2747
+ * oldest (the bridge enforces this).
2748
+ */
2749
+ declare const LOAD_SKILL_TOOL: RealtimeToolDefinition;
2735
2750
  /** Every tool defined in this module, keyed by name. */
2736
2751
  declare const REALTIME_TOOL_DEFINITIONS: Record<string, RealtimeToolDefinition>;
2737
2752
  /**
@@ -3202,6 +3217,26 @@ declare class RealtimeVoiceBridge {
3202
3217
  private readonly toolCallNames;
3203
3218
  /** `call_id`s whose tool call is currently executing. */
3204
3219
  private readonly inFlightToolCalls;
3220
+ /**
3221
+ * Mid-call skills loaded into the session so far, FIFO. Earliest at
3222
+ * index 0; cap at {@link MAX_LOADED_SKILLS}. When a (cap+1)th skill
3223
+ * is loaded the oldest one drops out — the model can't usefully
3224
+ * hold five playbooks in working memory at once, so we keep the
3225
+ * working set narrow on purpose.
3226
+ */
3227
+ private readonly loadedSkills;
3228
+ /**
3229
+ * The original `instructions` string from the session.update sent at
3230
+ * open. We keep a private copy because every mid-call skill load
3231
+ * issues a fresh `session.update` whose `instructions` is built as:
3232
+ *
3233
+ * baseInstructions + "\n\n" + renderedSkill1 + "\n\n" + renderedSkill2 …
3234
+ *
3235
+ * Without this snapshot, successive loads would compound — the second
3236
+ * load would see "base + skill1" as the base and append skill2 to
3237
+ * THAT, eventually drifting unboundedly.
3238
+ */
3239
+ private baseInstructions;
3205
3240
  constructor(opts: RealtimeVoiceBridgeOptions);
3206
3241
  /** True once the bridge has ended. */
3207
3242
  get isEnded(): boolean;
@@ -3215,6 +3250,41 @@ declare class RealtimeVoiceBridge {
3215
3250
  handleOpenAIOpen(): void;
3216
3251
  /** Call when the OpenAI socket closes. */
3217
3252
  handleOpenAIClose(): void;
3253
+ /**
3254
+ * Load a skill playbook into the live OpenAI Realtime session for
3255
+ * the rest of the call.
3256
+ *
3257
+ * Mechanics:
3258
+ * 1. Resolve the skill JSON via the skills registry (file on disk).
3259
+ * 2. Append the rendered skill text to the agent's working
3260
+ * instructions and re-send a `session.update` carrying ONLY
3261
+ * the new `instructions` field. The OpenAI Realtime API
3262
+ * supports partial session.update — we don't have to re-send
3263
+ * audio config, tools, voice, etc.
3264
+ * 3. Track which skills are loaded so we (a) FIFO-evict the
3265
+ * oldest when the cap is hit and (b) include every still-
3266
+ * loaded skill in the next composed instructions.
3267
+ * 4. Emit a transcript marker so the mission record shows the
3268
+ * adaptation ("[skill loaded: Negotiate a Bill Reduction
3269
+ * v1.0.0]"). Useful for post-call review and for the build
3270
+ * farm's telemetry on which skills actually got reached for.
3271
+ *
3272
+ * Returns an object the {@link load_skill} tool handler can serialise
3273
+ * back to the model: `ok: true` plus the skill name + version on
3274
+ * success, `ok: false` plus a short reason on failure (unknown id,
3275
+ * call ended, registry I/O error). Never throws — a buggy registry
3276
+ * or a missing file must not crash the bridge mid-call.
3277
+ *
3278
+ * Phase 2 of the skill library (`docs/skill-library-plan.md`).
3279
+ */
3280
+ loadSkillIntoSession(skillId: string): Promise<{
3281
+ ok: boolean;
3282
+ message: string;
3283
+ name?: string;
3284
+ version?: string;
3285
+ }>;
3286
+ /** The list of skills currently loaded into the session (FIFO-ordered). */
3287
+ get loadedSkillIds(): readonly string[];
3218
3288
  /** Call when the OpenAI socket errors. */
3219
3289
  handleOpenAIError(err: unknown): void;
3220
3290
  /**
@@ -5290,4 +5360,299 @@ declare class MemorySearchIndex {
5290
5360
  has(id: string): boolean;
5291
5361
  }
5292
5362
 
5293
- export { AGENT_ROLES, ASK_OPERATOR_TOOL, AccountManager, type AddressInfo, type Agent, AgentDeletionService, type AgentMemoryEntry, type AgentMemoryFields, AgentMemoryManager, type AgentMemoryOptions, type AgentMemoryRead, AgentMemoryStore, type AgentRole, AgenticMailClient, type AgenticMailClientOptions, type AgenticMailConfig, type ArchiveAndDeleteOptions, type ArchivedEmail, type Attachment, type AttachmentAdvisory, type AudioAction, type AudioEditOptions, BRIDGE_OPERATOR_LIVE_WINDOW_MS, type BridgeMailContext, type BridgeWakeError, type BridgeWakePromptArgs, type BridgeWakeResult, type BridgeWakeRoute, type CachedMessage, CloudflareClient, type CreateAgentOptions, type CreateMemoryInput, DEFAULT_AGENT_NAME, DEFAULT_AGENT_ROLE, DEFAULT_REALTIME_AUDIO_FORMAT, DEFAULT_REALTIME_MODEL, DEFAULT_REALTIME_VOICE, DEFAULT_SESSION_MAX_AGE_MS, DEFAULT_WEB_SEARCH_ENDPOINT, 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, ELKS_REALTIME_AUDIO_FORMATS, ELKS_REALTIME_WS_PATH, type ElksRealtimeAudioFormat, type ElksRealtimeAudioMessage, type ElksRealtimeByeMessage, type ElksRealtimeHelloMessage, type ElksRealtimeInboundMessage, type ElksRealtimeOutboundMessage, ElksRealtimeTransport, type EmailEnvelope, type EmailRouteAction, type EmailRouteClass, type EmailRouteClassification, type EmailRouteInput, EmailSearchIndex, type FolderInfo, GET_DATETIME_TOOL, type GatewayConfig, GatewayManager, type GatewayManagerOptions, type GatewayMode, type GatewayStatus, type GetDatetimeOptions, type GetUpdatesOptions, type HostName, type HostSession, type HostSessionResumeMode, type ImageAction, type ImageEditOptions, type InboundEmail, type InboundSmsEvent, type InboxEvent, type InboxExpungeEvent, type InboxFlagsEvent, type InboxNewEvent, InboxWatcher, type InboxWatcherOptions, type InstallProgress, type LinkAdvisory, type LocalSmtpConfig, MEMORY_CATEGORIES, MailReceiver, type MailReceiverOptions, MailSender, type MailSenderOptions, type MailboxInfo, type MediaBinary, type MediaCapability, type MediaCapabilityReport, type MediaFileResult, type MediaInfoResult, MediaManager, type MediaManagerOptions, type MediaStreamInfo, type MemoryCategory, type MemoryImportance, type MemoryQueryOptions, type MemoryRecaller, MemorySearchIndex, type MemorySource, type MemoryStats, OPENAI_REALTIME_URL, OPERATOR_QUERY_POLL_INTERVAL_MS, OPERATOR_QUERY_SUBJECT_TAG, OPERATOR_QUERY_TIMEOUT_MS, OPERATOR_QUERY_TIMEOUT_SENTINEL, type OpenClawPhoneMissionPolicy, type OperatorQueryNotificationInput, type OperatorQueryPollOptions, type OperatorQueryUrgency, type OperatorReplyKind, type OutboundCategory, type OutboundScanInput, type OutboundScanResult, type OutboundWarning, PHONE_CALL_CONTROL_PROVIDERS, PHONE_MAX_CONCURRENT_MISSIONS, PHONE_MIN_WEBHOOK_SECRET_LENGTH, PHONE_MISSION_STATES, PHONE_RATE_LIMIT_PER_HOUR, PHONE_RATE_LIMIT_PER_MINUTE, PHONE_REGION_SCOPES, PHONE_SERVER_MAX_ATTEMPTS, PHONE_SERVER_MAX_CALL_DURATION_SECONDS, PHONE_SERVER_MAX_COST_PER_MISSION, PHONE_TASK_MAX_LENGTH, type ParsedAttachment, type ParsedEmail, type ParsedOperatorReply, type ParsedSms, type ParsedTelegramMessage, PathTraversalError, type PhoneAlternativePolicy, type PhoneCallMission, type PhoneConfirmPolicy, PhoneManager, type PhoneMissionStartValidationResult, type PhoneMissionState, type PhoneMissionTranscriptEntry, type PhoneMissionValidationIssue, type PhoneMissionValidationResult, type PhoneNumberRisk, type PhoneOperatorQuery, PhoneRateLimitError, type PhoneRegionScope, type PhoneTransportConfig, type PhoneTransportProfile, type PhoneTransportProvider, type PhoneTransportValidationResult, PhoneWebhookAuthError, type PhoneWebhookResult, type PlanBridgeWakeArgs, type PurchasedDomain, REALTIME_AUDIO_SAMPLE_RATE, REALTIME_MAX_AUDIO_FRAME_BASE64, REALTIME_TOOL_CALL_TIMEOUT_MS, REALTIME_TOOL_DEFINITIONS, RECALL_MEMORY_TOOL, REDACTED, RELAY_PRESETS, type RealtimeBridgePort, type RealtimeBridgeTranscriptEntry, type RealtimeInboundEvent, type RealtimeInstructionOptions, type RealtimeSessionConfigOptions, type RealtimeToolCall, type RealtimeToolDefinition, type RealtimeToolHandler, type RealtimeToolResult, type RealtimeTransportAdapter, type RealtimeTransportProvider, RealtimeVoiceBridge, type RealtimeVoiceBridgeOptions, RelayBridge, type RelayBridgeOptions, type RelayConfig, RelayGateway, type RelayProvider, type RelaySearchResult, type ResumeErrorClassificationOptions, SEARCH_EMAIL_TOOL, SPAM_THRESHOLD, type SafeJoinOptions, type SanitizeDetection, type SanitizeResult, type SearchCriteria, type SearchableEmail, type SecurityAdvisory, type SendMailOptions, type SendResult, type SendResultWithRaw, type SendSmsInput, type SendSmsResult, type SendTelegramMessageOptions, type SendTelegramMessageResult, ServiceManager, type ServiceStatus, type SetWebhookOptions, 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, type StartPhoneCallOptions, type StartPhoneCallResult, type StartPhoneMissionInput, TELEGRAM_API_BASE, TELEGRAM_CHUNK_SIZE, TELEGRAM_MESSAGE_LIMIT, TELEGRAM_MIN_WEBHOOK_SECRET_LENGTH, TELEGRAM_OPERATOR_QUERY_TAG, TELEGRAM_STOP_WORDS, TELEGRAM_WEBHOOK_SECRET_RE, TELEPHONY_TRANSPORT_CAPABILITIES, TWILIO_MEDIA_SAMPLE_RATE, TWILIO_REALTIME_WS_PATH, TelegramApiError, type TelegramApiOptions, type TelegramBotInfo, type TelegramChatType, type TelegramConfig, TelegramManager, type TelegramMessage, type TelegramMode, type TelephonyTransportCapability, ThreadCache, type ThreadCacheEntry, type ThreadCacheOptions, type ThreadIdInput, type ToolExecutor, type TtsGenerateOptions, type TunnelConfig, TunnelManager, type TwilioConnectedMessage, type TwilioMarkMessage, type TwilioMediaMessage, type TwilioRealtimeInboundMessage, type TwilioRealtimeOutboundMessage, TwilioRealtimeTransport, type TwilioStartMessage, type TwilioStopMessage, type TwilioStreamTwiMLOptions, UnsafeApiUrlError, type UpdateMemoryInput, type ValidatedPhoneMissionStart, type VideoAction, type VideoEditOptions, type VideoTimelineEntry, type VideoUnderstandOptions, type VideoUnderstandResult, type VoiceCloneOptions, WARNING_THRESHOLD, WEB_SEARCH_TOOL, WEB_SEARCH_UNTRUSTED_PREFIX, type WatcherOptions, type WebSearchOptions, assertWithinBase, bridgeWakeErrorMessage, bridgeWakeLastSeenAgeMs, buildApiUrl, buildElksAudioMessage, buildElksByeMessage, buildElksHandshakeMessages, buildElksInterruptMessage, buildElksListeningMessage, buildElksSendingMessage, buildInboundSecurityAdvisory, buildOpenAIRealtimeUrl, buildPhoneTransportConfig, buildRealtimeInstructions, buildRealtimeSessionConfig, buildRealtimeToolGuidance, buildTwilioClearMessage, buildTwilioMarkMessage, buildTwilioMediaMessage, buildTwilioSayTwiML, buildTwilioSignature, buildTwilioStreamTwiML, callTelegramApi, classifyEmailRoute, classifyPhoneNumberRisk, classifyResumeError, clearMediaCapabilityCache, closeDatabase, composeBridgeWakePrompt, createRealtimeTransport, createTestDatabase, createToolExecutor, debug, debugWarn, deleteTelegramWebhook, detectBinary, ensureDataDir, escapeXml, extractEmailAddress, extractVerificationCode, flushTelemetry, forgetHostSession, formatOperatorQueryTelegramMessage, getDatabase, getDatetime, getMediaCapabilities, getOperatorEmail, getSmsProvider, getTelegramChat, getTelegramMe, getTelegramUpdates, getTelegramWebhookInfo, hostSessionStoragePath, inferPhoneRegion, isInternalEmail, isLoopbackMailHost, isOperatorReplySender, isPhoneRegionAllowed, isSessionFresh, isTelegramChatAllowed, isTelegramStopCommand, isValidPhoneNumber, loadHostSession, mapProviderSmsStatus, nextTelegramOffset, normalizeAddress, normalizePhoneNumber, normalizeSubject, operatorPrefsStoragePath, operatorQuerySubject, parseElksRealtimeMessage, parseEmail, parseGoogleVoiceSms, parseOperatorQueryReply, parseTelegramOperatorReply, parseTelegramUpdate, parseTwilioRealtimeMessage, planBridgeWake, pollForOperatorAnswer, recallMemory, recordToolCall, redactBotToken, redactObject, redactPhoneTransportConfig, redactSecret, redactSmsConfig, redactTelegramConfig, requireBinary, requireWhisperModel, resolveConfig, resolveTlsRejectUnauthorized, safeJoin, sanitizeEmail, saveConfig, saveHostSession, scanOutboundEmail, scoreEmail, sendTelegramMessage, setOperatorEmail, setTelegramWebhook, setTelemetryVersion, shouldSkipBridgeWakeForLiveOperator, splitTelegramMessage, startRelayBridge, stem, stripTelegramMarkdown, threadIdFor, tokenize, tryJoin, validateApiUrl, validatePhoneMissionPolicy, validatePhoneMissionStart, validatePhoneTransportProfile, validateTwilioSignature, webSearch };
5363
+ /**
5364
+ * AgenticMail skill library — types.
5365
+ *
5366
+ * A "skill" is a structured how-to-act-like-a-skilled-human bundle for
5367
+ * a single real-world task an agent might be asked to do: negotiate a
5368
+ * bill, book a reservation, handle a debt collector, escalate to a
5369
+ * supervisor. Each skill is a JSON document with a fixed schema (this
5370
+ * file) so agents can load them on demand AND so humans / other agents
5371
+ * can contribute new ones without writing TypeScript.
5372
+ *
5373
+ * The skill schema is deliberately verbose. A skill that an agent
5374
+ * loads mid-call into its system prompt needs to teach it everything
5375
+ * a human would intuitively know: what to open with, what objections
5376
+ * to expect, how to phrase a graceful concession, when to walk away.
5377
+ * Sparse skills ("just be assertive") do not actually transfer
5378
+ * competence to a language model that has never made the call before.
5379
+ *
5380
+ * Why JSON, not Markdown / Python / a DSL:
5381
+ * - Stable, language-agnostic — community contributions can come
5382
+ * from anyone with a text editor; the schema validates and rejects
5383
+ * malformed contributions on PR.
5384
+ * - Embeddable in a Realtime API session.update — the JSON shape can
5385
+ * be rendered into a single `instructions` block at load time.
5386
+ * - Diffable on GitHub — reviewers can see exactly what changed,
5387
+ * phrase-by-phrase, in a PR.
5388
+ * - Searchable — registry-level fuzzy match on name / description /
5389
+ * tags / phrase contents works without any extra index layer.
5390
+ *
5391
+ * The schema is intentionally open to extension: every object has an
5392
+ * optional `extra: Record<string, unknown>` escape hatch so a
5393
+ * contributor can attach domain-specific fields without waiting for a
5394
+ * core schema bump. The MCP `skill_load` tool returns the raw object,
5395
+ * so an agent that recognises the extension can use it directly.
5396
+ */
5397
+ /** Wire-format JSON skill — the on-disk file shape. */
5398
+ interface Skill {
5399
+ /**
5400
+ * Globally-unique slug. Lowercase, hyphenated, no spaces.
5401
+ * Convention: `<verb>-<noun>` (`negotiate-bill-reduction`,
5402
+ * `book-restaurant-reservation`). Used as the `skill_load` argument
5403
+ * and as the JSON filename (`<id>.json`).
5404
+ */
5405
+ id: string;
5406
+ /** Human-readable title, sentence case. */
5407
+ name: string;
5408
+ /**
5409
+ * Semver. Bumped when the skill changes materially (new tactic
5410
+ * added, deprecation, etc). Agents that loaded an older version
5411
+ * mid-call keep their copy — versioning is for the registry, not
5412
+ * the in-flight session.
5413
+ */
5414
+ version: string;
5415
+ /**
5416
+ * Coarse-grained category. Keep this list short and stable; tags
5417
+ * are where the long tail lives.
5418
+ */
5419
+ category: SkillCategory;
5420
+ /** Free-form lowercase tags for search. */
5421
+ tags: string[];
5422
+ /**
5423
+ * One-sentence summary used in search results + the `skill_list`
5424
+ * tool's response. The first 80 characters are what an agent sees
5425
+ * when deciding whether to load the full skill.
5426
+ */
5427
+ description: string;
5428
+ /**
5429
+ * REQUIRED legal / safety disclaimer the agent must recite to the
5430
+ * other party at the start of the call when this skill is loaded.
5431
+ * Set to `null` for skills that need no disclaimer; set to a
5432
+ * literal string for skills with legal / medical / financial
5433
+ * sensitivity (debt collection, court representation, medical
5434
+ * triage). The agent's system prompt is updated to make this
5435
+ * disclaimer mandatory before any substantive turn.
5436
+ */
5437
+ disclaimer: string | null;
5438
+ /** When + why to reach for this skill. */
5439
+ context: SkillContext;
5440
+ /**
5441
+ * Three to seven principles the agent should internalise. These
5442
+ * are the strategic frame — concrete phrasing lives in `phrases`
5443
+ * and `tactics`. Mirror the kind of advice a friend who's GOOD at
5444
+ * this thing would give you in a 30-second pep talk.
5445
+ */
5446
+ principles: string[];
5447
+ /**
5448
+ * Named scripted phrases. Keys are stable identifiers
5449
+ * (`opener`, `objection_no_discounts`, `stall_thinking`) so a
5450
+ * tactic can reference a phrase by key.
5451
+ */
5452
+ phrases: Record<string, string>;
5453
+ /**
5454
+ * Ordered list of specific moves to attempt, with their preconditions
5455
+ * and scripts. Agents should try tactics in order, falling back to
5456
+ * the next when the previous fails.
5457
+ */
5458
+ tactics: SkillTactic[];
5459
+ /**
5460
+ * Hard rules the agent must NOT cross. These are checked at every
5461
+ * turn — if the agent is about to violate one, it should pull
5462
+ * back, possibly via `ask_operator`. Examples: don't lie about
5463
+ * the user's situation, don't commit money on the user's behalf
5464
+ * without confirmation, don't be abusive.
5465
+ */
5466
+ boundaries: string[];
5467
+ /** Signs the call is going well — keep doing what's working. */
5468
+ success_signals: string[];
5469
+ /** Signs the call is going badly — escalate or exit. */
5470
+ failure_signals: string[];
5471
+ /** How to end the call. Almost always invoked; design carefully. */
5472
+ exit_strategy: SkillExitStrategy;
5473
+ /**
5474
+ * Information the agent needs from the operator (via task brief or
5475
+ * `ask_operator` mid-call) BEFORE it can use this skill effectively.
5476
+ * Used by the mission planner to flag missing context up front.
5477
+ */
5478
+ required_user_info: string[];
5479
+ /** Free-form attribution: name or handle of the contributor. */
5480
+ contributed_by: string;
5481
+ /** ISO 8601. Set by the registry on first load if absent. */
5482
+ created_at?: string;
5483
+ /** ISO 8601. Bumped on every JSON edit. */
5484
+ updated_at?: string;
5485
+ /**
5486
+ * Forward-compatible extension hatch. Domain-specific fields a
5487
+ * contributor wants to attach without a core schema bump live
5488
+ * here. Agents that recognise the extension key use it; others
5489
+ * ignore it. Example: `extra.compliance_jurisdiction: 'US'`.
5490
+ */
5491
+ extra?: Record<string, unknown>;
5492
+ }
5493
+ /** Coarse-grained taxonomy. Extend ONLY via PR + a reviewer's nod. */
5494
+ type SkillCategory = 'negotiation' | 'customer-service' | 'reservations' | 'medical-admin' | 'legal-admin' | 'finance-admin' | 'real-estate' | 'travel' | 'subscription' | 'home-services' | 'social' | 'civic' | 'employment' | 'debt-collection' | 'other';
5495
+ /** When-to-use + preconditions block. */
5496
+ interface SkillContext {
5497
+ /** Plain-language description of the situation this skill fits. */
5498
+ when_to_use: string;
5499
+ /** What must be true before the agent picks up the phone. */
5500
+ preconditions: string[];
5501
+ /**
5502
+ * Realistic typical duration. Used to set the mission's
5503
+ * `maxCallDurationSeconds` policy automatically if not overridden.
5504
+ */
5505
+ estimated_call_duration_minutes: number;
5506
+ }
5507
+ /** A single move the agent can try. */
5508
+ interface SkillTactic {
5509
+ name: string;
5510
+ /** When to deploy this tactic. */
5511
+ when: string;
5512
+ /**
5513
+ * Verbatim script. The agent paraphrases to match its voice but
5514
+ * keeps the structural moves (mirror, ask for retention, etc).
5515
+ */
5516
+ script: string;
5517
+ /**
5518
+ * Optional priority order (1 = try first). Defaults to array order.
5519
+ * Lower-priority tactics are fallbacks.
5520
+ */
5521
+ priority?: number;
5522
+ }
5523
+ /** How to wrap the call up. Different ending for success vs failure. */
5524
+ interface SkillExitStrategy {
5525
+ /** What to do / say when the call hit its goal. */
5526
+ on_success: string;
5527
+ /** What to do / say when the goal isn't reachable on this call. */
5528
+ on_failure: string;
5529
+ /**
5530
+ * Optional follow-ups for the operator after the call ends —
5531
+ * tasks like "email the rep's confirmation number" or "calendar a
5532
+ * 30-day check-back". The mission report includes these.
5533
+ */
5534
+ follow_ups?: string[];
5535
+ }
5536
+ /** Skill summary returned by `skill_list` / `skill_search` (no body). */
5537
+ interface SkillSummary {
5538
+ id: string;
5539
+ name: string;
5540
+ category: SkillCategory;
5541
+ tags: string[];
5542
+ description: string;
5543
+ version: string;
5544
+ disclaimer_required: boolean;
5545
+ estimated_call_duration_minutes: number;
5546
+ }
5547
+ /** Failed-validation result from the schema validator. */
5548
+ interface SkillValidationError {
5549
+ path: string;
5550
+ message: string;
5551
+ }
5552
+
5553
+ /**
5554
+ * Skill registry — load, search, validate, list.
5555
+ *
5556
+ * Skills live in two places:
5557
+ *
5558
+ * 1. **Built-in** — JSON files bundled with `@agenticmail/core` at
5559
+ * `packages/core/src/skills/built-in/*.json`. These ship with
5560
+ * every install and form the starter library. Editing one in
5561
+ * a fork is fine, but the canonical copy is the one in the
5562
+ * monorepo — PRs to add or refine built-in skills are the
5563
+ * community contribution path.
5564
+ *
5565
+ * 2. **User-contributed** — JSON files dropped into
5566
+ * `~/.agenticmail/skills/*.json` at runtime. The registry
5567
+ * scans this directory on every `list` / `search` / `load`
5568
+ * call (cached for a few seconds) so a user can add a skill
5569
+ * without restarting the server. User-contributed skills
5570
+ * override built-ins when their `id` collides.
5571
+ *
5572
+ * The registry is filesystem-only — no DB. A skill is a leaf JSON
5573
+ * file, easy to diff in git, easy to write by hand. Loading skills
5574
+ * directly from `~/.agenticmail/skills/` (no manifest, no
5575
+ * `enabled: true`) is deliberate: the simplest contribution path
5576
+ * is "drop the file in, that's it."
5577
+ */
5578
+
5579
+ /** Manual cache invalidation — useful for tests + after a write. */
5580
+ declare function invalidateSkillCache(): void;
5581
+ /**
5582
+ * Schema validator. Returns a list of (path, message) — empty list
5583
+ * means the skill is structurally valid. Catches the classes of
5584
+ * mistakes a contributor is most likely to make:
5585
+ *
5586
+ * - Missing top-level required fields.
5587
+ * - Wrong types (`tactics` as object instead of array).
5588
+ * - Empty arrays where a non-empty one is required.
5589
+ * - Invalid `category` value.
5590
+ * - Tactic with empty `script`.
5591
+ *
5592
+ * Intentionally NOT a full JSON-schema implementation — the cost of
5593
+ * a dependency on `ajv` or similar isn't justified for our shape.
5594
+ */
5595
+ declare function validateSkill(s: unknown): SkillValidationError[];
5596
+ /** List all skills (summaries), optionally filtered. */
5597
+ declare function listSkills(opts?: {
5598
+ category?: SkillCategory;
5599
+ tag?: string;
5600
+ }): SkillSummary[];
5601
+ /**
5602
+ * Search skills by free-text query, ranked by BM25F.
5603
+ *
5604
+ * Uses {@link MemorySearchIndex} — the same scorer that powers
5605
+ * persistent agent memory. Field weighting puts name (title 3×) and
5606
+ * tags (2×) above body content (1×), so an exact-name hit always beats
5607
+ * a phrase-body match. Inverted posting lists mean scoring only touches
5608
+ * docs that share at least one stem with the query — search cost grows
5609
+ * with matches, not corpus size, so a 1,000-skill library scores in
5610
+ * the same sub-millisecond range as a 10-skill one.
5611
+ *
5612
+ * Two behaviours worth knowing:
5613
+ *
5614
+ * - **Stemming + stop-word removal.** "negotiating", "negotiate",
5615
+ * and "negotiation" all match the same skills. "the", "a", "for"
5616
+ * are dropped from the query.
5617
+ * - **Empty / no-match queries return an empty list**, not the full
5618
+ * library. The model should call `skill_list` if it wants
5619
+ * everything; `skill_search` is for "did anything match?".
5620
+ *
5621
+ * If the BM25F search returns nothing (typo, very rare phrase), we
5622
+ * fall back to a tiny linear scan that catches substring hits the
5623
+ * stemmer might have missed. Keeps the search forgiving without
5624
+ * making the fast path slow.
5625
+ */
5626
+ declare function searchSkills(query: string, limit?: number): SkillSummary[];
5627
+ /** Load the FULL skill body (everything an agent needs to act on it). */
5628
+ declare function loadSkill(id: string): Skill | null;
5629
+ /**
5630
+ * Save a new or updated skill to `~/.agenticmail/skills/<id>.json`.
5631
+ * Validates first; throws on invalid input. Bumps `updated_at`.
5632
+ *
5633
+ * Used by `agenticmail skill add` and by the future "build farm"
5634
+ * agents that draft skills programmatically — the same path either
5635
+ * way.
5636
+ */
5637
+ declare function saveUserSkill(skill: Skill): {
5638
+ path: string;
5639
+ };
5640
+ /** Where the user library lives (for surfacing in error messages / help). */
5641
+ declare function userSkillsDir(): string;
5642
+
5643
+ /**
5644
+ * Render a loaded skill into a single block of text suitable for
5645
+ * injection into an OpenAI Realtime `session.update.instructions`
5646
+ * (or any other plain-text system-prompt slot). The rendering is
5647
+ * intentionally verbose — language models perform best when the
5648
+ * tactical knowledge is spelled out narrative-style, not as a
5649
+ * skeletal outline.
5650
+ *
5651
+ * Convention: every rendered skill starts with a marker so the
5652
+ * agent can recognise it's operating with a loaded skill, and
5653
+ * ends with a separator so additional skills (loaded later in the
5654
+ * call) can be concatenated without ambiguity.
5655
+ */
5656
+ declare function renderSkillAsPrompt(skill: Skill): string;
5657
+
5658
+ export { AGENT_ROLES, ASK_OPERATOR_TOOL, AccountManager, type AddressInfo, type Agent, AgentDeletionService, type AgentMemoryEntry, type AgentMemoryFields, AgentMemoryManager, type AgentMemoryOptions, type AgentMemoryRead, AgentMemoryStore, type AgentRole, AgenticMailClient, type AgenticMailClientOptions, type AgenticMailConfig, type ArchiveAndDeleteOptions, type ArchivedEmail, type Attachment, type AttachmentAdvisory, type AudioAction, type AudioEditOptions, BRIDGE_OPERATOR_LIVE_WINDOW_MS, type BridgeMailContext, type BridgeWakeError, type BridgeWakePromptArgs, type BridgeWakeResult, type BridgeWakeRoute, type CachedMessage, CloudflareClient, type CreateAgentOptions, type CreateMemoryInput, DEFAULT_AGENT_NAME, DEFAULT_AGENT_ROLE, DEFAULT_REALTIME_AUDIO_FORMAT, DEFAULT_REALTIME_MODEL, DEFAULT_REALTIME_VOICE, DEFAULT_SESSION_MAX_AGE_MS, DEFAULT_WEB_SEARCH_ENDPOINT, 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, ELKS_REALTIME_AUDIO_FORMATS, ELKS_REALTIME_WS_PATH, type ElksRealtimeAudioFormat, type ElksRealtimeAudioMessage, type ElksRealtimeByeMessage, type ElksRealtimeHelloMessage, type ElksRealtimeInboundMessage, type ElksRealtimeOutboundMessage, ElksRealtimeTransport, type EmailEnvelope, type EmailRouteAction, type EmailRouteClass, type EmailRouteClassification, type EmailRouteInput, EmailSearchIndex, type FolderInfo, GET_DATETIME_TOOL, type GatewayConfig, GatewayManager, type GatewayManagerOptions, type GatewayMode, type GatewayStatus, type GetDatetimeOptions, type GetUpdatesOptions, type HostName, type HostSession, type HostSessionResumeMode, type ImageAction, type ImageEditOptions, type InboundEmail, type InboundSmsEvent, type InboxEvent, type InboxExpungeEvent, type InboxFlagsEvent, type InboxNewEvent, InboxWatcher, type InboxWatcherOptions, type InstallProgress, LOAD_SKILL_TOOL, type LinkAdvisory, type LocalSmtpConfig, MEMORY_CATEGORIES, MailReceiver, type MailReceiverOptions, MailSender, type MailSenderOptions, type MailboxInfo, type MediaBinary, type MediaCapability, type MediaCapabilityReport, type MediaFileResult, type MediaInfoResult, MediaManager, type MediaManagerOptions, type MediaStreamInfo, type MemoryCategory, type MemoryImportance, type MemoryQueryOptions, type MemoryRecaller, MemorySearchIndex, type MemorySource, type MemoryStats, OPENAI_REALTIME_URL, OPERATOR_QUERY_POLL_INTERVAL_MS, OPERATOR_QUERY_SUBJECT_TAG, OPERATOR_QUERY_TIMEOUT_MS, OPERATOR_QUERY_TIMEOUT_SENTINEL, type OpenClawPhoneMissionPolicy, type OperatorQueryNotificationInput, type OperatorQueryPollOptions, type OperatorQueryUrgency, type OperatorReplyKind, type OutboundCategory, type OutboundScanInput, type OutboundScanResult, type OutboundWarning, PHONE_CALL_CONTROL_PROVIDERS, PHONE_MAX_CONCURRENT_MISSIONS, PHONE_MIN_WEBHOOK_SECRET_LENGTH, PHONE_MISSION_STATES, PHONE_RATE_LIMIT_PER_HOUR, PHONE_RATE_LIMIT_PER_MINUTE, PHONE_REGION_SCOPES, PHONE_SERVER_MAX_ATTEMPTS, PHONE_SERVER_MAX_CALL_DURATION_SECONDS, PHONE_SERVER_MAX_COST_PER_MISSION, PHONE_TASK_MAX_LENGTH, type ParsedAttachment, type ParsedEmail, type ParsedOperatorReply, type ParsedSms, type ParsedTelegramMessage, PathTraversalError, type PhoneAlternativePolicy, type PhoneCallMission, type PhoneConfirmPolicy, PhoneManager, type PhoneMissionStartValidationResult, type PhoneMissionState, type PhoneMissionTranscriptEntry, type PhoneMissionValidationIssue, type PhoneMissionValidationResult, type PhoneNumberRisk, type PhoneOperatorQuery, PhoneRateLimitError, type PhoneRegionScope, type PhoneTransportConfig, type PhoneTransportProfile, type PhoneTransportProvider, type PhoneTransportValidationResult, PhoneWebhookAuthError, type PhoneWebhookResult, type PlanBridgeWakeArgs, type PurchasedDomain, REALTIME_AUDIO_SAMPLE_RATE, REALTIME_MAX_AUDIO_FRAME_BASE64, REALTIME_TOOL_CALL_TIMEOUT_MS, REALTIME_TOOL_DEFINITIONS, RECALL_MEMORY_TOOL, REDACTED, RELAY_PRESETS, type RealtimeBridgePort, type RealtimeBridgeTranscriptEntry, type RealtimeInboundEvent, type RealtimeInstructionOptions, type RealtimeSessionConfigOptions, type RealtimeToolCall, type RealtimeToolDefinition, type RealtimeToolHandler, type RealtimeToolResult, type RealtimeTransportAdapter, type RealtimeTransportProvider, RealtimeVoiceBridge, type RealtimeVoiceBridgeOptions, RelayBridge, type RelayBridgeOptions, type RelayConfig, RelayGateway, type RelayProvider, type RelaySearchResult, type ResumeErrorClassificationOptions, SEARCH_EMAIL_TOOL, SEARCH_SKILLS_TOOL, SPAM_THRESHOLD, type SafeJoinOptions, type SanitizeDetection, type SanitizeResult, type SearchCriteria, type SearchableEmail, type SecurityAdvisory, type SendMailOptions, type SendResult, type SendResultWithRaw, type SendSmsInput, type SendSmsResult, type SendTelegramMessageOptions, type SendTelegramMessageResult, ServiceManager, type ServiceStatus, type SetWebhookOptions, type SetupConfig, SetupManager, type SetupResult, type Severity, type Skill, type SkillCategory, type SkillContext, type SkillExitStrategy, type SkillSummary, type SkillTactic, type SkillValidationError, type SmsConfig, SmsManager, type SmsMessage, SmsPoller, type SmsProvider, type SpamCategory, type SpamResult, type SpamRuleMatch, StalwartAdmin, type StalwartAdminOptions, type StalwartPrincipal, type StartPhoneCallOptions, type StartPhoneCallResult, type StartPhoneMissionInput, TELEGRAM_API_BASE, TELEGRAM_CHUNK_SIZE, TELEGRAM_MESSAGE_LIMIT, TELEGRAM_MIN_WEBHOOK_SECRET_LENGTH, TELEGRAM_OPERATOR_QUERY_TAG, TELEGRAM_STOP_WORDS, TELEGRAM_WEBHOOK_SECRET_RE, TELEPHONY_TRANSPORT_CAPABILITIES, TWILIO_MEDIA_SAMPLE_RATE, TWILIO_REALTIME_WS_PATH, TelegramApiError, type TelegramApiOptions, type TelegramBotInfo, type TelegramChatType, type TelegramConfig, TelegramManager, type TelegramMessage, type TelegramMode, type TelephonyTransportCapability, ThreadCache, type ThreadCacheEntry, type ThreadCacheOptions, type ThreadIdInput, type ToolExecutor, type TtsGenerateOptions, type TunnelConfig, TunnelManager, type TwilioConnectedMessage, type TwilioMarkMessage, type TwilioMediaMessage, type TwilioRealtimeInboundMessage, type TwilioRealtimeOutboundMessage, TwilioRealtimeTransport, type TwilioStartMessage, type TwilioStopMessage, type TwilioStreamTwiMLOptions, UnsafeApiUrlError, type UpdateMemoryInput, type ValidatedPhoneMissionStart, type VideoAction, type VideoEditOptions, type VideoTimelineEntry, type VideoUnderstandOptions, type VideoUnderstandResult, type VoiceCloneOptions, WARNING_THRESHOLD, WEB_SEARCH_TOOL, WEB_SEARCH_UNTRUSTED_PREFIX, type WatcherOptions, type WebSearchOptions, assertWithinBase, bridgeWakeErrorMessage, bridgeWakeLastSeenAgeMs, buildApiUrl, buildElksAudioMessage, buildElksByeMessage, buildElksHandshakeMessages, buildElksInterruptMessage, buildElksListeningMessage, buildElksSendingMessage, buildInboundSecurityAdvisory, buildOpenAIRealtimeUrl, buildPhoneTransportConfig, buildRealtimeInstructions, buildRealtimeSessionConfig, buildRealtimeToolGuidance, buildTwilioClearMessage, buildTwilioMarkMessage, buildTwilioMediaMessage, buildTwilioSayTwiML, buildTwilioSignature, buildTwilioStreamTwiML, callTelegramApi, classifyEmailRoute, classifyPhoneNumberRisk, classifyResumeError, clearMediaCapabilityCache, closeDatabase, composeBridgeWakePrompt, createRealtimeTransport, createTestDatabase, createToolExecutor, debug, debugWarn, deleteTelegramWebhook, detectBinary, ensureDataDir, escapeXml, extractEmailAddress, extractVerificationCode, flushTelemetry, forgetHostSession, formatOperatorQueryTelegramMessage, getDatabase, getDatetime, getMediaCapabilities, getOperatorEmail, getSmsProvider, getTelegramChat, getTelegramMe, getTelegramUpdates, getTelegramWebhookInfo, hostSessionStoragePath, inferPhoneRegion, invalidateSkillCache, isInternalEmail, isLoopbackMailHost, isOperatorReplySender, isPhoneRegionAllowed, isSessionFresh, isTelegramChatAllowed, isTelegramStopCommand, isValidPhoneNumber, listSkills, loadHostSession, loadSkill, mapProviderSmsStatus, nextTelegramOffset, normalizeAddress, normalizePhoneNumber, normalizeSubject, operatorPrefsStoragePath, operatorQuerySubject, parseElksRealtimeMessage, parseEmail, parseGoogleVoiceSms, parseOperatorQueryReply, parseTelegramOperatorReply, parseTelegramUpdate, parseTwilioRealtimeMessage, planBridgeWake, pollForOperatorAnswer, recallMemory, recordToolCall, redactBotToken, redactObject, redactPhoneTransportConfig, redactSecret, redactSmsConfig, redactTelegramConfig, renderSkillAsPrompt, requireBinary, requireWhisperModel, resolveConfig, resolveTlsRejectUnauthorized, safeJoin, sanitizeEmail, saveConfig, saveHostSession, saveUserSkill, scanOutboundEmail, scoreEmail, searchSkills, sendTelegramMessage, setOperatorEmail, setTelegramWebhook, setTelemetryVersion, shouldSkipBridgeWakeForLiveOperator, splitTelegramMessage, startRelayBridge, stem, stripTelegramMarkdown, threadIdFor, tokenize, tryJoin, userSkillsDir, validateApiUrl, validatePhoneMissionPolicy, validatePhoneMissionStart, validatePhoneTransportProfile, validateSkill, validateTwilioSignature, webSearch };