import { SessionContext, Honcho } from '@honcho-ai/sdk'; /** * Configuration for createHoncho(). * * Most callers can use `createHoncho()` with no arguments and rely on * `HONCHO_API_KEY` plus implicit workspace fallback. */ interface HonchoProviderOptions { /** Honcho API key. Falls back to HONCHO_API_KEY env var. */ apiKey?: string; /** Workspace ID. Falls back to HONCHO_WORKSPACE_ID env var. */ workspaceId?: string; /** Per-call `userId` > this > generated id with warn-once. Setting this suppresses the warning. */ defaultUserId?: string; /** Per-call `assistantId` > this > `"assistant"`. */ defaultAssistantId?: string; /** Per-call `sessionId` > this > generated id with warn-once. Setting this suppresses the warning. */ defaultSessionId?: string; /** Optional API environment selector. */ environment?: "production" | "local"; /** Optional explicit API URL. Overrides environment. */ baseURL?: string; /** Optional request timeout in milliseconds. */ timeout?: number; /** Optional max retry attempts for HTTP calls. */ maxRetries?: number; /** Optional additional default headers. */ defaultHeaders?: Record; /** Max distinct (assistantId, userId, sessionId) entries cached per provider. LRU-evicted by insertion order. Defaults to 1024. */ maxCacheEntries?: number; } /** * Flat middleware config for AI SDK model wrapping. */ interface HonchoMiddlewareConfig { /** Observed peer. Falls back to `defaultUserId` then a generated id with warn-once. */ userId?: string; /** Session id. `null` opts out; omit to use `defaultSessionId` then a generated id with warn-once. */ sessionId?: string | null; /** AI peer identity generating the response. Defaults to "assistant". */ assistantId?: string; /** Persist the user's input message. Defaults to true. */ persistInput?: boolean; /** Inject recent session messages from Honcho. Defaults to true. */ injectHistory?: boolean; /** Custom context formatter. */ formatContext?: (context: SessionContext) => string; /** Error hook for persistence/context failures. */ onError?: (error: unknown) => void; } /** * Flat tools config. */ interface HonchoToolsConfig { /** Observed peer (typically the end user). Falls back to `defaultUserId` then a generated id with warn-once. */ userId?: string; /** Session id. `null` opts out of session-scoped retrieval; omit to use `defaultSessionId` then a generated id with warn-once. */ sessionId?: string | null; /** AI peer identity for observer-scoped tools. Defaults to "assistant". */ assistantId?: string; } /** * Message persistence helper config. */ interface HonchoSendConfig { /** Peer the message is attributed to. Falls back to `defaultUserId` then a generated id with warn-once. */ userId?: string; /** Session id. `null` throws (`send()` requires session mode); omit to use `defaultSessionId` then a generated id with warn-once. */ sessionId?: string | null; /** AI peer the message is being sent to. Falls back to `defaultAssistantId` then `"assistant"`. Threads through to session setup so multi-peer flows attach the correct assistant. */ assistantId?: string; /** Message content to persist. */ content: string; } /** * Configuration for the PeerIdentity layer. */ interface PeerIdentityOptions { /** Honcho provider options. */ provider: HonchoProviderOptions; /** Peer ID whose identity card to manage. */ peerId: string; /** * Target peer ID (whose card to manage from this peer's perspective). * If omitted, manages the peer's own self-card. */ targetPeerId?: string; } /** * A diff describing changes to a peer card. */ interface CardDiff { added: string[]; removed: string[]; unchanged: string[]; } /** * Snapshot of a peer card at a point in time. */ interface CardSnapshot { entries: string[]; timestamp: string; observerPeerId: string; targetPeerId: string | null; } /** * A live identity document backed by Honcho peer cards. * * Peer cards are structured arrays of biographical facts that Honcho * maintains about a peer. This layer provides a document-like interface * for reading, writing, and evolving those cards. * * @example * ```ts * const identity = await createPeerIdentity({ * provider: { workspaceId: "ws-1" }, * peerId: "agent-narrator", * targetPeerId: "user-alice", * }); * * // Read current card * const card = await identity.read(); * console.log(card); // ["Prefers dark themes", "Speaks English and Spanish"] * * // Append facts * await identity.append(["Works in data science", "Loves hiking"]); * * // Remove outdated facts * await identity.remove(["Speaks English and Spanish"]); * * // Replace the entire card * await identity.replace(["Completely new identity"]); * * // Merge facts (add only new, deduplicated) * const diff = await identity.merge(["Works in data science", "Has a dog"]); * console.log(diff.added); // ["Has a dog"] * * // Take a timestamped snapshot * const snapshot = await identity.snapshot(); * ``` */ interface PeerIdentity { /** The Honcho client. */ client: Honcho; /** Workspace ID. */ workspaceId: string; /** Observer peer ID. */ peerId: string; /** Target peer ID (null = self-card). */ targetPeerId: string | null; /** * Read the current peer card entries. * Returns an empty array if no card exists. */ read(): Promise; /** * Replace the entire peer card with new entries. */ replace(entries: string[]): Promise; /** * Append entries to the existing card. * Does not deduplicate — use `merge` for that. */ append(entries: string[]): Promise; /** * Remove specific entries from the card (exact match). * Returns the updated card. */ remove(entries: string[]): Promise; /** * Merge new entries into the card, skipping exact duplicates. * Returns a diff showing what was added vs already present. */ merge(entries: string[]): Promise; /** * Check if the card contains a specific entry (exact match). */ has(entry: string): Promise; /** * Search card entries for those containing a substring (case-insensitive). */ search(query: string): Promise; /** * Get the number of entries in the card. */ size(): Promise; /** * Take a timestamped snapshot of the current card. */ snapshot(): Promise; /** * Compare the current card to a previous snapshot and return the diff. */ diff(previous: CardSnapshot): Promise; /** * Clear all entries from the card. */ clear(): Promise; } /** * Create a live peer identity document. */ declare function createPeerIdentity(options: PeerIdentityOptions): Promise; /** * Create peer identity documents for all peers in a workspace * observing a single target peer. * * Useful for seeing how different agents perceive the same user. */ declare function createMultiPerspectiveIdentity(options: { provider: HonchoProviderOptions; observerPeerIds: string[]; targetPeerId: string; }): Promise>; /** * Compare how multiple peers perceive the same target. * Returns a map of observerId -> card entries, plus entries * that appear across all observers (consensus) and entries * unique to each observer. */ declare function compareIdentityPerspectives(identities: Map): Promise<{ perspectives: Map; consensus: string[]; unique: Map; }>; export { type CardDiff as C, type HonchoProviderOptions as H, type PeerIdentity as P, type HonchoMiddlewareConfig as a, type HonchoToolsConfig as b, type HonchoSendConfig as c, type CardSnapshot as d, type PeerIdentityOptions as e, compareIdentityPerspectives as f, createMultiPerspectiveIdentity as g, createPeerIdentity as h };