/** * [WHO]: Extension interface, AI-driven personalized greetings and idle cues * [FROM]: Depends on @catui/tui, core/extensions-host/types.js, core/platform/i18n, node:path, node:url, node:fs * [TO]: Loaded by core/extensions-host/loader.ts as extension entry point * [HERE]: extensions/builtin/presence/index.ts - AI-generated opening + idle presence lines from memory (episodes/preferences/lessons) + git snapshot (branch/last commit/changed files) + soul personality traits and identity/style preferences, injects last MAX_RECENT_PRESENCE lines into agent systemPrompt per turn, configurable via settings.presence.enabled, canSendOpening guards against agent-is-busy race */ import type { ExtensionAPI } from "../../../core/extensions-host/types.js"; import { collectIdentityPreferenceHighlights, detectLanguageFromMemory, type PresenceMemoryEngine } from "./presence-memory.js"; /** * Read persona-specific presence lines from the active persona's CATUI.md. * Parses `## Presence` section for `### Opening Lines` or `### Idle Lines` blocks. * Returns empty array if no persona or no matching section found. */ declare function getPersonaPresenceLines(kind: "opening" | "idle"): string[]; /** * Read persona identity blocks (Identity / Tone / Working Style) from the active * persona's CATUI.md. These are persona-locked hard constraints — the model's * presence output must conform to them. * * Returns concatenated blocks, truncated to PERSONA_IDENTITY_MAX_CHARS. * Returns empty string when persona is missing or no matching sections found. * * Excludes `## Presence` (handled by getPersonaPresenceLines) and `## Example Interactions` * (kept terse on purpose; the examples can leak style choices that the LLM echoes * verbatim, which we don't want for short opening/idle lines). */ declare function loadPersonaIdentity(): string; declare function getFallbackOpeningLines(locale?: "en" | "zh"): string[]; declare function getFallbackIdleLines(locale?: "en" | "zh"): string[]; /** * Heuristic: do the persona presence lines primarily use the requested locale's script? * Used so a Chinese-only persona does not leak Chinese lines when the user is in English. * Count Chinese characters vs Latin word tokens across the lines. */ declare function personaLinesMatchLocale(lines: readonly string[], locale: "en" | "zh"): boolean; type PresenceState = { lastActivityAt: number; idleReminderSent: boolean; openingStartedAt?: number; openingSent: boolean; openingTimer?: ReturnType; idleTimer?: ReturnType; unsubscribeInput?: () => void; memEngine?: PresenceMemoryEngine; personaMemEngine?: PresenceMemoryEngine; recentPresenceLines: string[]; lastPresenceAt?: number; idleGenerating?: boolean; recentlyReferencedMemories: string[]; awakening?: string; awakeningGenerated?: boolean; }; declare function resolveBundledPackageEntry(packageName: "mem-core" | "soul-core"): string | undefined; declare function getOpeningDelayMs(): number; declare function importRuntimeModule(moduleNames: string[], bundledPackageName?: "mem-core" | "soul-core"): Promise; type PresenceSoulHints = { traits: string[]; tone?: string; identityPreferences: string[]; }; declare function collectSoulHints(soulManager: unknown): PresenceSoulHints; declare function buildPresenceSystemPrompt(locale: "en" | "zh", soulHints: PresenceSoulHints, kind: "opening" | "idle"): string; export default function presenceExtension(api: ExtensionAPI): Promise; /** * Test-only helper: assemble the (systemPrompt, userPrompt) pair that generatePresenceLine * would feed to ctx.completeSimple, without actually invoking the LLM. This lets tests * verify the prompt wiring (persona-locked identity, priority labels, soul de-prioritization, * layered memory) end-to-end without spinning up a model. */ declare function buildPresencePromptPair(state: PresenceState, locale: "en" | "zh", soulHints: PresenceSoulHints, kind: "opening" | "idle", lastUserMessage?: string): Promise<{ systemPrompt: string; userPrompt: string; } | undefined>; export declare const __testUtils: { getFallbackOpeningLines: typeof getFallbackOpeningLines; getFallbackIdleLines: typeof getFallbackIdleLines; getPersonaPresenceLines: typeof getPersonaPresenceLines; loadPersonaIdentity: typeof loadPersonaIdentity; personaLinesMatchLocale: typeof personaLinesMatchLocale; resolveBundledPackageEntry: typeof resolveBundledPackageEntry; importRuntimeModule: typeof importRuntimeModule; detectLanguageFromMemory: typeof detectLanguageFromMemory; collectIdentityPreferenceHighlights: typeof collectIdentityPreferenceHighlights; getOpeningDelayMs: typeof getOpeningDelayMs; collectSoulHints: typeof collectSoulHints; buildPresenceSystemPrompt: typeof buildPresenceSystemPrompt; buildPresencePromptPair: typeof buildPresencePromptPair; }; export {};